Spaces:
Running
Running
Andrea Maldonado
commited on
Commit
·
1120efa
1
Parent(s):
a5e0b3a
Show results from GEDI in frontend
Browse files- config_files/config_layout.json +1 -1
- utils/config_fabric.py +36 -15
config_files/config_layout.json
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
{
|
10 |
"pipeline_step": "event_logs_generation",
|
11 |
"output_path": "output/features/2_bpic_features/2_ense_rmcv_feat.csv",
|
12 |
-
"output_path": "data/test",
|
13 |
"generator_params": {
|
14 |
"experiment": "data/grid_objectives.csv",
|
15 |
"experiment": {"input_path": "data/2_bpic_features.csv",
|
|
|
9 |
{
|
10 |
"pipeline_step": "event_logs_generation",
|
11 |
"output_path": "output/features/2_bpic_features/2_ense_rmcv_feat.csv",
|
12 |
+
"output_path": "data/frontend/test",
|
13 |
"generator_params": {
|
14 |
"experiment": "data/grid_objectives.csv",
|
15 |
"experiment": {"input_path": "data/2_bpic_features.csv",
|
utils/config_fabric.py
CHANGED
@@ -2,6 +2,7 @@ from copy import deepcopy
|
|
2 |
from importlib import reload
|
3 |
from itertools import product as cproduct
|
4 |
from itertools import combinations
|
|
|
5 |
from pylab import *
|
6 |
import itertools
|
7 |
import json
|
@@ -186,10 +187,11 @@ def set_generator_experiments(generator_params):
|
|
186 |
with col2:
|
187 |
sel_features = feature_select()
|
188 |
|
|
|
189 |
values_indexes = ["value "+str(i+1) for i in range(num_values)]
|
190 |
values_defaults = ['*(1+2*0.'+str(i)+')' for i in range(num_values)]
|
191 |
cross_labels = [feature[0]+': '+feature[1] for feature in list(cproduct(sel_features,values_indexes))]
|
192 |
-
cross_values = [round(eval(str(combination[0])+combination[1]), 2) for combination in list(cproduct(list(
|
193 |
parameters = split_list(list(input_multicolumn(cross_labels, cross_values, n_cols=num_values)), len(sel_features))
|
194 |
tasks = f"list({parameters})"
|
195 |
|
@@ -267,25 +269,44 @@ if __name__ == '__main__':
|
|
267 |
output_path = st.text_input("Output file path", "config_files/experiment_config.json")
|
268 |
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
269 |
save_labels = ["Save config file", "Save and run config_file"]
|
270 |
-
save_labels = ["Save configuration file"]
|
271 |
-
|
272 |
-
create_button = multi_button(save_labels)
|
273 |
-
if create_button
|
274 |
with open(output_path, "w") as f:
|
275 |
f.write(config_file)
|
276 |
st.write("Saved configuration in ", output_path, ". Run command:")
|
277 |
-
create_button
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
if False: #FIXME: Command fails when using multiprocessing
|
283 |
command = var.split()
|
284 |
|
285 |
# Run the command
|
286 |
result = subprocess.run(command, capture_output=True, text=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
|
288 |
-
if len(result.stderr)==0:
|
289 |
-
st.write(result.stdout)
|
290 |
-
else:
|
291 |
-
st.write("ERROR: ", result.stderr)
|
|
|
2 |
from importlib import reload
|
3 |
from itertools import product as cproduct
|
4 |
from itertools import combinations
|
5 |
+
from pathlib import Path
|
6 |
from pylab import *
|
7 |
import itertools
|
8 |
import json
|
|
|
187 |
with col2:
|
188 |
sel_features = feature_select()
|
189 |
|
190 |
+
filtered_dict = {key: generator_params['experiment'][key] for key in sel_features if key in generator_params['experiment']}
|
191 |
values_indexes = ["value "+str(i+1) for i in range(num_values)]
|
192 |
values_defaults = ['*(1+2*0.'+str(i)+')' for i in range(num_values)]
|
193 |
cross_labels = [feature[0]+': '+feature[1] for feature in list(cproduct(sel_features,values_indexes))]
|
194 |
+
cross_values = [round(eval(str(combination[0])+combination[1]), 2) for combination in list(cproduct(list(filtered_dict.values()), values_defaults))]
|
195 |
parameters = split_list(list(input_multicolumn(cross_labels, cross_values, n_cols=num_values)), len(sel_features))
|
196 |
tasks = f"list({parameters})"
|
197 |
|
|
|
269 |
output_path = st.text_input("Output file path", "config_files/experiment_config.json")
|
270 |
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
271 |
save_labels = ["Save config file", "Save and run config_file"]
|
272 |
+
#save_labels = ["Save configuration file"]
|
273 |
+
create_button, create_run_button = multi_button(save_labels)
|
274 |
+
#create_button = multi_button(save_labels)
|
275 |
+
if create_button or create_run_button:
|
276 |
with open(output_path, "w") as f:
|
277 |
f.write(config_file)
|
278 |
st.write("Saved configuration in ", output_path, ". Run command:")
|
279 |
+
create_button = False
|
280 |
+
var = f"python -W ignore main.py -a {output_path}"
|
281 |
+
st.code(var, language='bash')
|
282 |
+
|
283 |
+
if create_run_button:
|
284 |
+
#if False: #FIXME: Command fails when using multiprocessing
|
285 |
command = var.split()
|
286 |
|
287 |
# Run the command
|
288 |
result = subprocess.run(command, capture_output=True, text=True)
|
289 |
+
st.write("## Results")
|
290 |
+
st.write(*step_config['generator_params']['experiment'][0].keys(), "log name", "target similarity")
|
291 |
+
|
292 |
+
#if len(result.stderr)==0:
|
293 |
+
# st.write(result.stdout)
|
294 |
+
#else:
|
295 |
+
# st.write("ERROR: ", result.stderr)
|
296 |
+
|
297 |
+
directory = Path(step_config['output_path']).parts
|
298 |
+
path = os.path.join(directory[0],'features',*directory[1:])
|
299 |
+
|
300 |
+
# Walk through all directories and files
|
301 |
+
for root, dirs, files in os.walk(path):
|
302 |
+
feature_files = [os.path.join(root, file) for file in files]
|
303 |
+
for feature_file in feature_files:
|
304 |
+
# Open and read the JSON file
|
305 |
+
with open(feature_file, 'r') as file:
|
306 |
+
data = json.load(file)
|
307 |
+
index = int(data['log'].split('genEL')[-1].split('_')[0])-1
|
308 |
+
config_targets = step_config['generator_params']['experiment'][index]
|
309 |
+
|
310 |
+
# Print the contents of the JSON file
|
311 |
+
st.write(*config_targets.values(), data['log'], data['target_similarity'])
|
312 |
|
|
|
|
|
|
|
|