Hi <@ULVA73B9P>, I am trying to run this snippet f...
# ask-marvin
n
Hi @Marvin, I am trying to run this snippet from the docs:
Copy code
import httpx
from prefect import flow


@flow(log_prints=True)
def get_repo_info(repo_name: str = "PrefectHQ/prefect"):
    url = f"<https://api.github.com/repos/{repo_name}>"
    response = httpx.get(url)
    response.raise_for_status()
    repo = response.json()
    print(f"{repo_name} repository statistics 🤓:")
    print(f"Stars 🌠 : {repo['stargazers_count']}")
    print(f"Forks 🍴 : {repo['forks_count']}")


if __name__ == "__main__":
    get_repo_info.from_source(
        source="<https://github.com/discdiver/demos.git>", 
        entrypoint="repo_info.py:get_repo_info"
    ).deploy(
        name="my-first-deployment", 
        work_pool_name="my-managed-pool", 
    )
This code throws error:
Copy code
get_repo_info.from_source(
AttributeError: 'Flow' object has no attribute 'from_source'
What am I missing?
m
Oh dear, it seems that the
from_source
method you are trying to use is not part of the Flow object in Prefect. The code snippet you are running appears to be incorrect or outdated. Prefect does support deployment of flows, but the approach you're using isn't the right way to do it. The snippet from the documentation provided doesn't explicitly cover your usage scenario, and it looks like the functionality you are trying to use has either changed or no longer exists in the version of Prefect you are running. The typical way to deploy a flow involves defining the flow in code and then using the Prefect UI or CLI to create a deployment. I recommend checking the latest documentation on deploying flows with Prefect, as they frequently update their APIs and usage patterns. For the most accurate information, consult the latest Prefect documentation and guides on how to properly deploy flows. If you continue to run into issues, you may need to investigate the exact version of Prefect you are using and make sure that the documentation you're referencing matches that version.
n
k
can you run
prefect version
and let me know what version of prefect you have installed?
n
Hi @Kevin Grismore, Thanks.
Copy code
Version:             2.82
API version:         0.8.4
Python version:      3.10.12
Git commit:          afbed19d
Built:               Fri, Feb 17, 2023 10:02 AM
OS/Arch:             linux/x86_64
Profile:             default
Server type:         server
k
would you be willing to install the latest version for running flows?
pip install prefect==2.14.21
n
I am already using 2.82. Isn't it the latest?
Manage to make it work. Thanks 🙂