Netanel Malka
02/11/2024, 12:49 PMimport 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:
get_repo_info.from_source(
AttributeError: 'Flow' object has no attribute 'from_source'
What am I missing?Marvin
02/11/2024, 12:49 PMfrom_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.Netanel Malka
02/11/2024, 12:50 PMKevin Grismore
02/11/2024, 2:55 PMprefect version
and let me know what version of prefect you have installed?Netanel Malka
02/11/2024, 2:56 PMVersion: 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
Kevin Grismore
02/11/2024, 3:06 PMpip install prefect==2.14.21
Netanel Malka
02/12/2024, 8:54 AMNetanel Malka
02/12/2024, 1:16 PM