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

Handle Relative Filepath #110

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from
2 changes: 1 addition & 1 deletion canflood/build/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@ def run_validate(self):
))

self.feedback.upd_prog(None)
self.validation_result_d=validation_result_d #store for ttests
self.validation_result_d=validation_result_d #store for tests



Expand Down
3 changes: 3 additions & 0 deletions canflood/model/modcom.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ def load_df_ctrl(self,#load raw data from control file
log.debug('no \'%s\'... skipping'%dtag)
continue

fp = os.path.join(self.cf_dir, fp)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cefect leveraged self.cf_dir to get base directory path and joined it with filepath.

#check it
assert os.path.exists(fp), '\'%s\' got bad filepath: \n %s'%(dtag, fp)

Expand Down Expand Up @@ -2103,6 +2104,8 @@ def _par_hndl_chk(self,
assert isinstance(pval, str), '%s.%s expected a filepath '%(sect, varnm)
if pval == '':
raise Error('must provided a valid \'%s.%s\' filepath'%(sect, varnm))
if not os.path.exists(pval):
pval = os.path.join(self.cf_dir,pval)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cefect here checking if the path is not valid then try to join it with base directory. even after this there is an assert statement so it will ensure the created path is valid. Adding this logic is producing correct paths and not showing errors in tests.

assert os.path.exists(pval), '%s.%s passed invalid filepath: \'%s\''%(sect, varnm, pval)

ext = os.path.splitext(os.path.split(pval)[1])[1]
Expand Down
Binary file added plugin_zips/canflood.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ apply_miti = False #whether to apply mitigation algorthihims

[dmg_fps]
curves = #damage curve library filepath
finv = C:\LS\09_REPOS\03_TOOLS\CanFlood\_git\tests2\data\test_02_build_inv_tests2__data0\finv_test_02_32_tut2.csv
finv = tests2\data\test_02_build_inv_tests2__data0\finv_test_02_32_tut2.csv
expos = #exposure data filepath
gels = #ground elevation data filepath
#'finv' file path set from prepr.py at 2022-06-26 14.30.12
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ impact_units = impacts #value to label impacts axis with (generally set by Dmg2
apply_miti = False #whether to apply mitigation algorthihims

[dmg_fps]
curves = C:\LS\09_REPOS\03_TOOLS\CanFlood\_git\tests2\data\test_03_build_inv_curves_tests0\cLib_test_03_2022-06-26_1806.xls
finv = C:\LS\09_REPOS\03_TOOLS\CanFlood\_git\tests2\data\test_02_build_inv_tests2__data0\finv_test_02_32_tut2.csv
curves = tests2\data\test_03_build_inv_curves_tests0\cLib_test_03_2022-06-26_1806.xls
finv = tests2\data\test_02_build_inv_tests2__data0\finv_test_02_32_tut2.csv
expos = #exposure data filepath
gels = #ground elevation data filepath
#'curves' file path set from builddialog.py at 2022-06-26 18.06.19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ impact_units = impacts #value to label impacts axis with (generally set by Dmg2
apply_miti = False #whether to apply mitigation algorthihims

[dmg_fps]
curves = C:\LS\09_REPOS\03_TOOLS\CanFlood\_git\tests2\data\test_03_build_inv_curves_tests0\cLib_test_03_2022-06-26_1806.xls
finv = C:\LS\09_REPOS\03_TOOLS\CanFlood\_git\tests2\data\test_02_build_inv_tests2__data0\finv_test_02_32_tut2.csv
expos = C:\LS\09_REPOS\03_TOOLS\CanFlood\_git\tests2\data\test_04_build_hsamp_tutorials_0\expos_test_04_4_32.csv
curves = tests2\data\test_03_build_inv_curves_tests0\cLib_test_03_2022-06-26_1806.xls
finv = tests2\data\test_02_build_inv_tests2__data0\finv_test_02_32_tut2.csv
expos = tests2\data\test_04_build_hsamp_tutorials_0\expos_test_04_4_32.csv
gels = #ground elevation data filepath
#'expos' file path set from rsamp.py at 2022-06-26 18.06.20

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ impact_units = impacts #value to label impacts axis with (generally set by Dmg2
apply_miti = False #whether to apply mitigation algorthihims

[dmg_fps]
curves = C:\LS\09_REPOS\03_TOOLS\CanFlood\_git\tests2\data\test_03_build_inv_curves_tests0\cLib_test_03_2022-06-26_1806.xls
finv = C:\LS\09_REPOS\03_TOOLS\CanFlood\_git\tests2\data\test_02_build_inv_tests2__data0\finv_test_02_32_tut2.csv
expos = C:\LS\09_REPOS\03_TOOLS\CanFlood\_git\tests2\data\test_04_build_hsamp_tutorials_0\expos_test_04_4_32.csv
curves = tests2\data\test_03_build_inv_curves_tests0\cLib_test_03_2022-06-26_1806.xls
finv = tests2\data\test_02_build_inv_tests2__data0\finv_test_02_32_tut2.csv
expos = tests2\data\test_04_build_hsamp_tutorials_0\expos_test_04_4_32.csv
gels = #ground elevation data filepath

[risk_fps]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ impact_units = impacts #value to label impacts axis with (generally set by Dmg2
apply_miti = False #whether to apply mitigation algorthihims

[dmg_fps]
curves = C:\LS\09_REPOS\03_TOOLS\CanFlood\_git\tests2\data\test_03_build_inv_curves_tests0\cLib_test_03_2022-06-26_1806.xls
finv = C:\LS\09_REPOS\03_TOOLS\CanFlood\_git\tests2\data\test_02_build_inv_tests2__data0\finv_test_02_32_tut2.csv
expos = C:\LS\09_REPOS\03_TOOLS\CanFlood\_git\tests2\data\test_04_build_hsamp_tutorials_0\expos_test_04_4_32.csv
gels = C:\LS\09_REPOS\03_TOOLS\CanFlood\_git\tests2\data\test_06_build_dtm_tutorials__20\gels_test_06_1_32.csv
curves = tests2\data\test_03_build_inv_curves_tests0\cLib_test_03_2022-06-26_1806.xls
finv = tests2\data\test_02_build_inv_tests2__data0\finv_test_02_32_tut2.csv
expos = tests2\data\test_04_build_hsamp_tutorials_0\expos_test_04_4_32.csv
gels = tests2\data\test_06_build_dtm_tutorials__20\gels_test_06_1_32.csv
#'gels' file path set from rsamp.py at 2022-06-26 18.06.21

[risk_fps]
Expand Down