| """Finalize: upload reproduction bundle as an HF Dataset, register the trackio |
| artifact (so publish rewrites the Conclusion cell to a bucket URL), and add both |
| the dataset and the logbook Space to the collection.""" |
| import os, sys, glob |
| from huggingface_hub import HfApi, upload_folder, create_repo, whoami, add_collection_item |
|
|
| BASE = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| sys.path.insert(0, os.path.join(BASE, "src")) |
| ME = whoami()["name"] |
| DATASET = f"{ME}/mindflow-repro-bundle" |
| COLLECTION = os.environ.get("MINDFLOW_COLLECTION", "") |
| SPACE = f"{ME}/repro-mindflow-mind-supernet-powered-thinking-flows-for-research-idea-innovation" |
|
|
| IGNORE = ["llm_cache/*", "**/__pycache__/*", ".trackio/*", "tools/posterly/*", "or_*.json", |
| "chal_*.json", "*.pyc", "paper.pdf", "outputs/poster/_poster_full.html", "or_notes.json"] |
|
|
| def upload_dataset(): |
| create_repo(DATASET, repo_type="dataset", exist_ok=True) |
| upload_folder(folder_path=BASE, repo_id=DATASET, repo_type="dataset", |
| ignore_patterns=IGNORE, commit_message="MindFlow reproduction bundle") |
| print("dataset:", f"https://huggingface.co/datasets/{DATASET}", flush=True) |
|
|
| def register_artifact(): |
| import trackio |
| |
| os.chdir(BASE) |
| try: |
| trackio.init(project="repro-mindflow-mind-supernet-powered-thinking-flows-for-research-idea-innovation") |
| except Exception as e: |
| print("trackio.init note:", str(e)[:120], flush=True) |
| art = trackio.log_artifact(BASE, name="repro-bundle", type="dataset") |
| print("registered artifact:", getattr(art, "name", art), flush=True) |
| try: |
| trackio.finish() |
| except Exception: |
| pass |
|
|
| def add_to_collection(): |
| if not COLLECTION: |
| print("no collection slug set", flush=True); return |
| for item_id, item_type in [(DATASET, "dataset"), (SPACE, "space")]: |
| try: |
| add_collection_item(COLLECTION, item_id=item_id, item_type=item_type, exists_ok=True) |
| print("added to collection:", item_id, flush=True) |
| except Exception as e: |
| print("collection add note:", item_id, str(e)[:120], flush=True) |
|
|
| if __name__ == "__main__": |
| what = sys.argv[1:] or ["dataset", "collection"] |
| if "dataset" in what: upload_dataset() |
| if "artifact" in what: register_artifact() |
| if "collection" in what: add_to_collection() |
| print("finalize done.") |
|
|