Spaces:
Running
Running
experiment implementation
Browse files- utils/config_fabric.py +63 -0
utils/config_fabric.py
CHANGED
@@ -313,3 +313,66 @@ if __name__ == '__main__':
|
|
313 |
progress_bar.progress(100)
|
314 |
|
315 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
progress_bar.progress(100)
|
314 |
|
315 |
|
316 |
+
## proposed change
|
317 |
+
## problem: the code reads the output file even before it is created, this causes an error
|
318 |
+
# if create_button or create_run_button:
|
319 |
+
# with open(output_path, "w") as f:
|
320 |
+
# f.write(config_file)
|
321 |
+
# st.write("Saved configuration in ", output_path, ". Run command:")
|
322 |
+
# create_button = False
|
323 |
+
# var = f"python -W ignore main.py -a {output_path}"
|
324 |
+
# st.code(var, language='bash')
|
325 |
+
|
326 |
+
# if create_run_button:
|
327 |
+
# command = var.split()
|
328 |
+
# progress_bar = st.progress(0) # Initialize the progress bar
|
329 |
+
|
330 |
+
# # Start the subprocess
|
331 |
+
# process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
|
332 |
+
|
333 |
+
# # Get the total number of experiments
|
334 |
+
# total_experiments = len(step_config['generator_params']['experiment'])
|
335 |
+
|
336 |
+
# # Determine the output path
|
337 |
+
# directory = Path(step_config['output_path']).parts
|
338 |
+
# path = os.path.join(directory[0], 'features', *directory[1:])
|
339 |
+
|
340 |
+
# generated_files = 0
|
341 |
+
# last_generated_files_count = 0
|
342 |
+
|
343 |
+
# while process.poll() is None: # While the subprocess is still running
|
344 |
+
# # Count the number of files generated so far
|
345 |
+
# generated_files = len(os.listdir(path))
|
346 |
+
|
347 |
+
# # Update the progress bar only if new files have been generated
|
348 |
+
# if generated_files > last_generated_files_count:
|
349 |
+
# last_generated_files_count = generated_files
|
350 |
+
# progress = min(generated_files / total_experiments, 1.0)
|
351 |
+
# progress_bar.progress(int(progress * 100))
|
352 |
+
|
353 |
+
# time.sleep(1) # Sleep for a short interval before checking again
|
354 |
+
|
355 |
+
# process.wait() # Wait for the process to complete
|
356 |
+
|
357 |
+
# # Final update of the progress bar
|
358 |
+
# progress_bar.progress(100)
|
359 |
+
|
360 |
+
# st.write("Number of files generated: ", generated_files)
|
361 |
+
|
362 |
+
# st.write("## Results")
|
363 |
+
# st.write(*step_config['generator_params']['experiment'][0].keys(), "log name", "target similarity")
|
364 |
+
|
365 |
+
# # Walk through all directories and files
|
366 |
+
# for root, dirs, files in os.walk(path):
|
367 |
+
# feature_files = [os.path.join(root, file) for file in files]
|
368 |
+
# for feature_file in feature_files:
|
369 |
+
# # Open and read the JSON file
|
370 |
+
# with open(feature_file, 'r') as file:
|
371 |
+
# data = json.load(file)
|
372 |
+
# index = int(data['log'].split('genEL')[-1].split('_')[0]) - 1
|
373 |
+
# config_targets = step_config['generator_params']['experiment'][index]
|
374 |
+
|
375 |
+
# # Print the contents of the JSON file
|
376 |
+
# st.write(*config_targets.values(), data['log'], data['target_similarity'])
|
377 |
+
|
378 |
+
# st.write("All files have been generated and processed.")
|