Skip to content

Commit

Permalink
support github repositories outside the ModelDBRepository organisation
Browse files Browse the repository at this point in the history
  • Loading branch information
olupton committed Dec 15, 2022
1 parent 0a84f9b commit 3ab37e8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions modeldb/modeldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,20 @@ def download_model(arg_tuple):
# we downloaded from the ModelDB API just above with a version from
# GitHub
github = model_run_info["github"]
organisation = "ModelDBRepository"
suffix = "" # default branch
if github == "default":
suffix = ""
pass
elif github.startswith("pull/"):
pr_number = int(github[5:])
suffix = "/pull/{}/head".format(pr_number)
elif github.startswith('/'):
# /org implies that we use the default branch from org/model_id
organisation = github[1:]
else:
raise Exception("Invalid value for github key: {}".format(github))
github_url = "https://api.github.com/repos/ModelDBRepository/{model_id}/zipball{suffix}".format(
model_id=model_id, suffix=suffix
github_url = "https://api.github.com/repos/{organisation}/{model_id}/zipball{suffix}".format(
model_id=model_id, organisation=organisation, suffix=suffix
)
# Replace the local file `model_zip_uri` with the zip file we
# downloaded from `github_url`
Expand Down

0 comments on commit 3ab37e8

Please sign in to comment.