substra / substra_launcher.py
NimaBoscarino's picture
Trainer URL change
15e7787
raw
history blame
No virus
739 Bytes
from huggingface_hub import HfApi, RepoUrl
async def launch_substra_space(
hf_api: HfApi, repo_id: str,
hospital_a: int, hospital_b: int,
) -> RepoUrl:
repo_id = "owkin/trainer-" + repo_id
repo_url = hf_api.create_repo(
repo_id=repo_id,
repo_type="space",
space_sdk="docker",
)
hf_api.upload_folder(
repo_id=repo_id,
repo_type="space",
folder_path="./substra_template/"
)
ENV_FILE = f"""\
SUBSTRA_ORG1_DISTR={hospital_a / 100}
SUBSTRA_ORG2_DISTR={hospital_b / 100}\
"""
hf_api.upload_file(
repo_id=repo_id,
path_or_fileobj=ENV_FILE.encode(),
path_in_repo=".env",
repo_type="space",
)
return repo_url