https://prefect.io logo
Title
j

Jan Nitschke

04/04/2022, 9:52 AM
Hi Prefect, I want to run a flow on ECS and use GitHub as storage. My python code imports modules. The flow definition looks something like:
from tasks import my_task
from prefect.storage import GitHub
from prefect import Flow
from prefect.run_configs import ECSRun


storage = GitHub(
    repo="repo",  # name of repo
    path="path/to/myflow.py",  # location of flow file in repo
    access_token_secret="GITHUB_ACCESS_KEY",  # name of personal access token secret
)

with Flow(name="foobar",
          run_config=ECSRun(),
          storage=storage) as flow:
    my_task()
The problem seems to be that the GitHub storage only clones the single file and not the entire project which causes my import to fail. (
ModuleNotFoundError("No module named 'tasks'")
) I've seen that there has been some discussion around this issue but it hasn't really helped me to solve the issue.... Is my only option to clone the repo into the custom image that I use for my ECS task? But that would mean that I would have to rebuild that image every time I change something to my underlying modules, right?
ðŸĪŠ 1
✅ 1
a

Anna Geller

04/04/2022, 10:33 AM
Since ECS tasks run your flows within Docker containers, you would need to package your code into a Docker image. If you need an example of how you can package your custom modules within a Dockerfile and push it to ECR, check out this repo also this blog post
j

Jan Nitschke

04/04/2022, 10:57 AM
ok, thanks for the quick response and for the samples 🙂
👍 1