Skip to content

Commit 5065e50

Browse files
authored
0.31.0 - Exploration update
2 parents 2f1a12b + 3011037 commit 5065e50

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+5247
-306
lines changed

.github/workflows/pull-request-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up Python
1717
uses: actions/setup-python@v1
1818
with:
19-
python-version: 3.10.16
19+
python-version: "3.11"
2020
- name: Install dependencies and check black format
2121
run: |
2222
cd debiaiServer
@@ -32,7 +32,7 @@ jobs:
3232
- name: Set up Python
3333
uses: actions/setup-python@v1
3434
with:
35-
python-version: 3.10.16
35+
python-version: "3.11"
3636
- name: Install dependencies and check flake8 format
3737
run: |
3838
cd debiaiServer

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ frontend/node_modules/
1818
# Scripts
1919
build_and_run.sh
2020

21-
# Deployement
21+
# Deployment
2222
deployment/
2323

2424
# VSCODE
2525
.vscode/
26+
.kilocode/
27+
28+
# Databases
29+
*.db

cspell.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"fromlist",
2525
"groundtruth",
2626
"ICAS",
27+
"kilocode",
2728
"kneighbors",
2829
"kraskov",
2930
"nats",
@@ -33,6 +34,7 @@
3334
"numpy",
3435
"openapi",
3536
"pearsonr",
37+
"pickledb",
3638
"plotly",
3739
"psutil",
3840
"pval",

debiaiServer/config/init_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def get_config_values(section, parameters, config_parser):
153153

154154

155155
def set_config_value(section, key, value):
156-
global config, changes_made
156+
global changes_made
157157

158158
if section in config and key in config[section]:
159159
if config[section][key] != value:
@@ -172,7 +172,7 @@ def set_config_value(section, key, value):
172172

173173

174174
def init_config(data_folder_path: str = None, parameters: dict = {}):
175-
global DATA_FOLDER_PATH, config
175+
global DATA_FOLDER_PATH
176176

177177
print("===================== CONFIG =======================")
178178

debiaiServer/exploration/__init__.py

Whitespace-only changes.
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
import uuid
2+
import threading
3+
from typing import List
4+
from .utils import (
5+
project_explorations_db,
6+
start_exploration_real_combination_computation,
7+
get_exploration_by_id,
8+
update_explorations,
9+
update_exploration as update_exploration_db,
10+
create_selection,
11+
computation_threads,
12+
stop_flags,
13+
)
14+
15+
16+
def get_exploration_available_config():
17+
pass
18+
19+
20+
def get_explorations(project_id):
21+
explorations: List[dict] = project_explorations_db.get(project_id) or []
22+
for exploration in explorations:
23+
exploration.pop("combinations", None)
24+
exploration.pop("metrics", None)
25+
return explorations
26+
27+
28+
def create_exploration(project_id, body):
29+
# Get current explorations
30+
explorations = project_explorations_db.get(project_id) or []
31+
32+
# Add new exploration
33+
explorations.append(
34+
{
35+
"id": str(uuid.uuid4()),
36+
"name": body.get("name"),
37+
"description": body.get("description", ""),
38+
"state": "not_started",
39+
"config": {},
40+
}
41+
)
42+
43+
# Update the database
44+
update_explorations(project_id, explorations)
45+
46+
47+
def get_exploration(project_id, exploration_id):
48+
return get_exploration_by_id(project_id, exploration_id)
49+
50+
51+
def delete_exploration(project_id, exploration_id):
52+
# Get current explorations
53+
explorations = project_explorations_db.get(project_id) or []
54+
55+
# Filter out the exploration to delete
56+
explorations = [
57+
exploration
58+
for exploration in explorations
59+
if exploration.get("id") != exploration_id
60+
]
61+
62+
# Update the database
63+
update_explorations(project_id, explorations)
64+
return explorations
65+
66+
67+
def update_exploration(project_id, exploration_id, action, body):
68+
exploration = get_exploration(project_id, exploration_id)
69+
if exploration is None:
70+
print("Exploration not found:", exploration_id)
71+
return None
72+
73+
# Perform action based on the request
74+
if action == "start":
75+
# Check if the exploration is already running
76+
if exploration.get("state") == "ongoing":
77+
print("Exploration is already running:", exploration_id)
78+
return exploration
79+
80+
# Start the exploration computation in a separate thread
81+
thread = threading.Thread(
82+
target=start_exploration_real_combination_computation,
83+
args=(project_id, exploration_id),
84+
daemon=True,
85+
)
86+
thread.start()
87+
88+
# Save the thread in the global dictionary
89+
computation_threads[exploration_id] = thread
90+
91+
return exploration
92+
elif action == "stop":
93+
# Stop the exploration computation
94+
if exploration_id in computation_threads:
95+
# Set the stop flag
96+
stop_flags[exploration_id] = True
97+
98+
# Wait for the thread to finish
99+
computation_threads[exploration_id].join()
100+
del computation_threads[exploration_id]
101+
del stop_flags[exploration_id]
102+
elif exploration.get("state") == "ongoing":
103+
# Exploration is ongoing but no thread found, set state to not_started
104+
exploration["state"] = "not_started"
105+
106+
return exploration
107+
elif action == "updateConfig":
108+
# Do not update the exploration if it is running
109+
if exploration.get("state") == "ongoing":
110+
print("Cannot update config while exploration is running:", exploration_id)
111+
return exploration
112+
113+
# Update exploration config
114+
exploration["config"] = body
115+
update_exploration_db(project_id, exploration)
116+
return exploration
117+
else:
118+
raise ValueError(f"Unknown action: {action}")
119+
120+
121+
def update_exploration_config():
122+
pass
123+
124+
125+
def create_exploration_selection(project_id, exploration_id, body):
126+
# Create a selection for the exploration
127+
create_selection(
128+
project_id,
129+
exploration_id,
130+
body["selected_combinations"],
131+
body["selection_name"],
132+
)
133+
134+
return 201

0 commit comments

Comments
 (0)