Spaces:
Runtime error
Runtime error
Commit
·
137bc36
1
Parent(s):
6d85f4d
Update substra_launcher.py
Browse files- substra_launcher.py +12 -4
substra_launcher.py
CHANGED
|
@@ -7,8 +7,16 @@ async def launch_substra_space(
|
|
| 7 |
) -> RepoUrl:
|
| 8 |
repo_id = "owkin/trainer-" + repo_id
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
|
|
|
| 12 |
|
| 13 |
with open("substra_template/.env", 'w') as f:
|
| 14 |
f.write(ENV_FILE)
|
|
@@ -19,10 +27,10 @@ async def launch_substra_space(
|
|
| 19 |
space_sdk="docker",
|
| 20 |
)
|
| 21 |
|
| 22 |
-
hf_api.
|
| 23 |
repo_id=repo_id,
|
|
|
|
|
|
|
| 24 |
repo_type="space",
|
| 25 |
-
folder_path="./substra_template/"
|
| 26 |
)
|
| 27 |
-
|
| 28 |
return repo_url
|
|
|
|
| 7 |
) -> RepoUrl:
|
| 8 |
repo_id = "owkin/trainer-" + repo_id
|
| 9 |
|
| 10 |
+
BASE_IMAGE = "ghcr.io/substra/substrafl:substra-hf-demo"
|
| 11 |
+
|
| 12 |
+
DOCKERFILE = f"""
|
| 13 |
+
FROM {BASE_IMAGE}
|
| 14 |
+
|
| 15 |
+
ENV SUBSTRA_ORG1_DISTR={hospital_a / 100}
|
| 16 |
+
ENV SUBSTRA_ORG2_DISTR={hospital_b / 100}
|
| 17 |
|
| 18 |
+
CMD ["bash", "docker-run.sh"]
|
| 19 |
+
"""
|
| 20 |
|
| 21 |
with open("substra_template/.env", 'w') as f:
|
| 22 |
f.write(ENV_FILE)
|
|
|
|
| 27 |
space_sdk="docker",
|
| 28 |
)
|
| 29 |
|
| 30 |
+
hf_api.upload_file(
|
| 31 |
repo_id=repo_id,
|
| 32 |
+
path_or_fileobj=DOCKERFILE.encode(),
|
| 33 |
+
path_in_repo="Dockerfile",
|
| 34 |
repo_type="space",
|
|
|
|
| 35 |
)
|
|
|
|
| 36 |
return repo_url
|