-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_setup.py
More file actions
60 lines (46 loc) · 1.59 KB
/
app_setup.py
File metadata and controls
60 lines (46 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import os
import subprocess
from backend.config.paths import (
RESOURCES_DIR,
DATASET_FILE,
DOCKER_DIR,
METHODS_TS_FILE,
)
from backend.utils.methods_handler import Methods
IMAGE_NAME = "pysymgym-test"
def fetch_dataset(data_upload_file):
container_name = "temp-fetch-dataset"
try:
subprocess.run(
["docker", "create", "--name", container_name, IMAGE_NAME],
check=True,
capture_output=True,
)
subprocess.run(
[
"docker",
"cp",
f"{container_name}:/workspace/PySymGym/maps/DotNet/Maps/dataset.json",
data_upload_file,
],
check=True,
)
print(f"Dataset copied to {data_upload_file}")
return data_upload_file
finally:
subprocess.run(["docker", "rm", container_name], capture_output=True)
def build_container():
print(f"Building Docker image '{IMAGE_NAME}'...")
subprocess.run(
["docker", "build", "--no-cache", "-t", IMAGE_NAME, DOCKER_DIR], check=True
)
print("Docker build completed.\n")
os.makedirs(RESOURCES_DIR, exist_ok=True)
def update_frontend_selection_options(dataset_file, selection_options_file):
print("Updating frontend selection options...")
selection_tree = Methods.build_selection_tree_from_dataset(dataset_file)
Methods.save_selection_to_frontend_file(selection_tree, selection_options_file)
if __name__ == "__main__":
build_container()
fetch_dataset(DATASET_FILE)
update_frontend_selection_options(DATASET_FILE, METHODS_TS_FILE)