From 45ac856d888442d2cd382f458c60721f895ef556 Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Mon, 25 Nov 2024 19:46:24 -0500 Subject: [PATCH] ci: Generate Fluent journals --- tests/conftest.py | 26 ++++---------------------- tests/fluent_fixtures.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 1d685f06a25..8823e8180cf 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -75,34 +75,16 @@ def pytest_runtest_setup(item): pytest.skip() -# Fluent launcher arguments for fixtures which are not "3ddp" -# TODO: Use a decorator -launcher_args_by_fixture = { - "new_meshing_session": "3ddp -meshing", - "new_pure_meshing_session": "3ddp -meshing", - "watertight_workflow_session": "3ddp -meshing", - "fault_tolerant_workflow_session": "3ddp -meshing", - "mixing_elbow_watertight_pure_meshing_session": "3ddp -meshing", - "new_solver_session": "3ddp", - "new_solver_session_sp": "3d", - "new_solver_session_2d": "2ddp", - "static_mixer_settings_session": "3ddp", - "static_mixer_case_session": "3ddp", - "mixing_elbow_settings_session": "3ddp", - "mixing_elbow_case_data_session": "3ddp", - "mixing_elbow_param_case_data_session": "3ddp", - "disk_settings_session": "2ddp", - "disk_case_session": "2ddp", - "periodic_rot_settings_session": "3ddp", -} - - def pytest_collection_finish(session): if session.config.getoption("--write-fluent-journals"): import_path = Path(__file__).parent sys.path.append(str(import_path)) import fluent_fixtures + launcher_args_by_fixture = {} + for k, v in fluent_fixtures.__dict__.items(): + if hasattr(v, "fluent_launcher_args"): + launcher_args_by_fixture[k] = v.fluent_launcher_args fluent_test_root = import_path / "fluent" shutil.rmtree(fluent_test_root, ignore_errors=True) for item in session.items: diff --git a/tests/fluent_fixtures.py b/tests/fluent_fixtures.py index 70dd66d00b1..2798a59eb9d 100644 --- a/tests/fluent_fixtures.py +++ b/tests/fluent_fixtures.py @@ -1,3 +1,5 @@ +from typing import Callable + import pytest import ansys.fluent.core as pyfluent @@ -5,6 +7,17 @@ from ansys.fluent.core.examples import download_file +def fluent_launcher_args(args: str): + def fluent_launcher_args_inner(f: Callable): + def wrapper(*args, **kwargs): + return f(*args, **kwargs) + + wrapper.fluent_launcher_args = args + return wrapper + + return fluent_launcher_args_inner + + def mixing_elbow_geometry_filename(globals): return download_file( file_name="mixing_elbow.pmdb", directory="pyfluent/mixing_elbow" @@ -17,27 +30,32 @@ def exhaust_system_geometry_filename(globals): ) +@fluent_launcher_args("3ddp -meshing") def new_meshing_session(globals): meshing = globals["meshing"] return meshing +@fluent_launcher_args("3ddp -meshing") def new_pure_meshing_session(globals): return new_meshing_session(globals) +@fluent_launcher_args("3ddp -meshing") def watertight_workflow_session(globals): meshing = new_meshing_session(globals) meshing.workflow.InitializeWorkflow(WorkflowType="Watertight Geometry") return meshing +@fluent_launcher_args("3ddp -meshing") def fault_tolerant_workflow_session(globals): meshing = new_meshing_session(globals) meshing.workflow.InitializeWorkflow(WorkflowType="Fault-tolerant Meshing") return meshing +@fluent_launcher_args("3ddp -meshing") def mixing_elbow_watertight_pure_meshing_session(globals): meshing = new_pure_meshing_session(globals) geometry_filename = mixing_elbow_geometry_filename(globals) @@ -48,19 +66,23 @@ def mixing_elbow_watertight_pure_meshing_session(globals): return meshing +@fluent_launcher_args("3ddp") def new_solver_session(globals): solver = globals["solver"] return solver +@fluent_launcher_args("3d") def new_solver_session_sp(globals): return new_solver_session(globals) +@fluent_launcher_args("2ddp") def new_solver_session_2d(globals): return new_solver_session(globals) +@fluent_launcher_args("3ddp") def static_mixer_settings_session(globals): solver = new_solver_session(globals) case_name = download_file("Static_Mixer_main.cas.h5", "pyfluent/static_mixer") @@ -72,6 +94,7 @@ def static_mixer_settings_session(globals): return solver +@fluent_launcher_args("3ddp") def static_mixer_case_session(globals): solver = new_solver_session(globals) case_name = download_file("Static_Mixer_main.cas.h5", "pyfluent/static_mixer") @@ -79,6 +102,7 @@ def static_mixer_case_session(globals): return solver +@fluent_launcher_args("3ddp") def mixing_elbow_settings_session(globals): solver = new_solver_session(globals) case_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow") @@ -90,6 +114,7 @@ def mixing_elbow_settings_session(globals): return solver +@fluent_launcher_args("3ddp") def mixing_elbow_case_data_session(globals): solver = new_solver_session(globals) case_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow") @@ -98,6 +123,7 @@ def mixing_elbow_case_data_session(globals): return solver +@fluent_launcher_args("3ddp") def mixing_elbow_param_case_data_session(globals): solver = new_solver_session(globals) case_name = download_file("elbow_param.cas.h5", "pyfluent/mixing_elbow") @@ -106,6 +132,7 @@ def mixing_elbow_param_case_data_session(globals): return solver +@fluent_launcher_args("2ddp") def disk_settings_session(globals): solver = new_solver_session_2d(globals) case_name = download_file("disk.cas.h5", "pyfluent/rotating_disk") @@ -117,6 +144,7 @@ def disk_settings_session(globals): return solver +@fluent_launcher_args("2ddp") def disk_case_session(globals): solver = new_solver_session_2d(globals) case_name = download_file("disk.cas.h5", "pyfluent/rotating_disk") @@ -124,6 +152,7 @@ def disk_case_session(globals): return solver +@fluent_launcher_args("3ddp") def periodic_rot_settings_session(globals): solver = new_solver_session(globals) case_name = download_file(