MCPcopy Create free account
hub / github.com/huggingface/evaluate / convert_github_url

Function convert_github_url

src/evaluate/loading.py:111–127  ·  view source on GitHub ↗

Convert a link to a file on a github repo in a link to the raw github object.

(url_path: str)

Source from the content-addressed store, hash-verified

109
110
111def convert_github_url(url_path: str) -> Tuple[str, Optional[str]]:
112 """Convert a link to a file on a github repo in a link to the raw github object."""
113 parsed = urlparse(url_path)
114 sub_directory = None
115 if parsed.scheme in ("http", "https", "s3") and parsed.netloc == "github.com":
116 if "blob" in url_path:
117 if not url_path.endswith(".py"):
118 raise ValueError(f"External import from github at {url_path} should point to a file ending with '.py'")
119 url_path = url_path.replace("blob", "raw") # Point to the raw file
120 else:
121 # Parse github url to point to zip
122 github_path = parsed.path[1:]
123 repo_info, branch = github_path.split("/tree/") if "/tree/" in github_path else (github_path, "master")
124 repo_owner, repo_name = repo_info.split("/")
125 url_path = f"https://github.com/{repo_owner}/{repo_name}/archive/{branch}.zip"
126 sub_directory = f"{repo_name}-{branch}"
127 return url_path, sub_directory
128
129
130def increase_load_count(name: str, resource_type: str):

Callers 1

get_importsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…