Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add residual demand simulation and some ruff check #345

Merged
merged 32 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d58ac73
Methods for transportation system performance & recovery simulation
bacetiner Aug 14, 2024
680814a
Merge branch 'NHERI-SimCenter:master' into brails-buildings_widget
bacetiner Aug 14, 2024
5f7097d
bc - Fixed a typo in class description
bacetiner Aug 15, 2024
466d3c1
Merge branch 'NHERI-SimCenter:master' into brails-buildings_widget
bacetiner Aug 15, 2024
f0e8e64
bc - Moved methods for recovery simulation to folder JZ created
bacetiner Aug 15, 2024
090b90e
Merge branch 'NHERI-SimCenter:master' into brails-buildings_widget
bacetiner Aug 15, 2024
e71b18c
Merge branch 'NHERI-SimCenter:master' into brails-buildings_widget
bacetiner Aug 18, 2024
b37d4fa
bc - Added system_performance method
bacetiner Aug 30, 2024
fa12283
bc - Cleaned up the code for better PEP compatibility
bacetiner Aug 30, 2024
c8b9140
Replace "|" with typing.Union to fit python 3.9
jinyan1214 Sep 16, 2024
2b75f7c
comment out @abstractmethod and fix path.open bug
jinyan1214 Sep 16, 2024
0964549
fix initial-state file name definiatio error (extra dot may exist in …
jinyan1214 Sep 16, 2024
33e7390
fix file path and input format to files_exist()
jinyan1214 Sep 16, 2024
115b9fd
try to move get_grapth_network from brails to performREC/transportati…
jinyan1214 Sep 20, 2024
5529b0d
performREC version 1
jinyan1214 Sep 21, 2024
b5ccdcf
Merge remote-tracking branch 'upstream/master' into barbaros_transport
jinyan1214 Oct 11, 2024
2794386
Merge remote-tracking branch 'upstream/master' into barbaros_transport
jinyan1214 Oct 14, 2024
d364101
run residual demand wrapper
jinyan1214 Oct 16, 2024
393ce10
add a compile to geojson function
jinyan1214 Oct 16, 2024
b28f7d3
add a ipynb as a tool for postprocessing
jinyan1214 Oct 16, 2024
be80869
enable Sangri's error handling systems other than windows
jinyan1214 Oct 16, 2024
4385f7c
Merge remote-tracking branch 'upstream/master' into barbaros_transport
jinyan1214 Oct 23, 2024
deab74d
Add post event od file option
jinyan1214 Oct 23, 2024
d521554
Run all OD is hour_list is empty
jinyan1214 Oct 23, 2024
5c7f80c
Merge remote-tracking branch 'upstream/master' into barbaros_transport
jinyan1214 Oct 28, 2024
4bcc5bf
run residual demand from main workflow
jinyan1214 Oct 30, 2024
69943ce
change residual demand to run undamaged network only once
jinyan1214 Oct 30, 2024
1881eb3
suppress ruff check errors by "--add-noqa"
jinyan1214 Oct 30, 2024
4da5086
Add doc string to run_residual_demand
jinyan1214 Oct 30, 2024
08ff14d
Ruff format
jinyan1214 Oct 30, 2024
1f67b79
codespell
jinyan1214 Oct 30, 2024
11ba5ef
Merge branch 'master' into barbaros_transport
fmckenna Oct 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
430 changes: 222 additions & 208 deletions modules/Workflow/WorkflowApplications.json

Large diffs are not rendered by default.

51 changes: 30 additions & 21 deletions modules/Workflow/whale/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def create_command(command_list, enforced_python=None):
return command # noqa: DOC201, RUF100


def run_command(command, app_category=""): # noqa: C901
def run_command(command, app_category=''):
"""Short description

Long description
Expand Down Expand Up @@ -380,27 +380,26 @@ def run_command(command, app_category=""): # noqa: C901
#

try:

if (platform.system() == 'Windows') and ('python.exe' in str(command)):
if returncode != 0:
raise WorkFlowInputError('Analysis Failed at ' + app_category) # noqa: TRY301
# if (platform.system() == 'Windows') and ('python.exe' in str(command)):
if returncode != 0:
raise WorkFlowInputError('Analysis Failed at ' + app_category) # noqa: TRY301

# sy - safe apps should be added below
elif ('OpenSeesInput' in str(command)):
elif 'OpenSeesInput' in str(command): # noqa: RET506
if returncode != 0:
raise WorkFlowInputError('Analysis Failed at ' + app_category) # noqa: TRY301

return str(result), returncode

except WorkFlowInputError as e:
# this will catch the error
print(str(e).replace('\'','')) # noqa: T201
print(" =====================================") # noqa: T201
print(str(e).replace("'", '')) # noqa: T201
print(' =====================================') # noqa: T201
print(str(result)) # noqa: T201
sys.exit(-20)

except: # noqa: E722
# if for whatever reason the function inside "try" failes, move on without checking error
# if for whatever reason the function inside "try" fails, move on without checking error
return str(result), 0

return result, returncode
Expand Down Expand Up @@ -1307,7 +1306,7 @@ def create_asset_files(self):
prepend_blank_space=False,
)

result, returncode = run_command(command,"Asset Creater")
result, returncode = run_command(command, 'Asset Creater')

# Check if the command was completed successfully
if returncode != 0:
Expand Down Expand Up @@ -1546,7 +1545,15 @@ def perform_system_performance_assessment(self, asset_type):

# Check if system performance is requested
if 'SystemPerformance' in self.workflow_apps:
performance_app = self.workflow_apps['SystemPerformance'][asset_type]
if asset_type in self.workflow_apps['SystemPerformance']:
performance_app = self.workflow_apps['SystemPerformance'][asset_type]
else:
log_msg(
f'No Performance application to run for asset type: {asset_type}.',
prepend_timestamp=False,
)
log_div()
return False
else:
log_msg(
f'No Performance application to run for asset type: {asset_type}.',
Expand Down Expand Up @@ -1597,7 +1604,7 @@ def perform_system_performance_assessment(self, asset_type):
prepend_blank_space=False,
)

result, returncode = run_command(command,"Performance Assessment")
result, returncode = run_command(command, 'Performance Assessment')
log_msg(
f'\n{result}\n',
prepend_timestamp=False,
Expand Down Expand Up @@ -1661,7 +1668,7 @@ def perform_regional_event(self):
prepend_blank_space=False,
)

result, returncode = run_command(command,"Hazard Event")
result, returncode = run_command(command, 'Hazard Event')

log_msg('Output: ', prepend_timestamp=False, prepend_blank_space=False)
log_msg(
Expand Down Expand Up @@ -1724,7 +1731,7 @@ def perform_regional_recovery(self, asset_keys): # noqa: ARG002
prepend_blank_space=False,
)

result, returncode = run_command(command, "Recovery")
result, returncode = run_command(command, 'Recovery')

log_msg('Output: ', prepend_timestamp=False, prepend_blank_space=False)
log_msg(
Expand Down Expand Up @@ -1807,7 +1814,7 @@ def perform_regional_mapping(self, AIM_file_path, assetType, doParallel=True):
)

else:
result, returncode = run_command(command,"Hazard-Asset Mapping (HTA)")
result, returncode = run_command(command, 'Hazard-Asset Mapping (HTA)')

log_msg(
'Output: ' + str(returncode),
Expand Down Expand Up @@ -2047,7 +2054,9 @@ def preprocess_inputs( # noqa: C901
prepend_blank_space=False,
)

result, returncode = run_command(command,f'{app_type} - at the initial setup (getRV)')
result, returncode = run_command(
command, f'{app_type} - at the initial setup (getRV)'
)

log_msg(
'Output: ' + str(returncode),
Expand Down Expand Up @@ -2457,7 +2466,7 @@ def simulate_response(self, AIM_file_path='AIM.json', asst_id=None): # noqa: C9
prepend_blank_space=False,
)

result, returncode = run_command(command, "Response Simulator")
result, returncode = run_command(command, 'Response Simulator')

if self.run_type in ['run', 'runningLocal']:
log_msg(
Expand Down Expand Up @@ -2534,7 +2543,7 @@ def perform_asset_performance(asset_type): # noqa: N805, D102
app_path=self.app_dir_local # noqa: F821
)
command = create_command(app_command_list)
result, returncode = run_command(command,"Performance assessment")
result, returncode = run_command(command, 'Performance assessment')

def estimate_losses( # noqa: C901
self,
Expand Down Expand Up @@ -2627,7 +2636,7 @@ def estimate_losses( # noqa: C901
prepend_blank_space=False,
)

result, returncode = run_command(command,"Damage and loss")
result, returncode = run_command(command, 'Damage and loss')

log_msg(result, prepend_timestamp=False)

Expand Down Expand Up @@ -2678,7 +2687,7 @@ def estimate_losses( # noqa: C901
prepend_blank_space=False,
)

result, returncode = run_command(command,"Damage and loss")
result, returncode = run_command(command, 'Damage and loss')

log_msg(result, prepend_timestamp=False)

Expand Down Expand Up @@ -2821,7 +2830,7 @@ def estimate_performance( # noqa: D102
prepend_blank_space=False,
)

result, returncode = run_command(command,"Performance Assessment")
result, returncode = run_command(command, 'Performance Assessment')

log_msg(result, prepend_timestamp=False)

Expand Down
3 changes: 2 additions & 1 deletion modules/createEDP/surrogateEDP/surrogateEDP.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import argparse
import json

errPath = os.path.join(os.getcwd(),'workflow.err') # noqa: N816
errPath = os.path.join(os.getcwd(), 'workflow.err') # noqa: N816, PTH109, PTH118


def write_RV(AIM_input_path, EDP_input_path, EDP_type): # noqa: ARG001, N802, N803, D103
# load the AIM file
Expand Down
Loading
Loading