Thread
#prefect-community
    Constantino Schillebeeckx

    Constantino Schillebeeckx

    1 year ago
    I'm having some issues using the
    Github
    storage. I'm configuring it like
    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:
    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?
    Kevin Kho

    Kevin Kho

    1 year ago
    Hey @Constantino Schillebeeckx, this looks right. Maybe Git storage will be friendlier to work with since you can explicitly specify the branch name?
    Constantino Schillebeeckx

    Constantino Schillebeeckx

    1 year ago
    I tried that too, only to get:
    Failed to load and execute Flow's environment: KeyError(b'refs/remotes/origin/stg')
    Kevin Kho

    Kevin Kho

    1 year ago
    Are you using on on-prem version of Github?
    Constantino Schillebeeckx

    Constantino Schillebeeckx

    1 year ago
    no
    Kevin Kho

    Kevin Kho

    1 year ago
    Looking into this
    Wait, if stg is your default branch, I think you can leave the ref blank?
    Constantino Schillebeeckx

    Constantino Schillebeeckx

    1 year ago
    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 🙂
    Kevin Kho

    Kevin Kho

    1 year ago
    I’d like to learn what it was for the future if i see the error again
    j

    Jake Place

    1 year ago
    @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 🙂
    Kevin Kho

    Kevin Kho

    1 year ago
    Are you providing the base URL to indicate you are using on prem?
    j

    Jake Place

    1 year ago
    Yes
    I’m down to the simplest example I can think of 😅
    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
    )
    Error retrieving file contents at flows/test/test.py in {my_org}/{my_project}@{branch}. Ensure the project and file exist.
    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?
    Kevin Kho

    Kevin Kho

    1 year ago
    I think that might be an option yeah. That is true.