I'm having some issues using the `Github` storage....
# ask-community
c
I'm having some issues using the
Github
storage. I'm configuring it like
Copy code
GitHub(
        repo="some_org/repo_name",
        path="path/to/flow.py",
        access_token_secret="secret_name", 
        ref="stg"
)
When I execute the flow I get the following failure:
Copy code
Failed to load and execute Flow's environment: GithubException(422, {'message': 'No commit found for SHA: stg', 'documentation_url': '<https://docs.github.com/rest/reference/repos#get-a-commit'}>).
That repo definitely has the branch, do I need to reference it in a special way?
k
Hey @Constantino Schillebeeckx, this looks right. Maybe Git storage will be friendlier to work with since you can explicitly specify the branch name?
c
I tried that too, only to get:
Copy code
Failed to load and execute Flow's environment: KeyError(b'refs/remotes/origin/stg')
k
Are you using on on-prem version of Github?
c
no
k
Looking into this
Wait, if stg is your default branch, I think you can leave the ref blank?
c
it is now, but it may not be in the future; regardless that shouldn't break this, should it?
lemme try with a non-default branch
i may have found my issue; please hold from looking into this further
yep, sorry for the false alarm, it was something stupid on my end 🙂
k
I’d like to learn what it was for the future if i see the error again
j
@Constantino Schillebeeckx I’d also like to know what your fix was; I’m having issues with on-prem Gitlab and 404's. If it’s something easy that would be amazing 🙂
k
Are you providing the base URL to indicate you are using on prem?
j
Yes
I’m down to the simplest example I can think of 😅
Copy code
import prefect
from prefect import task, Flow
from prefect.storage.gitlab import GitLab
import os


@task
def say_hi():
    logger = prefect.context.get("logger")
    <http://logger.info|logger.info>("This worked")


with Flow("test1") as flow:
    say_hi()

flow.storage = GitLab(
    repo="{my_org}/{my_project}",
    host="<https://gitlab>.{my_on_prem_server_address}.{TLD}",
    path="flows/test/test.py", #it finds this correctly
    ref=os.getenv("BRANCH"), #this resolves correctly
    access_token_secret="GitLab", #secret in Prefect Cloud
)
Copy code
Error retrieving file contents at flows/test/test.py in {my_org}/{my_project}@{branch}. Ensure the project and file exist.
Copy code
Failed to load and execute Flow's environment: GitlabGetError('404 Commit Not Found')
@Kevin Kho I saw there is an open issue with
python-gitlab > 2.6.0
, would it be possible / advisable for the time being to use
git
storage?
k
I think that might be an option yeah. That is true.
🎉 1