Skip to content

Commit

Permalink
Merge branch 'master' of github.com:NHERI-SimCenter/SimCenterBackendA…
Browse files Browse the repository at this point in the history
…pplications
  • Loading branch information
fmckenna committed Sep 19, 2024
2 parents 06d43b8 + ae580fa commit 4c8b2ce
Show file tree
Hide file tree
Showing 14 changed files with 1,741 additions and 603 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,4 @@ fmkTest.sh
#Remove .vscode
.vscode



.coverage
56 changes: 16 additions & 40 deletions modules/Workflow/whale/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1507,27 +1507,33 @@ def augment_asset_files(self): # noqa: C901
return assetFilesList # noqa: DOC201, RUF100

def perform_system_performance_assessment(self, asset_type):
"""For an asset type run the system level performance assessment application
"""Run the system level performance assessment application.
Longer description
For an asset type run the system level performance assessment
application.
Parameters
----------
asset_type: string
Asset type to run perform system assessment of
""" # noqa: D400
if 'SystemPerformance' in self.workflow_apps.keys(): # noqa: SIM118
"""
# Make sure that we are in the run directory before we run REWET
# Every other path will be relative to the Run Directory (result dir)
os.chdir(self.run_dir)

# Check if system performance is requested
if 'SystemPerformance' in self.workflow_apps:
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 # noqa: DOC201, RUF100
return False

if performance_app.rel_path == None: # noqa: E711
if performance_app.rel_path is None:
log_msg(
f'No Performance application to run for asset type: {asset_type}.',
prepend_timestamp=False,
Expand All @@ -1536,8 +1542,7 @@ def perform_system_performance_assessment(self, asset_type):
return False

log_msg(
'Performing System Performance Application for asset type: '
+ asset_type,
f'Performing System Performance Application for asset type: {asset_type}',
prepend_timestamp=False,
)
log_div()
Expand All @@ -1550,18 +1555,13 @@ def perform_system_performance_assessment(self, asset_type):
# defaults added to a system performance app are asset_type, input_dir and running_parallel (default False)
#

# app_command_list.append('--asset_type')
# app_command_list.append(asset_type)
app_command_list.append('--input')
app_command_list.append(self.input_file)
# app_command_list.append('--working_dir')
# app_command_list.append(self.working_dir)

# Sina added this part for parallel run in REWET
if self.parType == 'parSETUP':
log_msg(
'\nParallel settings for System Performance for asset type:'
+ asset_type,
f'\nParallel settings for System Performance for asset type:{asset_type}',
prepend_timestamp=False,
)
app_command_list.append('--par')
Expand All @@ -1583,34 +1583,10 @@ def perform_system_performance_assessment(self, asset_type):
)

log_msg(
'System Performance Application Completed for asset type: ' + asset_type,
f'System Performance Application Completed for asset type: {asset_type}',
prepend_timestamp=False,
)

# end of Sina's odifications for parallel run

# if (self.parType == 'parSETUP'):

# log_msg('\nWriting System Performance application for asset type:' + asset_type, prepend_timestamp=False)
# self.parCommandFile.write("\n# Writing System Performance application for asset type:" + asset_type +"\n")

# if performance_app.runsParallel == False:
# self.parCommandFile.write(command + "\n")
# else:
# self.parCommandFile.write(self.mpiExec + " -n " + str(self.numProc) + " " + command + " --running_parallel True\n")

# else:

# log_msg('\n{}\n'.format(command), prepend_timestamp=False,
# prepend_blank_space=False)

# result, returncode = run_command(command)

# log_msg('Output: ', prepend_timestamp=False, prepend_blank_space=False)
# log_msg('\n{}\n'.format(result), prepend_timestamp=False, prepend_blank_space=False)

# log_msg('System Performance Application Completed for asset type: ' + asset_type, prepend_timestamp=False)

log_div()
return True

