From 90a3e7fe0b825d6d81a94f7ba3ab0f91dded40d4 Mon Sep 17 00:00:00 2001 From: John Vouvakis Manousakis Date: Sun, 18 Aug 2024 10:20:09 -0700 Subject: [PATCH 01/10] Update codespell workflow. Update codespell workflow to use [actions-codespell](https://github.com/codespell-project/actions-codespell). --- .github/workflows/spell_check.yml | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/.github/workflows/spell_check.yml b/.github/workflows/spell_check.yml index e21f80b37..1b520e1fc 100644 --- a/.github/workflows/spell_check.yml +++ b/.github/workflows/spell_check.yml @@ -7,19 +7,6 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.10' - - - name: Install codespell - run: | - python -m pip install --upgrade pip - pip install tomli codespell - - name: Run codespell - run: | - codespell . + uses: codespell-project/actions-codespell@v2 + From 330bba5d3ca86a20b57e60815f0d986151e5d179 Mon Sep 17 00:00:00 2001 From: John Vouvakis Manousakis Date: Sun, 18 Aug 2024 10:27:58 -0700 Subject: [PATCH 02/10] Add typo Add typo to see if workflow would pick it up. --- .github/workflows/spell_check.yml | 1 - modules/performUQ/common/parallel_runner_mpi4py.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spell_check.yml b/.github/workflows/spell_check.yml index 1b520e1fc..0e920f48c 100644 --- a/.github/workflows/spell_check.yml +++ b/.github/workflows/spell_check.yml @@ -9,4 +9,3 @@ jobs: steps: - name: Run codespell uses: codespell-project/actions-codespell@v2 - diff --git a/modules/performUQ/common/parallel_runner_mpi4py.py b/modules/performUQ/common/parallel_runner_mpi4py.py index bf8de20bc..44927f722 100644 --- a/modules/performUQ/common/parallel_runner_mpi4py.py +++ b/modules/performUQ/common/parallel_runner_mpi4py.py @@ -1,6 +1,7 @@ from mpi4py import MPI # noqa: INP001, D100 from mpi4py.futures import MPIPoolExecutor +# aceleration should be acceleration class ParallelRunnerMPI4PY: # noqa: D101 def __init__(self, run_type: str = 'runningRemote') -> None: From a8396ad0d62d755857fed6691951b86b81d8bff3 Mon Sep 17 00:00:00 2001 From: John Vouvakis Manousakis Date: Sun, 18 Aug 2024 10:30:20 -0700 Subject: [PATCH 03/10] Add back `checkout` block. --- .github/workflows/spell_check.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/spell_check.yml b/.github/workflows/spell_check.yml index 0e920f48c..c894573a1 100644 --- a/.github/workflows/spell_check.yml +++ b/.github/workflows/spell_check.yml @@ -7,5 +7,9 @@ jobs: runs-on: ubuntu-latest steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Run codespell uses: codespell-project/actions-codespell@v2 + From 85ed9527a3812ceeee82c32c9e9fe7c7a2687007 Mon Sep 17 00:00:00 2001 From: John Vouvakis Manousakis Date: Sun, 18 Aug 2024 10:31:20 -0700 Subject: [PATCH 04/10] Awesome. Remove typo. Remove typo. We are done here. --- modules/performUQ/common/parallel_runner_mpi4py.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/performUQ/common/parallel_runner_mpi4py.py b/modules/performUQ/common/parallel_runner_mpi4py.py index 44927f722..64bbb4a6d 100644 --- a/modules/performUQ/common/parallel_runner_mpi4py.py +++ b/modules/performUQ/common/parallel_runner_mpi4py.py @@ -1,8 +1,6 @@ from mpi4py import MPI # noqa: INP001, D100 from mpi4py.futures import MPIPoolExecutor -# aceleration should be acceleration - class ParallelRunnerMPI4PY: # noqa: D101 def __init__(self, run_type: str = 'runningRemote') -> None: self.run_type = run_type From 0ab0129700abae5b3fdc99c1c6a51a77566f2553 Mon Sep 17 00:00:00 2001 From: jinyan1214 Date: Mon, 26 Aug 2024 14:57:45 -0700 Subject: [PATCH 05/10] jz - UX supported IM type in error message --- .../regionalGroundMotion/gmpe/openSHAGMPE.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/performRegionalEventSimulation/regionalGroundMotion/gmpe/openSHAGMPE.py b/modules/performRegionalEventSimulation/regionalGroundMotion/gmpe/openSHAGMPE.py index 3a6c527ec..a83b970f6 100644 --- a/modules/performRegionalEventSimulation/regionalGroundMotion/gmpe/openSHAGMPE.py +++ b/modules/performRegionalEventSimulation/regionalGroundMotion/gmpe/openSHAGMPE.py @@ -74,7 +74,12 @@ def __init__(self): def setIMT(self, imt): # noqa: N802, D102 if imt not in self.supportedImt: - sys.exit(f'The imt {imt} is not supported by Chiou and Young (2014)') + # supported_imt = [] + # for i in self.supportedImt: + # if i is float: + # supported_imt.append(i) + supported_imt = [f'SA{x}s' if isinstance(x, float) else x for x in self.supportedImt] + sys.exit(f'The IM type {imt} is not supported by Chiou and Young (2014). \n The supported IM types are {supported_imt}') return False self.c1 = self.coeff['c1'][imt] self.c1a = self.coeff['c1a'][imt] @@ -337,8 +342,9 @@ def __init__(self): def setIMT(self, imt): # noqa: N802, D102 if imt not in self.supportedImt: + supported_imt = [f'SA{x}s' if isinstance(x, float) else x for x in self.supportedImt] sys.exit( - f'The imt {imt} is not supported by Abrahamson, Silva, and Kamai (2014)' + f'The IM type {imt} is not supported by Abrahamson, Silva, and Kamai (2014). \n The supported IM types are {supported_imt}' ) return self.imt = imt @@ -636,8 +642,9 @@ def __init__(self): def setIMT(self, imt): # noqa: N802, D102 if imt not in self.supportedImt: + supported_imt = [f'SA{x}s' if isinstance(x, float) else x for x in self.supportedImt] sys.exit( - f'The imt {imt} is not supported by Boore, Stewart, Seyhan & Atkinson (2014)' + f'The IM type {imt} is not supported by Boore, Stewart, Seyhan & Atkinson (2014). \n The supported IM types are {supported_imt}' ) return self.imt = imt @@ -863,8 +870,9 @@ def __init__(self): def setIMT(self, imt): # noqa: N802, D102 if imt not in self.supportedImt: + supported_imt = [f'SA{x}s' if isinstance(x, float) else x for x in self.supportedImt] sys.exit( - f'The imt {imt} is not supported by Campbell & Bozorgnia (2014)' + f'The IM type {imt} is not supported by Campbell & Bozorgnia (2014). \n The supported IM types are {supported_imt}' ) return self.imt = imt From fd65b973d3d00ef2290f41113f5dbccb0bbafe4a Mon Sep 17 00:00:00 2001 From: jinyan1214 Date: Mon, 26 Aug 2024 16:04:15 -0700 Subject: [PATCH 06/10] ruff format and ruff check --- modules/Workflow/createResponseCSV.py | 14 ++++++------- .../regionalGroundMotion/gmpe/openSHAGMPE.py | 20 ++++++++++++++----- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/modules/Workflow/createResponseCSV.py b/modules/Workflow/createResponseCSV.py index e553398c3..557b14c80 100644 --- a/modules/Workflow/createResponseCSV.py +++ b/modules/Workflow/createResponseCSV.py @@ -1,4 +1,4 @@ -# noqa: D100 +# noqa: D100, INP001 # # Code to write response.csv file given input and dakotaTab.out files @@ -14,9 +14,9 @@ import numpy as np import pandas as pd -def main(input_file, dakota_tab_file): # noqa: D103 - directory_inputs = os.path.dirname(input_file) # noqa: PTH120 +def main(input_file, dakota_tab_file): # noqa: D103 + directory_inputs = os.path.dirname(input_file) # noqa: PTH120 os.chdir(directory_inputs) try: @@ -26,11 +26,11 @@ def main(input_file, dakota_tab_file): # noqa: D103 except FileNotFoundError: # Handle the error if the file is not found - print(f"Error createResponseCSV.py: The file '{input_file}' was not found.") # noqa: T201 + print(f"Error createResponseCSV.py: The file '{input_file}' was not found.") # noqa: T201 return except OSError: # Handle other I/O errors - print(f"Error createResponseCSV.py: Error reading the file '{input_file}'.") # noqa: T201 + print(f"Error createResponseCSV.py: Error reading the file '{input_file}'.") # noqa: T201 return app_data = data.get('Applications', None) @@ -59,12 +59,12 @@ def main(input_file, dakota_tab_file): # noqa: D103 except FileNotFoundError: # Handle the error if the file is not found - print(f"Error createResponseCSV.py: The file '{dakota_tab_file}' not found.") # noqa: T201 + print(f"Error createResponseCSV.py: The file '{dakota_tab_file}' not found.") # noqa: T201 return except OSError: # Handle other I/O errors - print(f"Error createResponseCSV.py: Error reading '{dakota_tab_file}'.") # noqa: T201 + print(f"Error createResponseCSV.py: Error reading '{dakota_tab_file}'.") # noqa: T201 return diff --git a/modules/performRegionalEventSimulation/regionalGroundMotion/gmpe/openSHAGMPE.py b/modules/performRegionalEventSimulation/regionalGroundMotion/gmpe/openSHAGMPE.py index a83b970f6..69213803e 100644 --- a/modules/performRegionalEventSimulation/regionalGroundMotion/gmpe/openSHAGMPE.py +++ b/modules/performRegionalEventSimulation/regionalGroundMotion/gmpe/openSHAGMPE.py @@ -78,8 +78,12 @@ def setIMT(self, imt): # noqa: N802, D102 # for i in self.supportedImt: # if i is float: # supported_imt.append(i) - supported_imt = [f'SA{x}s' if isinstance(x, float) else x for x in self.supportedImt] - sys.exit(f'The IM type {imt} is not supported by Chiou and Young (2014). \n The supported IM types are {supported_imt}') + supported_imt = [ + f'SA{x}s' if isinstance(x, float) else x for x in self.supportedImt + ] + sys.exit( + f'The IM type {imt} is not supported by Chiou and Young (2014). \n The supported IM types are {supported_imt}' + ) return False self.c1 = self.coeff['c1'][imt] self.c1a = self.coeff['c1a'][imt] @@ -342,7 +346,9 @@ def __init__(self): def setIMT(self, imt): # noqa: N802, D102 if imt not in self.supportedImt: - supported_imt = [f'SA{x}s' if isinstance(x, float) else x for x in self.supportedImt] + supported_imt = [ + f'SA{x}s' if isinstance(x, float) else x for x in self.supportedImt + ] sys.exit( f'The IM type {imt} is not supported by Abrahamson, Silva, and Kamai (2014). \n The supported IM types are {supported_imt}' ) @@ -642,7 +648,9 @@ def __init__(self): def setIMT(self, imt): # noqa: N802, D102 if imt not in self.supportedImt: - supported_imt = [f'SA{x}s' if isinstance(x, float) else x for x in self.supportedImt] + supported_imt = [ + f'SA{x}s' if isinstance(x, float) else x for x in self.supportedImt + ] sys.exit( f'The IM type {imt} is not supported by Boore, Stewart, Seyhan & Atkinson (2014). \n The supported IM types are {supported_imt}' ) @@ -870,7 +878,9 @@ def __init__(self): def setIMT(self, imt): # noqa: N802, D102 if imt not in self.supportedImt: - supported_imt = [f'SA{x}s' if isinstance(x, float) else x for x in self.supportedImt] + supported_imt = [ + f'SA{x}s' if isinstance(x, float) else x for x in self.supportedImt + ] sys.exit( f'The IM type {imt} is not supported by Campbell & Bozorgnia (2014). \n The supported IM types are {supported_imt}' ) From 6f461e904668a3d4d05f326a0e86b4d3ce4afb76 Mon Sep 17 00:00:00 2001 From: jinyan1214 Date: Tue, 27 Aug 2024 17:38:06 -0700 Subject: [PATCH 07/10] jz - add some tabs for easier reading --- .../multiplePEER/MultiplePEER_Events.cpp | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/modules/createEVENT/multiplePEER/MultiplePEER_Events.cpp b/modules/createEVENT/multiplePEER/MultiplePEER_Events.cpp index fbe69c22a..e311ebab4 100644 --- a/modules/createEVENT/multiplePEER/MultiplePEER_Events.cpp +++ b/modules/createEVENT/multiplePEER/MultiplePEER_Events.cpp @@ -88,52 +88,52 @@ int main(int argc, char **argv) if (strcmp(eventType,"ExistingPEER_Events") != 0) { - json_array_append(newEventArray, value); // copy event for next event app to parse + json_array_append(newEventArray, value); // copy event for next event app to parse } else { - json_t *eventObj = json_object(); - json_object_set(eventObj,"type", json_string("Seismic")); - json_object_set(eventObj,"subtype", json_string("MultiplePEER_Event")); - - json_t *existingEventsArray = json_object_get(value,"Events"); - int numExisting = json_array_size(existingEventsArray); - - if (numExisting > 1) { - - json_t *randomVar = json_object(); - json_object_set(randomVar, "distribution",json_string("discrete_design_set_string")); - json_object_set(randomVar, "name",json_string("MultipleEvent")); - json_object_set(randomVar, "value",json_string("RV.MultipleEvent")); - json_t *theMultipleEvents = json_array(); - - json_t *existingEvent = 0; - json_array_foreach(existingEventsArray, index, existingEvent) { - createSimCenterEvent(existingEvent); - json_array_append(theMultipleEvents, json_object_get(existingEvent,"name")); - } - - json_object_set(randomVar, "elements", theMultipleEvents); - json_array_append(rvArray, randomVar); - json_object_set(eventObj, "index", json_string("RV.MultipleEvent")); - - } else { - - json_t *existingEvent = json_array_get(existingEventsArray,0); - createSimCenterEvent(existingEvent); - json_object_set(eventObj, "index", json_integer(0)); - - } - - //add first event to event - json_t *firstEvent = json_array_get(existingEventsArray, 0); - json_t *fileValue = json_object_get(firstEvent, "name"); - if (fileValue != NULL) { - const char *fileName = json_string_value(fileValue); - addEvent(fileName, eventObj); - } - - json_array_append(newEventArray, eventObj); + json_t *eventObj = json_object(); + json_object_set(eventObj,"type", json_string("Seismic")); + json_object_set(eventObj,"subtype", json_string("MultiplePEER_Event")); + + json_t *existingEventsArray = json_object_get(value,"Events"); + int numExisting = json_array_size(existingEventsArray); + + if (numExisting > 1) { + + json_t *randomVar = json_object(); + json_object_set(randomVar, "distribution",json_string("discrete_design_set_string")); + json_object_set(randomVar, "name",json_string("MultipleEvent")); + json_object_set(randomVar, "value",json_string("RV.MultipleEvent")); + json_t *theMultipleEvents = json_array(); + + json_t *existingEvent = 0; + json_array_foreach(existingEventsArray, index, existingEvent) { + createSimCenterEvent(existingEvent); + json_array_append(theMultipleEvents, json_object_get(existingEvent,"name")); + } + + json_object_set(randomVar, "elements", theMultipleEvents); + json_array_append(rvArray, randomVar); + json_object_set(eventObj, "index", json_string("RV.MultipleEvent")); + + } else { + + json_t *existingEvent = json_array_get(existingEventsArray,0); + createSimCenterEvent(existingEvent); + json_object_set(eventObj, "index", json_integer(0)); + + } + + //add first event to event + json_t *firstEvent = json_array_get(existingEventsArray, 0); + json_t *fileValue = json_object_get(firstEvent, "name"); + if (fileValue != NULL) { + const char *fileName = json_string_value(fileValue); + addEvent(fileName, eventObj); + } + + json_array_append(newEventArray, eventObj); } } From 8ae17d429e081a46e7e302d1958d5e5541404768 Mon Sep 17 00:00:00 2001 From: John Vouvakis Manousakis Date: Wed, 28 Aug 2024 05:05:09 -0700 Subject: [PATCH 08/10] Pin Ruff version to 0.6.1 We'll need to keep an eye on Ruff releases and manually update the version when we deem it appropriate. --- .github/workflows/format_check.yml | 1 + .github/workflows/lint.yml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/format_check.yml b/.github/workflows/format_check.yml index dca19a00f..f779ab252 100644 --- a/.github/workflows/format_check.yml +++ b/.github/workflows/format_check.yml @@ -8,3 +8,4 @@ jobs: - uses: chartboost/ruff-action@v1 with: args: 'format --check' + version: 0.6.1 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 744b4e642..be42eccfe 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -6,3 +6,5 @@ jobs: steps: - uses: actions/checkout@v4 - uses: chartboost/ruff-action@v1 + with: + version: 0.6.1 From 62cf6be3ba95911504c69b73ef99aab11697ffe8 Mon Sep 17 00:00:00 2001 From: John Vouvakis Manousakis Date: Wed, 28 Aug 2024 05:08:16 -0700 Subject: [PATCH 09/10] Format and lint --- modules/Workflow/createResponseCSV.py | 14 +++++++------- modules/performUQ/common/parallel_runner_mpi4py.py | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/Workflow/createResponseCSV.py b/modules/Workflow/createResponseCSV.py index e553398c3..557b14c80 100644 --- a/modules/Workflow/createResponseCSV.py +++ b/modules/Workflow/createResponseCSV.py @@ -1,4 +1,4 @@ -# noqa: D100 +# noqa: D100, INP001 # # Code to write response.csv file given input and dakotaTab.out files @@ -14,9 +14,9 @@ import numpy as np import pandas as pd -def main(input_file, dakota_tab_file): # noqa: D103 - directory_inputs = os.path.dirname(input_file) # noqa: PTH120 +def main(input_file, dakota_tab_file): # noqa: D103 + directory_inputs = os.path.dirname(input_file) # noqa: PTH120 os.chdir(directory_inputs) try: @@ -26,11 +26,11 @@ def main(input_file, dakota_tab_file): # noqa: D103 except FileNotFoundError: # Handle the error if the file is not found - print(f"Error createResponseCSV.py: The file '{input_file}' was not found.") # noqa: T201 + print(f"Error createResponseCSV.py: The file '{input_file}' was not found.") # noqa: T201 return except OSError: # Handle other I/O errors - print(f"Error createResponseCSV.py: Error reading the file '{input_file}'.") # noqa: T201 + print(f"Error createResponseCSV.py: Error reading the file '{input_file}'.") # noqa: T201 return app_data = data.get('Applications', None) @@ -59,12 +59,12 @@ def main(input_file, dakota_tab_file): # noqa: D103 except FileNotFoundError: # Handle the error if the file is not found - print(f"Error createResponseCSV.py: The file '{dakota_tab_file}' not found.") # noqa: T201 + print(f"Error createResponseCSV.py: The file '{dakota_tab_file}' not found.") # noqa: T201 return except OSError: # Handle other I/O errors - print(f"Error createResponseCSV.py: Error reading '{dakota_tab_file}'.") # noqa: T201 + print(f"Error createResponseCSV.py: Error reading '{dakota_tab_file}'.") # noqa: T201 return diff --git a/modules/performUQ/common/parallel_runner_mpi4py.py b/modules/performUQ/common/parallel_runner_mpi4py.py index 64bbb4a6d..bf8de20bc 100644 --- a/modules/performUQ/common/parallel_runner_mpi4py.py +++ b/modules/performUQ/common/parallel_runner_mpi4py.py @@ -1,6 +1,7 @@ from mpi4py import MPI # noqa: INP001, D100 from mpi4py.futures import MPIPoolExecutor + class ParallelRunnerMPI4PY: # noqa: D101 def __init__(self, run_type: str = 'runningRemote') -> None: self.run_type = run_type From f702763d4797508024971f40d3ce3e7cde29ae6c Mon Sep 17 00:00:00 2001 From: jinyan1214 Date: Fri, 30 Aug 2024 10:42:36 -0700 Subject: [PATCH 10/10] jz - fix the bug of hardcoding Results dir of rWHALE --- modules/Workflow/whale/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Workflow/whale/main.py b/modules/Workflow/whale/main.py index 759f8af73..86d0f26ab 100644 --- a/modules/Workflow/whale/main.py +++ b/modules/Workflow/whale/main.py @@ -2874,7 +2874,7 @@ def aggregate_results( # noqa: C901, PLR0912, PLR0915 bldg_dir = Path(os.path.dirname(asst_data[a_i]['file'])).resolve() # noqa: PTH120 main_dir = bldg_dir assetTypeHierarchy = [bldg_dir.name] # noqa: N806 - while main_dir.parent.name != 'Results': + while main_dir.parent.name != self.run_dir.name: main_dir = bldg_dir.parent assetTypeHierarchy = [main_dir.name] + assetTypeHierarchy # noqa: N806, RUF005