Hello, everyone! I'm beginner in Prefect. I try to...
# ask-community
d
Hello, everyone! I'm beginner in Prefect. I try to build flow which will be running some sql file from GitHub. Using Prefect Secrets I have connect between my Perfect Cloud and my GitHub repo. I try to recieve file this way:
Copy code
from prefect.storage.github import GitHub
my_string = GitHub(access_token_secret="github", repo="my_repo", path="etl/query.sql")
but I get only
<class 'prefect.storage.github.GitHub'>
I need to get this file like a string. How I can do it?
k
Welcome @Dmitry! This is a Storage class where your flow will be stored. When you register a flow with Prefect, the metadata is being send to Prefect that the flow lives in this location. During execution time it will retrieve this flow from Github (or another specified strorage). This class is not meant to pull down files.
n
Hi @Dmitry - the task you've imported is for _flow storage_; it's meant to denote the location your agent can retrieve your flow before deploying for execution. I think you'll want to interact directly with the GitHub API to get any files you have there. You'll want to make a post request like this
<http://requests.post|requests.post>( "<https://api.github.com/graphql>", json=request_body, headers=headers)
where
request_body
is a graphql string and
headers
contains your GitHub authentication headers
d
@Kevin Kho Ho, @nicholas, thank you for your help! As I wrote, I have a connection between my Perfect Cloud and my GitHub repo. Is there a way to get data from GitHub without API? Or is API the only way?
k
You would need the Github API for that. We have some Github Tasks available, but none to download a file like that.
upvote 1
d
Thank you, guys! I'll try to figure it out