Hi everybody, has anybody had any success with flo...
# ask-community
s
Hi everybody, has anybody had any success with flow.from_source method to read flow from a git repo of any kind? I am struggling to succeed with the most basic flow and code snipet following documentation. (check the threads with marvin the app to see the exact issues). I don't know how to interpret this frustating start with prefect.
1
j
I made a reproduction and got it to work okay. You need to call
.deploy
to create the deployment. See a repo here that uses a Prefect Managed work pool with the deployment. Then you don’t need a worker.
Copy code
from datetime import datetime
from prefect import flow


@flow(retries=3, retry_delay_seconds=5, log_prints=True)
def dummy_flow(date: datetime = datetime.now()):
    print(f"It was {date.strftime('%A')} on {date.isoformat()}")


if __name__ == "__main__":
    flow.from_source(
        source="<https://github.com/discdiver/help-repo.git>",
        entrypoint="load_from_storage.py:dummy_flow",
    ).deploy(name="example1", work_pool_name="managed2")
I ran
python load_from_storage.py
to create the deployment.
s
Thanks for the reply. I will give it a try and come back to this thread.
I have managed to run the flow successfully now. The problem was in how the git had been configured on my linux machine. Instead of clonning via
<https://github.com/><username>/<repository>.git
, git was forced to clone using ssh keys via
git@github.com:<username>/<repository>.git
url. There is a nice discussion in this link. So basically it was not related to the prefect in the example code though prefect prefect-gitlab python modul must be used with caution.
🙌 1