evalstate/diffusers-pr-api
0
1from __future__ import annotations2 3import os4import subprocess5from pathlib import Path6 7from slop_farmer.config import DeployDashboardOptions8from slop_farmer.data.snapshot_source import resolve_snapshot_source_dir9 10 11def run_deploy_dashboard(options: DeployDashboardOptions) -> None:12 repo_root = Path(__file__).resolve().parents[3]13 script_path = repo_root / "scripts" / "deploy_dashboard_space.sh"14 if not script_path.exists():15 raise FileNotFoundError(f"Could not find deploy script at {script_path}")16 env = os.environ.copy()17 env.update(18 {19 "PIPELINE_DATA_DIR": str(options.pipeline_data_dir),20 "WEB_DIR": str(options.web_dir),21 "SNAPSHOT_DIR": str(22 resolve_snapshot_source_dir(23 snapshot_dir=options.snapshot_dir,24 local_snapshots_root=options.pipeline_data_dir.resolve() / "snapshots",25 hf_repo_id=options.hf_repo_id,26 hf_revision=options.hf_revision,27 hf_materialize_dir=options.hf_materialize_dir,28 hf_output_dir=options.pipeline_data_dir,29 )30 ),31 "DASHBOARD_WINDOW_DAYS": str(options.dashboard_window_days),32 "CONTRIBUTOR_WINDOW_DAYS": str(options.contributor_window_days),33 "CONTRIBUTOR_MAX_AUTHORS": str(options.contributor_max_authors),34 "COMMIT_MESSAGE": options.commit_message,35 "SPACE_ID": options.space_id,36 "SPACE_EMOJI": options.space_emoji,37 "SPACE_COLOR_FROM": options.space_color_from,38 "SPACE_COLOR_TO": options.space_color_to,39 "SPACE_SHORT_DESCRIPTION": options.space_short_description,40 }41 )42 if options.analysis_input is not None:43 env["ANALYSIS_INPUT"] = str(options.analysis_input.resolve())44 if options.contributors_input is not None:45 env["CONTRIBUTORS_INPUT"] = str(options.contributors_input.resolve())46 if options.pr_scope_input is not None:47 env["PR_SCOPE_INPUT"] = str(options.pr_scope_input.resolve())48 if options.refresh_contributors:49 env["REFRESH_CONTRIBUTORS"] = "1"50 if options.private_space:51 env["PRIVATE_FLAG"] = "--private"52 if options.space_title:53 env["SPACE_TITLE"] = options.space_title54 if options.dataset_id:55 env["DATASET_ID"] = options.dataset_id56 if options.space_tags:57 env["SPACE_TAGS"] = options.space_tags58 subprocess.run([str(script_path)], cwd=repo_root, env=env, check=True)59 