Andreas Tsangarides
09/17/2021, 7:27 AMif __name__ == '__main__':
# run/register flow
works fine. But if you have modules python does not like it. I was hoping for a structure like the screenshot attached below. For now, I import the flow I am working on the main,py
file and that's the one I use to register my flow and test locally (with docker-compose, local agent and the UI)Kyle McChesney
09/17/2021, 1:42 PMprefect run -p path/to/file/with/flow.py
(different flows should be defined in different files, just pass the file with the flow you want to run). Similarly the prefect register
command can be used to register flows, it takes a -p
flag as well.
https://docs.prefect.io/api/latest/cli/run.html
https://docs.prefect.io/api/latest/cli/register.htmlAndreas Tsangarides
09/17/2021, 2:28 PM# uk_prefect_flows/projects/elexon/flow.py
from prefect import Flow
from .tasks import define_settlement_date
with Flow("local") as flow:
set_date = define_settlement_date()
used the prefect run
as you said but getting the relative import error..
% prefect run -p
...
from .tasks import (
ImportError: attempted relative import with no known parent package
Kyle McChesney
09/17/2021, 2:43 PMsetup.py
file at your project root with the following contents
from setuptools import find_packages, setup
setup(
name='uk_prefect_flows',
packages=[
'uk_prefect_flows',
'uk_prefect_flows.projects',
'uk_prefect_flows.projects.elexon',
],
)
Then do pip install -e .
Then update your imports to be fully qualified from uk_prefect_flows.projects.elexon.tasks import define_settlement_date
Andreas Tsangarides
09/17/2021, 2:49 PMKyle McChesney
09/17/2021, 3:08 PMFROM prefecthq/prefect:0.15.2
WORKDIR /app
COPY requirements.txt /app/
RUN pip3 install -r requirements.txt
COPY setup.py /app/
COPY uk_prefect_flows/ /app/uk_prefect_flows/
RUN python3 setup.py install
Kyle McChesney
09/17/2021, 3:12 PMAndreas Tsangarides
09/17/2021, 3:34 PMDavid Jenkins
09/17/2021, 4:44 PMconda develop .
this will add the base directory sys.path, making every module in the project available everywhereAndreas Tsangarides
09/20/2021, 8:13 PMpoetry
for managing packages:
1. poetry install
installs the current project as well to allow local development
2. in the script that the flow is defined use full imports (not relative)Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by