Hello folks! I've been testing Prefect Deployments...
# ask-community
n
Hello folks! I've been testing Prefect Deployments, and I can across this. I am using
prefect deploy
to create one, and a Git repo as the code source. So far it seems that the Python script needs to live in the parent directory of the repo and not in a subdirectory. Otherwise, the Work Pool throws an error:
Copy code
FileNotFoundError: [Errno 2] No such file or directory:...
...
prefect.exceptions.ScriptError: Script at 'test_flow_deployment.py' encountered an exception: FileNotFoundError(2, 'No such file or directory')
Prefect's Interactive tool, aside from the Git repo link and branch, doesn't ask for a directory name. If this is truly the only way to do it, it's definitely not the neatest implementation. But I'd guess there must be a way to direct Prefect to the subdirectories somehow, which I haven't figured out yet. If anyone knows how to do so, please share your knowledge. TIA!
j
Use
from_source
to share where the file is
n
@Janet Carson thanks a bunch for the tip! I am assuming (and based on a quick research) that this needs to be declared in my python script (as the entrypoint?). Something like:
Copy code
flow.from_source(
        source="<https://github.com/username/repo.git>",
        entrypoint="path/to/script/my_script.py:my_main_flow",
    )
Source. Could you please confirm? Thanks again!
j
I'm still taking baby steps on from_source - so not pulling the latest from git yet. I just have source = "my dircectory" rather than a git link. The entrypoint arg looks lithe same though: "path-relative-to-my-directory/file.py:function_name"