Hi! I have a project that started with flow.py, no...
# prefect-community
w
Hi! I have a project that started with flow.py, now I need to create another flow, is it ok that I just create the new flow (db-flow.py) in this same folder?
k
I don’t think the structure of the directory necessarily matters. It would depend on your storage. What is your storage?
w
Github
k
For Github yeah this won’t affect anything. Just note Github Storage can’t do imports between files. Like if
db-flow.py
imports from
flow.py
w
awesome
thanks!
feel better.
❤️ 1
k
Oh lol thanks!
g
is there any other way that i could not miss the import functionalities? Would be a great case for modularisation of the code
k
You would need to install it either in the execution environment, or use Docker storage to hold dependencies
g
what do you meant by install it in the execution environment? 😁
This means i can reference a module with utility functions that i use? I wouldn’t like to maintain packages in this occasion because it’s something that it’s tailored for each case/flow that i build
k
Like if you use a local agent, and the agent has access to the files in the PYTHONPATH, it will be able to resolve the imports. For example, the LocalRun takes in a
working_dir
. But if you are using something Docker based, then they need to go inside the image.
👍 1
g
Apparently my flows don’t run when i try to use Github as part of my flow.storage. Don’t know exactly what it’s missing here:
Copy code
❯ prefect diagnostics
{
  "config_overrides": {
    "context": {
      "secrets": false
    }
  },
  "env_vars": [],
  "system_information": {
    "platform": "macOS-12.3.1-x86_64-i386-64bit",
    "prefect_backend": "cloud",
    "prefect_version": "1.2.1",
    "python_version": "3.9.10"
  }
}
Code:
Copy code
with Flow("zendesk_tickets_incremental") as flow:

    latest_date = latest_date_unix()
    incremental = incremental_call(latest_date)
    incremental_df = create_df(incremental)
    upload = upload_to_snowflake(incremental_df)

flow.storage = GitHub(
    repo='X/prefect',
    path='/zendesk/scripts/{FLOW_NAME}.py',
    access_token_secret= Secret('GITHUB_ACCESS_TOKEN').get()  # required with private repositories
)
flow.run_config = LocalRun()
flow.register("zendesk_project_test")
k
As in stuck in scheduled? It is most likely a label issue between Flow and agent. You can find more info here
g
I’m not using labels neither in the Agent nor in the flow
k
Is it stuck in scheduled or submitted?
Wait, the local agent has a default label. Are you sure you have no labels?
g
uhm, didn’t knew that the label was actually mandatory to make it run - Let me try to add them here
k
No more like you need to remove the default label
Copy code
prefect agent local start --no-hostname-label
1
g
Ok, that seems to work, but now apparently Github is throwing errors back at me even though i already setup the access
Copy code
State Message:
Failed to load and execute flow run: UnknownObjectException(404, {'message': 'Not Found', 'documentation_url': '<https://docs.github.com/rest/reference/repos#get-a-repository>'}
k
Your access token secret should be the name of the secret itself. Not the value. And then it is pulled during runtime
g
Yeah, i notice that and corrected the script following:
Copy code
access_token_secret= 'GITHUB_ACCESS_TOKEN'
but that was the error that i’m getting throw back
k
I wouldn’t know then. It looks right. I have a public example here and the path and repo look right to me. Only suggestion I have is maybe add the branch to be explicit. And then the other question is if you host your own Github?
But yes that error is really not finding the Flow. It also might be faster for you to debug if you do:
Copy code
flow.storage = GitHub(
    repo='X/prefect',
    path='/zendesk/scripts/{FLOW_NAME}.py',
    access_token_secret= Secret('GITHUB_ACCESS_TOKEN').get()  # required with private repositories
)
Copy code
flow.storage.add_flow(flow)
flow.storage.get_flow()
to see if you can pull. You can avoid re-registration this way and test a lot faster I think
g
Yeah, now a simple version of the error:
Copy code
github.GithubException.UnknownObjectException: 404 {"message": "Not Found", "documentation_url": "<https://docs.github.com/rest/reference/repos#get-repository-content>"}
It’s a private repo inside an organisation account
k
Yeah this is really not finding it, but I don’t think there’s a lot more I can do to debug that. If you are using the normal github.com, this looks good from what I can tell without peekin gin