Skip to content
Snippets Groups Projects
Commit cc2789df authored by Erik Schnaubelt's avatar Erik Schnaubelt
Browse files

parallelize snapshot and compiled getdp tests

parent c71ac1f8
No related branches found
No related tags found
No related merge requests found
Pipeline #8597723 passed
...@@ -248,18 +248,18 @@ pypi-package: ...@@ -248,18 +248,18 @@ pypi-package:
# to setup the website, follow https://how-to.docs.cern.ch/ # to setup the website, follow https://how-to.docs.cern.ch/
pages: pages:
stage: deploy stage: deploy
# we can build the docs without any dependency needs: ["prepare_venv"]
needs: [] before_script:
# a standard python image is just fine - C:\venvs\steam-material-library\Scripts\Activate.ps1
image: python:3.11.8
script: script:
# install only packages containing the string "mkdocs" from requirements.txt
- pip install -r requirements.txt
- mkdocs build --clean --site-dir public - mkdocs build --clean --site-dir public
artifacts: artifacts:
paths: paths:
- public - public
# - docs/source
rules: rules:
- if: $CI_COMMIT_TAG # Any tag is created - if: $CI_COMMIT_TAG # Any tag is created
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
\ No newline at end of file # These tags are to use the STEAM shared runner
tags:
- matlab
- windows
\ No newline at end of file
...@@ -6,6 +6,8 @@ import os ...@@ -6,6 +6,8 @@ import os
import zipfile import zipfile
import numpy as np import numpy as np
import time import time
from concurrent.futures import ThreadPoolExecutor, as_completed
def create_gmsh_dummy_mesh(output_folder_path, model_name_arg): def create_gmsh_dummy_mesh(output_folder_path, model_name_arg):
gmsh.initialize() gmsh.initialize()
...@@ -40,6 +42,46 @@ def read_output_file(file_path): ...@@ -40,6 +42,46 @@ def read_output_file(file_path):
output = np.loadtxt(f)[:, 1] output = np.loadtxt(f)[:, 1]
return output return output
def subprocess_call_getdp(cerngetdp_path, output_folder_txt, pro_file, outputs_folder_msh, model_name, input_dict):
try:
status = subprocess.run(
[
cerngetdp_path,
pro_file,
"-solve", "#1",
"-pos", "#1",
"-v", "0",
"-msh", os.path.join(outputs_folder_msh, f"{model_name}.msh"),
"-name", os.path.join(output_folder_txt, input_dict['c_function_name'])
],
check=True
)
if status.returncode == 0:
output_file_path = os.path.join(output_folder_txt, f"{input_dict['function_name']}.txt")
return read_output_file(output_file_path)
except Exception as e:
print(f"Error processing {cerngetdp_path}: {e}")
return None
def parallel_getdp_calls(cerngetdp_path_list, outputs_folder_txt_list, pro_file, outputs_folder_msh, model_name, input_dict):
all_outputs = []
with ThreadPoolExecutor() as executor:
futures = [
executor.submit(
subprocess_call_getdp, cerngetdp_path, output_folder_txt, pro_file, outputs_folder_msh, model_name, input_dict
)
for cerngetdp_path, output_folder_txt in zip(cerngetdp_path_list, outputs_folder_txt_list)
]
for future in as_completed(futures):
result = future.result()
if result is not None:
all_outputs.append(result)
return all_outputs
def call_getdp_function(input_dict, model_name, cerngetdp_path_list, pro_template_path, outputs_folder_msh, outputs_folder_pro, outputs_folder_txt_list): def call_getdp_function(input_dict, model_name, cerngetdp_path_list, pro_template_path, outputs_folder_msh, outputs_folder_pro, outputs_folder_txt_list):
""" """
Call the getdp executable and evaluate values of a GetDP function for all input values. Call the getdp executable and evaluate values of a GetDP function for all input values.
...@@ -57,15 +99,15 @@ def call_getdp_function(input_dict, model_name, cerngetdp_path_list, pro_templat ...@@ -57,15 +99,15 @@ def call_getdp_function(input_dict, model_name, cerngetdp_path_list, pro_templat
pro_file = template_pro_file(pro_template_path, model_name, input_dict, outputs_folder_pro) pro_file = template_pro_file(pro_template_path, model_name, input_dict, outputs_folder_pro)
all_outputs = [] all_outputs = []
for cerngetdp_path, output_folder_txt in zip(cerngetdp_path_list, outputs_folder_txt_list):
status = subprocess.run([cerngetdp_path, pro_file, "-solve", "#1", "-pos", "#1", "-v", "0", "-msh", os.path.join(outputs_folder_msh, f"{model_name}.msh"), "-name", os.path.join(output_folder_txt, input_dict['c_function_name'])], check=True) all_outputs = parallel_getdp_calls(
cerngetdp_path_list,
if status.returncode == 0: outputs_folder_txt_list,
output_file_path = os.path.join(output_folder_txt, f"{input_dict['function_name']}.txt") pro_file,
all_outputs.append(read_output_file(output_file_path)) outputs_folder_msh,
else: model_name,
return None input_dict
)
return all_outputs return all_outputs
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment