Janet Carson
08/29/2024, 7:08 PM@flow
def my_flow(arg1, etc.):
...
if __name__ == "__main__":
# process some CLI args, etc
deployment = my_flow.to_deployment(
name="my_custom_name",
version="1.2.3",
parameters = {
"arg1": value1,
..etc
}
)
serve(deployment)
This was working great until I tried to run my CLI command from a place other than my source tree, then it fails in python3.10/site-packages/prefect/deployments/runner.py at line 543
541 # set entrypoint
542 entry_path = (
543 Path(flow_file).absolute().relative_to(Path.cwd().absolute())
544 )
545 deployment.entrypoint = f"{entry_path}:{flow.fn.__name__}"
546
Is there a hard requirement that you must run a flow this way from within your source tree? Why? If not, is there a way to set an argument to avoid this error?Nate
08/29/2024, 8:08 PMJanet Carson
08/29/2024, 9:19 PMNate
08/29/2024, 9:42 PMJanet Carson
08/29/2024, 9:47 PMJanet Carson
08/29/2024, 9:49 PMmake setup
to install, then make works
works and make fails
failsJanet Carson
08/30/2024, 6:04 PMNate
08/30/2024, 6:05 PMJanet Carson
08/30/2024, 6:05 PMJanet Carson
08/30/2024, 6:05 PMNate
08/30/2024, 6:06 PMJanet Carson
08/30/2024, 6:12 PMJanet Carson
08/30/2024, 9:57 PMJanet Carson
08/30/2024, 9:57 PMsimple_example/
simple_example/silly_package/
simple_example/silly_package/pyproject.toml
simple_example/silly_package/silly_package/
simple_example/silly_package/silly_package/silly_flow.py
simple_example/Makefile
Janet Carson
08/30/2024, 9:58 PMNate
08/30/2024, 10:15 PMNate
08/30/2024, 10:22 PMnate :: ~/github.com/zzstoatzz/simple_example ‹main›
» make fails
mkdir sub_directory && \
. ./silly/bin/activate && \
cd sub_directory && \
uv run silly_script
warning: `uv run` is experimental and may change without warning
Your flow 'flow-main' is being served and polling for scheduled runs!
To trigger a run for this flow, use the following command:
$ prefect deployment run 'flow-main/a-silly-flow'
You can also run your flow via the Prefect UI: <https://app.prefect.cloud/account/12242a57-9f05-4bf5-8853-9bff595d4bab/workspace/cafa2ffa-f6cc-4ed6-ab76-eaa4ba1ad40e/deployments/deployment/5eb2a3dd-e884-4e46-b65c-2f638b84d331>
Nate
08/30/2024, 10:22 PMNate
08/30/2024, 10:22 PMfrom_source
to tell us in general where the source lives
which in this case is a file, but could be a repo, s3 bucket etcJanet Carson
08/30/2024, 10:29 PMNate
08/30/2024, 10:29 PMNate
08/30/2024, 10:31 PMJanet Carson
08/30/2024, 10:31 PMpath = Path(__file__)
flow_main.from_source(
source=str(path.parent.resolve()),
entrypoint=f"{path.name}:flow_main",
I'm wondering if the path in the general case (where I have multiple packages, etc, if the path would be the location of "site-packages" in my virtual environment where all the everything is, or whether it is still just the path to where the entrypoint file isNate
08/30/2024, 10:32 PMJanet Carson
08/30/2024, 10:32 PMJanet Carson
09/13/2024, 4:49 PMNate
09/13/2024, 4:50 PMfrom_source
is just to tell the API where the deployment entrypoint is
normal python rules once you start the entrypointJanet Carson
09/13/2024, 4:51 PM