From dc93deef03214ff459c03794c41e22e1e9d78b0b Mon Sep 17 00:00:00 2001 From: Brian Ok Date: Tue, 19 Nov 2024 15:31:41 -0500 Subject: [PATCH] fix some merges --- toolchain/mfc/build.py | 15 ++++++--------- toolchain/mfc/test/case.py | 6 +++--- toolchain/mfc/test/cases.py | 7 +++---- toolchain/mfc/test/test.py | 3 +++ 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/toolchain/mfc/build.py b/toolchain/mfc/build.py index ed3273ab0..901cc94b6 100644 --- a/toolchain/mfc/build.py +++ b/toolchain/mfc/build.py @@ -1,6 +1,5 @@ import os, typing, hashlib, dataclasses -from .case import Case from .printer import cons from .common import MFCException, system, delete_directory, create_directory, \ format_list_to_string @@ -22,7 +21,7 @@ def compute(self) -> typing.Set: return r name: str # Name of the target - flags: typing.List[str] # Extra flags to pass to CMake + flags: typing.List[str] # Extra flags to pass to CMakeMFCTarget isDependency: bool # Is it a dependency of an MFC target? isDefault: bool # Should it be built by default? (unspecified -t | --targets) isRequired: bool # Should it always be built? (no matter what -t | --targets is) @@ -32,7 +31,7 @@ def compute(self) -> typing.Set: def __hash__(self) -> int: return hash(self.name) - def get_slug(self, case: Case) -> str: + def get_slug(self, case: input.MFCInputFile) -> str: if self.isDependency: return self.name @@ -47,7 +46,7 @@ def get_slug(self, case: Case) -> str: return m.hexdigest()[:10] # Get path to directory that will store the build files - def get_staging_dirpath(self, case: Case) -> str: + def get_staging_dirpath(self, case: input.MFCInputFile) -> str: return os.sep.join([os.getcwd(), "build", "staging", self.get_slug(case) ]) # Get the directory that contains the target's CMakeLists.txt @@ -64,18 +63,18 @@ def get_install_dirpath(self, case: input.MFCInputFile) -> str: # The install directory is located /build/install/ return os.sep.join([os.getcwd(), "build", "install", self.get_slug(case)]) - def get_install_binpath(self, case: Case) -> str: + def get_install_binpath(self, case: input.MFCInputFile) -> str: # /install//bin/ return os.sep.join([self.get_install_dirpath(case), "bin", self.name]) - def is_configured(self, case: Case) -> bool: + def is_configured(self, case: input.MFCInputFile) -> bool: # We assume that if the CMakeCache.txt file exists, then the target is # configured. (this isn't perfect, but it's good enough for now) return os.path.isfile( os.sep.join([self.get_staging_dirpath(case), "CMakeCache.txt"]) ) - def get_configuration_txt(self, case: Case) -> typing.Optional[dict]: + def get_configuration_txt(self, case: input.MFCInputFile) -> typing.Optional[dict]: if not self.is_configured(case): return None @@ -261,8 +260,6 @@ def build(targets = None, case: input.MFCInputFile = None, history: typing.Set[s targets = [ targets ] if targets is None: targets = ARG("targets") - elif isinstance(targets, (MFCTarget, str)): - targets = [targets] targets = get_targets(list(REQUIRED_TARGETS) + targets) case = case or input.load(ARG("input"), ARG("--"), {}) diff --git a/toolchain/mfc/test/case.py b/toolchain/mfc/test/case.py index f2d9607fc..549650707 100644 --- a/toolchain/mfc/test/case.py +++ b/toolchain/mfc/test/case.py @@ -7,7 +7,6 @@ from ..run import input from ..build import MFCTarget, get_target -count = 0 Tend = 0.25 Nt = 50 mydt = 0.0005 @@ -219,7 +218,7 @@ def __str__(self) -> str: def to_input_file(self) -> input.MFCInputFile: return input.MFCInputFile( - self.get_filepath(), + os.path.basename(self.get_filepath()), self.get_dirpath(), self.get_parameters()) @@ -262,7 +261,7 @@ def get_uuid(self) -> str: return trace_to_uuid(self.trace) def to_case(self) -> TestCase: - dictionary = {} + dictionary = self.mods.copy() if self.path: dictionary.update(input.load(self.path, self.args, do_print=False).params) @@ -274,6 +273,7 @@ def to_case(self) -> TestCase: path = os.path.abspath(path) if os.path.exists(path): dictionary[key] = path + break if self.mods: dictionary.update(self.mods) diff --git a/toolchain/mfc/test/cases.py b/toolchain/mfc/test/cases.py index f6dc0af79..5d2d009ca 100644 --- a/toolchain/mfc/test/cases.py +++ b/toolchain/mfc/test/cases.py @@ -745,14 +745,13 @@ def modify_example_case(case: dict): case['t_step_save'] = 50 caseSize = case['m'] * max(case['n'], 1) * max(case['p'], 1) - if caseSize > 625: + if caseSize > 25 * 25: if case['n'] == 0 and case['p'] == 0: - case['m'] = 625 + case['m'] = 25 * 25 elif case['p'] == 0: case['m'] = 25 case['n'] = 25 - # m, n, p < 25 causes errors - elif caseSize > 15625: + elif caseSize > 25 * 25 * 25: case['m'] = 25 case['n'] = 25 case['p'] = 25 diff --git a/toolchain/mfc/test/test.py b/toolchain/mfc/test/test.py index 7defa1a49..3e32b5c51 100644 --- a/toolchain/mfc/test/test.py +++ b/toolchain/mfc/test/test.py @@ -136,6 +136,9 @@ def _handle_case(case: TestCase, devices: typing.Set[int]): start_time = time.time() tol = case.compute_tolerance() + case.delete_output() + case.create_directory() + cmd = case.run([PRE_PROCESS, SIMULATION], gpus=devices) out_filepath = os.path.join(case.get_dirpath(), "out_pre_sim.txt")