Expand Down Expand Up @@ -2870,7 +2846,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 != self.run_dir.name:
while main_dir.parent.name != 'Results':
main_dir = bldg_dir.parent
assetTypeHierarchy = [main_dir.name] + assetTypeHierarchy # noqa: N806, RUF005

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json # noqa: INP001, D100
import os
import sys
import time

try:
Expand Down Expand Up @@ -656,14 +657,14 @@ def err_exit(msg): # noqa: D103
# parseWindMatFile("Forces_ANG000_phase1.mat", "Forces_ANG000_phase1.json")
# parseWindMatFile("TargetSpectra_ANG000_phase1.mat", "TargetSpectra_ANG000_phase1.json")

inputArgs = sys.argv # noqa: N816, F405
inputArgs = sys.argv # noqa: N816

# set filenames
aimName = sys.argv[2] # noqa: N816, F405
evtName = sys.argv[4] # noqa: N816, F405
aimName = sys.argv[2] # noqa: N816
evtName = sys.argv[4] # noqa: N816

getRV = False # noqa: N816
for myarg in sys.argv: # noqa: F405
for myarg in sys.argv:
if myarg == '--getRV':
getRV = True # noqa: N816

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json # noqa: INP001, D100
import os
import sys
import time

try:
Expand All @@ -21,16 +22,16 @@
from convertWindMat import * # noqa: F403

errPath = './workflow.err' # error file name # noqa: N816
sys.stderr = open( # noqa: SIM115, PTH123, F405
sys.stderr = open( # noqa: SIM115, PTH123
errPath, 'w'
) # redirecting stderr (this way we can capture all sorts of python errors)


def err_exit(msg): # noqa: D103
print('Failed in wind load generator: ' + msg) # display in stdout # noqa: T201
print(
print( # noqa: T201
'Failed in wind load generator: ' + msg,
file=sys.stderr, # noqa: F405
file=sys.stderr,
) # display in stderr
exit(-1) # exit with non-zero exit code # noqa: PLR1722

Expand Down Expand Up @@ -300,7 +301,7 @@ def main(aimName, evtName, getRV): # noqa: C901, N803, D103, PLR0915
try:
self.pool.shutdown() # noqa: F405
except Exception: # noqa: BLE001
sys.exit() # noqa: F405
sys.exit()

my_cdf_vects = np.zeros((1000, tap))
my_cdf_x_range = np.zeros((2, tap))
Expand Down Expand Up @@ -487,7 +488,7 @@ def main(aimName, evtName, getRV): # noqa: C901, N803, D103, PLR0915
try:
self.pool.shutdown() # noqa: F405
except Exception: # noqa: BLE001
sys.exit() # noqa: F405
sys.exit()

Cp_nongauss_kernel = np.zeros((tap, CP_sim.shape[2], len(seeds))) # noqa: N806
Cp_nongauss_kernel[:, :, 0] = np.array(result_objs)
Expand Down Expand Up @@ -834,7 +835,7 @@ def perform_POD(s_target, f_target, ncomp, l_mo, pool): # noqa: N802, D103
try:
self.pool.shutdown() # noqa: F405
except Exception: # noqa: BLE001
sys.exit() # noqa: F405
sys.exit()

for ii in range(SpeN):
D_all = result_objs[ii][0] # noqa: N806
Expand Down Expand Up @@ -952,14 +953,14 @@ def simulation_gaussian( # noqa: D103, PLR0913


if __name__ == '__main__':
inputArgs = sys.argv # noqa: N816, F405
inputArgs = sys.argv # noqa: N816

# set filenames
aimName = sys.argv[2] # noqa: N816, F405
evtName = sys.argv[4] # noqa: N816, F405
aimName = sys.argv[2] # noqa: N816
evtName = sys.argv[4] # noqa: N816

getRV = False # noqa: N816
for myarg in sys.argv: # noqa: F405
for myarg in sys.argv:
if (myarg == '--getRV') or (myarg == 'getRV'): # noqa: PLR1714
getRV = True # noqa: N816

Expand Down
Loading

0 comments on commit 4c8b2ce

Please sign in to comment.