Hi, I am trying to use Git repository for storage ...
# ask-community
t
Hi, I am trying to use Git repository for storage and run my flows but the flow is not working giving error that the unable to find directory. Can you help me here. Is there any working use case example which I look at which uses git Storage ? Thanks !
j
Hi @Talha - there’s an idiom in the docs here: https://docs.prefect.io/core/idioms/script-based.html
t
Thanks for getting back to me. If I use the git storage. Do i need to make any change to my agent as wll
well
j
You shouldn't need to. You can see a bit more about the right kind of storage class/agent type here: https://docs.prefect.io/orchestration/flow_config/storage.html#choosing-a-storage-class
t
I am getting this error. I have set the Secret on the Local agent as well
prefect agent start --name talha_local --label talha --no-hostname-label --env PREFECT__CONTEXT__SECRETS__MYSECRET="My_tokenValue"
j
Hi Tahla - MY_SECRET is the secret name and should be entered in your code as well. For example:
Copy code
flow = Flow(
    "github-flow",
    GitHub(
        repo="org/repo",                           # name of repo
        path="flows/my_flow.py",                   # location of flow file in repo
        access_token_secret="MY_SECRET"  # name of personal access token secret
    )
)
t
what I am doing wrong
Still getting this error Failed to load and execute Flow's environment: ValueError('Local Secret "GITHUB_ACCESS_TOKEN" was not found.')
j
Looks like your secret name is being set as GITHUB_ACCESS_TOKEN instead of your intended name?
Let's try simplify. In your storage use:
Copy code
storage = Github(
   ...
   access_token_secret="GITHUB_ACCESS_TOKEN"
)
Then to run your agent:
prefect agent start --name talha_local --label talha --no-hostname-label --env PREFECT__CONTEXT__SECRETS__GITHUB_ACCESS_TOKEN="YOUR_TOKEN_VALUE_"
Maybe also take out those top four lines to avoid any messiness.
t
yeah, I followed this, and it is working
🚀 1
Now I am thinking about how can I make multiple flow.py files and run them.
as the path in the Github() storage points to a single file as flows/myflow.py
So can you guide me on how can I point to the whole folder or repository, instead of a single flow.py file
j
Hi Talha. It seems you’re looking for someone to walk you through step-by-step in this setup, which I’m unable to do - please open a documentation request on GitHub so we can fill in the gaps in our tutorials.