-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[WIP] feat: automatically reproduce model from reproduce.json #326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,8 +1,11 @@ | ||||||||
| # SPDX-License-Identifier: AGPL-3.0-or-later | ||||||||
| # Copyright (C) 2025-2026 Philipp Emanuel Weidmann <pew@worldwidemann.com> + contributors | ||||||||
|
|
||||||||
| import json | ||||||||
| import shutil | ||||||||
| from pathlib import Path | ||||||||
| from typing import Any | ||||||||
| from urllib.request import urlopen | ||||||||
|
|
||||||||
| from huggingface_hub import HfApi, hf_hub_download | ||||||||
| from huggingface_hub.utils import disable_progress_bars, enable_progress_bars | ||||||||
|
|
@@ -81,3 +84,19 @@ def collect_reproducibles(path: str): | |||||||
| print(f"Found: [bold]{found}[/] files") | ||||||||
| print(f"Downloaded: [bold]{downloaded}[/] files") | ||||||||
| print(f"Already stored: [bold]{found - downloaded}[/] files") | ||||||||
|
|
||||||||
|
|
||||||||
| def load_reproduction_information(path: str) -> dict[str, Any]: | ||||||||
| if path.lower().startswith(("http://", "https://")): | ||||||||
| # The path is a URL on the web. | ||||||||
|
|
||||||||
| # Obtain raw download URL. | ||||||||
| path = path.replace("/blob/", "/raw/") # Hugging Face, GitHub | ||||||||
| path = path.replace("/src/branch/", "/raw/branch/") # Codeberg | ||||||||
|
p-e-w marked this conversation as resolved.
|
||||||||
|
|
||||||||
| json_str = urlopen(path).read().decode("utf-8") | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is recommended to use a context manager with
Suggested change
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough. |
||||||||
| else: | ||||||||
| # The path is (assumed to be) a local file system path. | ||||||||
| json_str = Path(path).read_text(encoding="utf-8") | ||||||||
|
|
||||||||
| return json.loads(json_str) | ||||||||
Uh oh!
There was an error while loading. Please reload this page.