From 7c5f9996f0ba39b0e0badc7ef6398f4212cf30d9 Mon Sep 17 00:00:00 2001 From: Jesse Hines Date: Thu, 28 Aug 2025 10:05:13 -0400 Subject: [PATCH 1/3] Better test clean up Make sure that test output gets deleted after tests --- tests/conftest.py | 23 ++++++++++++++++--- tests/systems/test_engine.py | 5 +--- tests/systems/test_main_basic_run.py | 14 ++--------- tests/systems/test_main_cooling_run.py | 14 ++--------- .../test_main_cooling_uncertainty_run.py | 14 ++--------- tests/systems/test_main_fastforward_run.py | 14 ++--------- tests/systems/test_main_help.py | 6 +---- tests/systems/test_main_network_run.py | 14 ++--------- .../systems/test_main_network_withdata_run.py | 14 ++--------- tests/systems/test_main_noui_run.py | 14 ++--------- tests/systems/test_main_time_delta_run.py | 14 ++--------- .../test_main_time_delta_sub_second_run.py | 6 ++--- tests/systems/test_main_time_ff_delta_run.py | 14 ++--------- tests/systems/test_main_time_run.py | 14 ++--------- tests/systems/test_main_uncertainty_run.py | 14 ++--------- tests/systems/test_main_withdata_run.py | 14 ++--------- .../test_multi_part_sim_network_run.py | 11 ++------- tests/systems/test_telemetry_withdata_run.py | 14 ++--------- 18 files changed, 53 insertions(+), 180 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 477588a..855f969 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,9 @@ import pytest import uuid +import shutil +from glob import glob +from pathlib import Path +import gc def pytest_addoption(parser): @@ -15,6 +19,19 @@ def pytest_runtest_setup(item): pytest.skip(reason) -@pytest.fixture -def random_id(): - return f"test-{str(uuid.uuid4())[:8]}" +@pytest.fixture() +def sim_output(): + """ + Handles cleaning up output from the sim. + Can also be used even if you aren't outputing anything to run garbage collection after the sim. + """ + out = f"test-output/test-{str(uuid.uuid4())[:8]}" + yield out + for file in glob(f"{out}*"): + if Path(file).is_dir(): + shutil.rmtree(file) + else: + Path(file).unlink() + + # Also force a garbage collection to clean up memory after running a simulation + gc.collect() diff --git a/tests/systems/test_engine.py b/tests/systems/test_engine.py index 974ed2e..ce40878 100644 --- a/tests/systems/test_engine.py +++ b/tests/systems/test_engine.py @@ -1,4 +1,3 @@ -import gc import pytest from raps.engine import Engine from raps.sim_config import SimConfig @@ -15,7 +14,7 @@ pytestmark = [ ] -def test_engine(system, system_config): +def test_engine(system, system_config, sim_output): if not system_config.get("main", False): pytest.skip(f"{system} does not support basic main run.") @@ -35,5 +34,3 @@ def test_engine(system, system_config): assert engine_stats['time simulated'] == '0:02:00' # TODO: More specific tests of values - - gc.collect() diff --git a/tests/systems/test_main_basic_run.py b/tests/systems/test_main_basic_run.py index c420b59..0cc9b69 100644 --- a/tests/systems/test_main_basic_run.py +++ b/tests/systems/test_main_basic_run.py @@ -1,6 +1,5 @@ import os import subprocess -import gc import pytest from tests.util import PROJECT_ROOT @@ -11,7 +10,7 @@ pytestmark = [ ] -def test_main_basic_run(system, system_config, random_id): +def test_main_basic_run(system, system_config, sim_output): if not system_config.get("main", False): pytest.skip(f"{system} does not support basic main run.") @@ -20,15 +19,6 @@ def test_main_basic_run(system, system_config, random_id): "python", "main.py", "run", "--time", "1m", "--system", system, - "-o", random_id + "-o", sim_output ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" - - subprocess.run( - f"rm {random_id}.npz && rm -fr simulation_results/{random_id}", - shell=True, - check=True - ) - - del result - gc.collect() diff --git a/tests/systems/test_main_cooling_run.py b/tests/systems/test_main_cooling_run.py index 62d8621..da0c3a3 100644 --- a/tests/systems/test_main_cooling_run.py +++ b/tests/systems/test_main_cooling_run.py @@ -1,6 +1,5 @@ import os import subprocess -import gc import pytest from tests.util import PROJECT_ROOT @@ -12,7 +11,7 @@ pytestmark = [ ] -def test_main_cooling_run(system, system_config, random_id): +def test_main_cooling_run(system, system_config, sim_output): if not system_config.get("cooling", False): pytest.skip(f"{system} does not support cooling.") @@ -23,15 +22,6 @@ def test_main_cooling_run(system, system_config, random_id): "--system", system, "-c", "--noui", - "-o", random_id + "-o", sim_output ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" - - subprocess.run( - f"rm {random_id}.npz && rm -fr simulation_results/{random_id}", - shell=True, - check=True - ) - - del result - gc.collect() diff --git a/tests/systems/test_main_cooling_uncertainty_run.py b/tests/systems/test_main_cooling_uncertainty_run.py index 742fe87..472771d 100644 --- a/tests/systems/test_main_cooling_uncertainty_run.py +++ b/tests/systems/test_main_cooling_uncertainty_run.py @@ -1,6 +1,5 @@ import os import subprocess -import gc import pytest from tests.util import PROJECT_ROOT @@ -12,7 +11,7 @@ pytestmark = [ ] -def test_main_cooling_uncertainty_run(request, system, system_config, random_id): +def test_main_cooling_uncertainty_run(request, system, system_config, sim_output): print(f"Markexpr: {request.config.option.markexpr}") if not system_config.get("uncertainty", False) or not system_config.get("cooling", False): pytest.skip(f"{system} does not support cooling or uncertainty.") @@ -25,15 +24,6 @@ def test_main_cooling_uncertainty_run(request, system, system_config, random_id) "-c", "-u", "--noui", - "-o", random_id + "-o", sim_output ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" - - subprocess.run( - f"rm {random_id}.npz && rm -fr simulation_results/{random_id}", - shell=True, - check=True - ) - - del result - gc.collect() diff --git a/tests/systems/test_main_fastforward_run.py b/tests/systems/test_main_fastforward_run.py index 3eb567c..ab19b24 100644 --- a/tests/systems/test_main_fastforward_run.py +++ b/tests/systems/test_main_fastforward_run.py @@ -1,6 +1,5 @@ import os import subprocess -import gc import pytest from tests.util import PROJECT_ROOT @@ -18,7 +17,7 @@ pytestmark = [ "0m", "1m", "60m", "0h", "1h", "6h", ]) -def test_main_fastforward_run(system, system_config, ff_arg, random_id): +def test_main_fastforward_run(system, system_config, ff_arg, sim_output): if not system_config.get("fastforward", False): pytest.skip(f"{system} does not support basic main run.") @@ -29,15 +28,6 @@ def test_main_fastforward_run(system, system_config, ff_arg, random_id): "--fastforward", ff_arg, "--system", system, "--noui", - "-o", random_id + "-o", sim_output ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" - - subprocess.run( - f"rm {random_id}.npz && rm -fr simulation_results/{random_id}", - shell=True, - check=True - ) - - del result - gc.collect() diff --git a/tests/systems/test_main_help.py b/tests/systems/test_main_help.py index a651a38..97fabef 100644 --- a/tests/systems/test_main_help.py +++ b/tests/systems/test_main_help.py @@ -1,6 +1,5 @@ import os import subprocess -import gc import pytest from tests.util import PROJECT_ROOT @@ -11,7 +10,7 @@ pytestmark = [ ] -def test_main_help(system, system_config, random_id): +def test_main_help(system, system_config): if not system_config.get("main", False): pytest.skip(f"{system} does not support basic main run.") @@ -23,6 +22,3 @@ def test_main_help(system, system_config, random_id): assert result.returncode == 0, f"Failed on {system}: {result.stderr}" assert "usage:" in result.stdout - - del result - gc.collect() diff --git a/tests/systems/test_main_network_run.py b/tests/systems/test_main_network_run.py index 8c7db1e..ea693b4 100644 --- a/tests/systems/test_main_network_run.py +++ b/tests/systems/test_main_network_run.py @@ -1,6 +1,5 @@ import os import subprocess -import gc import pytest from tests.util import PROJECT_ROOT @@ -12,7 +11,7 @@ pytestmark = [ ] -def test_main_network_run(system, system_config, random_id): +def test_main_network_run(system, system_config, sim_output): if not system_config.get("main", False): pytest.skip(f"{system} does not support basic main run.") @@ -25,15 +24,6 @@ def test_main_network_run(system, system_config, random_id): "--time", "1m", "--system", system, "--net", - "-o", random_id + "-o", sim_output ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" - - subprocess.run( - f"rm {random_id}.npz && rm -fr simulation_results/{random_id}", - shell=True, - check=True - ) - - del result - gc.collect() diff --git a/tests/systems/test_main_network_withdata_run.py b/tests/systems/test_main_network_withdata_run.py index 1dcfee0..a4a8b4f 100644 --- a/tests/systems/test_main_network_withdata_run.py +++ b/tests/systems/test_main_network_withdata_run.py @@ -1,6 +1,5 @@ import os import subprocess -import gc import pytest from tests.util import PROJECT_ROOT, DATA_PATH @@ -14,7 +13,7 @@ pytestmark = [ ] -def test_main_network_withdata_run(system, system_config, system_file, random_id): +def test_main_network_withdata_run(system, system_config, system_file, sim_output): if not system_config.get("net", False): pytest.skip(f"{system} does not support basic net run.") @@ -33,15 +32,6 @@ def test_main_network_withdata_run(system, system_config, system_file, random_id "--system", system, "-f", *file_list, "--net", - "-o", random_id + "-o", sim_output ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" - - subprocess.run( - f"rm {random_id}.npz && rm -fr simulation_results/{random_id}", - shell=True, - check=True - ) - - del result - gc.collect() diff --git a/tests/systems/test_main_noui_run.py b/tests/systems/test_main_noui_run.py index af8bea8..08e7189 100644 --- a/tests/systems/test_main_noui_run.py +++ b/tests/systems/test_main_noui_run.py @@ -1,6 +1,5 @@ import os import subprocess -import gc import pytest from tests.util import PROJECT_ROOT @@ -11,7 +10,7 @@ pytestmark = [ ] -def test_main_noui_run(system, system_config, random_id): +def test_main_noui_run(system, system_config, sim_output): if not system_config.get("main", False): pytest.skip(f"{system} does not support basic main run.") @@ -21,15 +20,6 @@ def test_main_noui_run(system, system_config, random_id): "--time", "1m", "--system", system, "--noui", - "-o", random_id + "-o", sim_output ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" - - subprocess.run( - f"rm {random_id}.npz && rm -fr simulation_results/{random_id}", - shell=True, - check=True - ) - - del result - gc.collect() diff --git a/tests/systems/test_main_time_delta_run.py b/tests/systems/test_main_time_delta_run.py index 8808052..2ca8477 100644 --- a/tests/systems/test_main_time_delta_run.py +++ b/tests/systems/test_main_time_delta_run.py @@ -1,6 +1,5 @@ import os import subprocess -import gc import pytest from tests.util import PROJECT_ROOT from raps.utils import convert_to_time_unit, convert_seconds_to_hhmmss @@ -22,7 +21,7 @@ pytestmark = [ ("10h", "3h"), ("3d", "1d") ], ids=["1", "1s", "10s", "1m", "1h", "3h", "1d"]) -def test_main_time_delta_run(system, system_config, time_arg, tdelta_arg, random_id): +def test_main_time_delta_run(system, system_config, time_arg, tdelta_arg, sim_output): if not system_config.get("time_delta", False): pytest.skip(f"{system} does not support time_delta run.") @@ -33,17 +32,8 @@ def test_main_time_delta_run(system, system_config, time_arg, tdelta_arg, random "--time-delta", tdelta_arg, "--system", system, "--noui", - "-o", random_id + "-o", sim_output ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" time = convert_to_time_unit(time_arg) assert f"Time Simulated: {convert_seconds_to_hhmmss(time)}" in result.stdout - - subprocess.run( - f"rm {random_id}.npz && rm -fr simulation_results/{random_id}", - shell=True, - check=True - ) - - del result - gc.collect() diff --git a/tests/systems/test_main_time_delta_sub_second_run.py b/tests/systems/test_main_time_delta_sub_second_run.py index 0bedee8..55c0e3c 100644 --- a/tests/systems/test_main_time_delta_sub_second_run.py +++ b/tests/systems/test_main_time_delta_sub_second_run.py @@ -23,7 +23,7 @@ pytestmark = [ ("100ms", "1ms"), ("100ms", "1s"), ], ids=["1ds", "3ds", "1cs", "1ms", "1cs-for-10ds", "1ms-for-10cs", "1ms-for-100ms", "1s-for-100ms"]) -def test_main_time_delta_sub_second_run(system, system_config, time_arg, tdelta_arg, random_id): +def test_main_time_delta_sub_second_run(system, system_config, time_arg, tdelta_arg, sim_output): if not system_config.get("time_delta", False): pytest.skip(f"{system} does not support time_delta run.") @@ -34,14 +34,14 @@ def test_main_time_delta_sub_second_run(system, system_config, time_arg, tdelta_ "--time-delta", tdelta_arg, "--system", system, "--noui", - "-o", random_id + "-o", sim_output ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" time = parse_td(time_arg).seconds assert f"Time Simulated: {convert_seconds_to_hhmmss(time)}" in result.stdout subprocess.run( - f"rm {random_id}.npz && rm -fr simulation_results/{random_id}", + f"rm {sim_output}.npz && rm -fr simulation_results/{sim_output}", shell=True, check=True ) diff --git a/tests/systems/test_main_time_ff_delta_run.py b/tests/systems/test_main_time_ff_delta_run.py index a6c8763..7424758 100644 --- a/tests/systems/test_main_time_ff_delta_run.py +++ b/tests/systems/test_main_time_ff_delta_run.py @@ -1,6 +1,5 @@ import os import subprocess -import gc import pytest from tests.util import PROJECT_ROOT @@ -22,7 +21,7 @@ pytestmark = [ pytest.param("3d", "1d", "1d", marks=pytest.mark.long, id="1d (long)"), ], ids=["1", "1s", "10s", "1m", "1h", "3h", "1d"]) def test_main_time_ff_delta_run(system, system_config, time_arg, tdelta_arg, - ff_arg, random_id): + ff_arg, sim_output): if not system_config.get("time_delta", False): pytest.skip(f"{system} does not support time_delta run.") @@ -34,15 +33,6 @@ def test_main_time_ff_delta_run(system, system_config, time_arg, tdelta_arg, "--time-delta", tdelta_arg, "--system", system, "--noui", - "-o", random_id + "-o", sim_output ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" - - subprocess.run( - f"rm {random_id}.npz && rm -fr simulation_results/{random_id}", - shell=True, - check=True - ) - - del result - gc.collect() diff --git a/tests/systems/test_main_time_run.py b/tests/systems/test_main_time_run.py index c8e00b1..0faa06c 100644 --- a/tests/systems/test_main_time_run.py +++ b/tests/systems/test_main_time_run.py @@ -1,6 +1,5 @@ import os import subprocess -import gc import pytest from tests.util import PROJECT_ROOT @@ -21,7 +20,7 @@ pytestmark = [ "0h", "1h", pytest.param("6h", marks=pytest.mark.long), # mark this one as long ]) -def test_main_time_run(system, system_config, time_args, random_id): +def test_main_time_run(system, system_config, time_args, sim_output): if not system_config.get("main", False): pytest.skip(f"{system} does not support basic main run.") @@ -31,15 +30,6 @@ def test_main_time_run(system, system_config, time_args, random_id): "--time", time_args, "--system", system, "--noui", - "-o", random_id + "-o", sim_output ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" - - subprocess.run( - f"rm {random_id}.npz && rm -fr simulation_results/{random_id}", - shell=True, - check=True - ) - - del result - gc.collect() diff --git a/tests/systems/test_main_uncertainty_run.py b/tests/systems/test_main_uncertainty_run.py index effdcc6..f3d5bd0 100644 --- a/tests/systems/test_main_uncertainty_run.py +++ b/tests/systems/test_main_uncertainty_run.py @@ -1,6 +1,5 @@ import os import subprocess -import gc import pytest from tests.util import PROJECT_ROOT @@ -13,7 +12,7 @@ pytestmark = [ ] -def test_main_uncertainty_run(system, system_config, random_id): +def test_main_uncertainty_run(system, system_config, sim_output): if not system_config.get("uncertainty", False): pytest.skip(f"{system} does not support uncertainty.") @@ -24,15 +23,6 @@ def test_main_uncertainty_run(system, system_config, random_id): "--system", system, "-u", "--noui", - "-o", random_id + "-o", sim_output ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" - - subprocess.run( - f"rm {random_id}.npz && rm -fr simulation_results/{random_id}", - shell=True, - check=True - ) - - del result - gc.collect() diff --git a/tests/systems/test_main_withdata_run.py b/tests/systems/test_main_withdata_run.py index a4cbd55..68d672d 100644 --- a/tests/systems/test_main_withdata_run.py +++ b/tests/systems/test_main_withdata_run.py @@ -1,6 +1,5 @@ import os import subprocess -import gc import pytest from tests.util import PROJECT_ROOT, DATA_PATH @@ -12,7 +11,7 @@ pytestmark = [ ] -def test_main_withdata_run(system, system_config, system_file, random_id): +def test_main_withdata_run(system, system_config, system_file, sim_output): if not system_config.get("main", False): pytest.skip(f"{system} does not support basic main even without data.") if not system_config.get("withdata", False): @@ -30,15 +29,6 @@ def test_main_withdata_run(system, system_config, system_file, random_id): "--time", "1m", "--system", system, "-f", ','.join(str(p) for p in file_list), - "-o", random_id + "-o", sim_output ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" - - subprocess.run( - f"rm {random_id}.npz && rm -fr simulation_results/{random_id}", - shell=True, - check=True - ) - - del result - gc.collect() diff --git a/tests/systems/test_multi_part_sim_network_run.py b/tests/systems/test_multi_part_sim_network_run.py index ccbadaa..aa90cca 100644 --- a/tests/systems/test_multi_part_sim_network_run.py +++ b/tests/systems/test_multi_part_sim_network_run.py @@ -1,6 +1,5 @@ import os import subprocess -import gc import pytest from tests.util import PROJECT_ROOT @@ -11,8 +10,7 @@ pytestmark = [ ] -def test_multi_part_sim_network_run(system, system_config, random_id): - +def test_multi_part_sim_network_run(system, system_config, sim_output): if not system_config.get("multi-part-sim", False): pytest.skip(f"{system} does not support basic multi-part-sim run.") @@ -25,11 +23,6 @@ def test_multi_part_sim_network_run(system, system_config, random_id): "--time", "1h", "-x", f"{system}/*", "--net", + "-o", sim_output, ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" - - # TODO: - # Cleanup files after test! - - del result - gc.collect() diff --git a/tests/systems/test_telemetry_withdata_run.py b/tests/systems/test_telemetry_withdata_run.py index e9685f7..eef5adf 100644 --- a/tests/systems/test_telemetry_withdata_run.py +++ b/tests/systems/test_telemetry_withdata_run.py @@ -1,6 +1,5 @@ import os import subprocess -import gc import pytest from tests.util import PROJECT_ROOT, DATA_PATH @@ -11,7 +10,7 @@ pytestmark = [ ] -def test_telemetry_main_withdata_run(system, system_config, system_file, random_id): +def test_telemetry_main_withdata_run(system, system_config, system_file, sim_output): if not system_config.get("telemetry", False): pytest.skip(f"{system} does not support telemetry run.") if not system_config.get("withdata", False): @@ -29,15 +28,6 @@ def test_telemetry_main_withdata_run(system, system_config, system_file, random_ "python", "main.py", "telemetry", "--system", system, "-f", *file_list, - "-o", random_id + "-o", sim_output, ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" - - subprocess.run( - f"rm {random_id}.npz ; rm {random_id}.png", - shell=True, - check=True - ) - - del result - gc.collect() -- GitLab From 5c931588e93da1d1de4044442cb79068c64579aa Mon Sep 17 00:00:00 2001 From: Jesse Hines Date: Thu, 28 Aug 2025 10:14:23 -0400 Subject: [PATCH 2/3] Allow passing cli_args explicitly --- main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index cd7e162..737cc8d 100644 --- a/main.py +++ b/main.py @@ -31,7 +31,7 @@ CLI_CONFIG = SettingsConfigDict( ) -def main(): +def main(cli_args: list[str] | None = None): parser = argparse.ArgumentParser( description=""" ExaDigiT Resource Allocator & Power Simulator (RAPS) @@ -153,7 +153,7 @@ def main(): # TODO: move telemetry and other misc scripts into here - args = parser.parse_args() + args = parser.parse_args(cli_args) args.func(args) -- GitLab From 20bf758bae6a621ac7f9b8be400a4c9e6ee04ae4 Mon Sep 17 00:00:00 2001 From: Jesse Hines Date: Thu, 28 Aug 2025 15:14:29 -0400 Subject: [PATCH 3/3] Refactor system_files fixture --- tests/systems/conftest.py | 27 ++++++++++++------- .../systems/test_main_network_withdata_run.py | 12 ++------- tests/systems/test_main_withdata_run.py | 11 ++------ .../test_multi_part_sim_withdata_run.py | 13 ++------- tests/systems/test_telemetry_withdata_run.py | 11 ++------ 5 files changed, 25 insertions(+), 49 deletions(-) diff --git a/tests/systems/conftest.py b/tests/systems/conftest.py index 8e361e9..269d101 100644 --- a/tests/systems/conftest.py +++ b/tests/systems/conftest.py @@ -1,4 +1,5 @@ import pytest +from tests.util import DATA_PATH @pytest.fixture(params=[ @@ -180,18 +181,24 @@ def system_config(system): @pytest.fixture -def system_file(system): +def system_files(system): files = { "40frontiers": [], - "adastraMI250": ["AdastaJobsMI250_15days.parquet"], - "frontier": ["slurm/joblive/date=2024-01-18/", "jobprofile/date=2024-01-18/"], - "fugaku": ["21_04.parquet"], - "gcloudv2": ["/v2/google_cluster_data_2011_sample"], - "lassen": ["Lassen-Supercomputer-Job-Dataset"], - "marconi100": ["job_table.parquet"], - "mit_supercloud": ["202201"], - "setonix": [""], + "adastraMI250": ["adastraMI250/AdastaJobsMI250_15days.parquet"], + "frontier": ["frontier/slurm/joblive/date=2024-01-18/", "frontier/jobprofile/date=2024-01-18/"], + "fugaku": ["fugaku/21_04.parquet"], + "gcloudv2": ["gcloud/v2/google_cluster_data_2011_sample"], + "lassen": ["lassen/Lassen-Supercomputer-Job-Dataset"], + "marconi100": ["marconi100/job_table.parquet"], + "mit_supercloud": ["mit_supercloud/202201"], + "setonix": [], "summit": [], "lumi": [] } - return files.get(system, files) + + file_list = [DATA_PATH / f for f in files.get(system, [])] + for file in file_list: + assert file.exists(), \ + f"File `{file}' does not exist. does ./data exist or is RAPS_DATA_DIR set?" + + return [str(f) for f in file_list] diff --git a/tests/systems/test_main_network_withdata_run.py b/tests/systems/test_main_network_withdata_run.py index a4a8b4f..62b679a 100644 --- a/tests/systems/test_main_network_withdata_run.py +++ b/tests/systems/test_main_network_withdata_run.py @@ -13,24 +13,16 @@ pytestmark = [ ] -def test_main_network_withdata_run(system, system_config, system_file, sim_output): +def test_main_network_withdata_run(system, system_config, system_files, sim_output): if not system_config.get("net", False): pytest.skip(f"{system} does not support basic net run.") - if isinstance(system_file, list): - file_list = [DATA_PATH / system / x for x in system_file] - else: - file_list = [DATA_PATH / system / system_file] - for file in file_list: - assert os.path.isfile(file) or os.path.isdir(file), \ - "File does not exist. does ./data exist or is RAPS_DATA_DIR set?" - os.chdir(PROJECT_ROOT) result = subprocess.run([ "python", "main.py", "run", "--time", "1m", "--system", system, - "-f", *file_list, + "-f", *system_files, "--net", "-o", sim_output ], capture_output=True, text=True, stdin=subprocess.DEVNULL) diff --git a/tests/systems/test_main_withdata_run.py b/tests/systems/test_main_withdata_run.py index 68d672d..eb996a3 100644 --- a/tests/systems/test_main_withdata_run.py +++ b/tests/systems/test_main_withdata_run.py @@ -11,24 +11,17 @@ pytestmark = [ ] -def test_main_withdata_run(system, system_config, system_file, sim_output): +def test_main_withdata_run(system, system_config, system_files, sim_output): if not system_config.get("main", False): pytest.skip(f"{system} does not support basic main even without data.") if not system_config.get("withdata", False): pytest.skip(f"{system} does not support basic main with data.") - if isinstance(system_file, list): - file_list = [DATA_PATH / system / x for x in system_file] - else: - file_list = [DATA_PATH / system / system_file] - for file in file_list: - assert os.path.isfile(file) or os.path.isdir(file), \ - f"File `{file}' does not exist. does ./data exist or is RAPS_DATA_DIR set?" os.chdir(PROJECT_ROOT) result = subprocess.run([ "python", "main.py", "run", "--time", "1m", "--system", system, - "-f", ','.join(str(p) for p in file_list), + "-f", ','.join(system_files), "-o", sim_output ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" diff --git a/tests/systems/test_multi_part_sim_withdata_run.py b/tests/systems/test_multi_part_sim_withdata_run.py index 2b18305..caaf9e8 100644 --- a/tests/systems/test_multi_part_sim_withdata_run.py +++ b/tests/systems/test_multi_part_sim_withdata_run.py @@ -12,26 +12,17 @@ pytestmark = [ ] -def test_multi_part_sim_withdata_run(system, system_config, system_file): +def test_multi_part_sim_withdata_run(system, system_config, system_files): if not system_config.get("multi-part-sim", False): pytest.skip(f"{system} does not support basic multi-part-sim run even without data.") if not system_config.get("withdata", False): pytest.skip(f"{system} does not support multi-part-sim run with data.") - if isinstance(system_file, list): - file_list = [DATA_PATH / system / x for x in system_file] - else: - file_list = [DATA_PATH / system / system_file] - for file in file_list: - assert os.path.isfile(file) or os.path.isdir(file), \ - f"File `{file}' does not exist. does ./data exist or is RAPS_DATA_DIR set?" os.chdir(PROJECT_ROOT) result = subprocess.run([ "python", "main.py", "run-multi-part", "--time", "1h", "-x", f"{system}/*", - "-f", *file_list, + "-f", *system_files, ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" - del result - gc.collect() diff --git a/tests/systems/test_telemetry_withdata_run.py b/tests/systems/test_telemetry_withdata_run.py index eef5adf..ab6f93c 100644 --- a/tests/systems/test_telemetry_withdata_run.py +++ b/tests/systems/test_telemetry_withdata_run.py @@ -10,24 +10,17 @@ pytestmark = [ ] -def test_telemetry_main_withdata_run(system, system_config, system_file, sim_output): +def test_telemetry_main_withdata_run(system, system_config, system_files, sim_output): if not system_config.get("telemetry", False): pytest.skip(f"{system} does not support telemetry run.") if not system_config.get("withdata", False): pytest.skip(f"{system} does not support telemetry run with data.") - if isinstance(system_file, list): - file_list = [DATA_PATH / system / x for x in system_file] - else: - file_list = [DATA_PATH / system / system_file] - for file in file_list: - assert os.path.isfile(file) or os.path.isdir(file), \ - f"File `{file}' does not exist. does ./data exist or is RAPS_DATA_DIR set?" os.chdir(PROJECT_ROOT) result = subprocess.run([ "python", "main.py", "telemetry", "--system", system, - "-f", *file_list, + "-f", *system_files, "-o", sim_output, ], capture_output=True, text=True, stdin=subprocess.DEVNULL) assert result.returncode == 0, f"Failed on {system}: {result.stderr}" -- GitLab