Skip to content

refactor(flopy_io, notebooks): update path cleaning mechanism#1728

Merged
wpbonelli merged 1 commit into
modflowpy:developfrom
wpbonelli:fix-path-cleaning
Feb 24, 2023
Merged

refactor(flopy_io, notebooks): update path cleaning mechanism#1728
wpbonelli merged 1 commit into
modflowpy:developfrom
wpbonelli:fix-path-cleaning

Conversation

@wpbonelli
Copy link
Copy Markdown
Member

@wpbonelli wpbonelli commented Feb 21, 2023

#1711 cleaned up absolute paths containing usernames from notebooks and introduced a function relpath_printstr to trap relpath errors due to different drives on Windows. This isn't always sufficient to keep absolute paths out of notebooks if used with a path sharing no prefix with the starting path (e.g. if an exe isn't in the flopy project dir, but somewhere like /usr/bin)

  • Rename relpath_printstr -> relpath_safe since it returns the edited path without printing. Update usages. Refactor to follow builtin relpath signature and defaults.

  • Introduce a function scrub_login to obfuscate login names with ***. Optionally scrub in relpath_safe.

  • Suppress output in notebooks with silent=True and collect with report=True before printing, avoiding the executable log statement if possible, otherwise use scrub_login() to hide username in absolute paths

  • Lint notebooks and test scripts

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 21, 2023

Codecov Report

Merging #1728 (72f6930) into develop (58d92fa) will decrease coverage by 0.1%.
The diff coverage is 86.6%.

@@            Coverage Diff            @@
##           develop   #1728     +/-   ##
=========================================
- Coverage     71.9%   71.9%   -0.1%     
=========================================
  Files          253     253             
  Lines        55987   55996      +9     
=========================================
+ Hits         40270   40275      +5     
- Misses       15717   15721      +4     
Impacted Files Coverage Δ
flopy/mbase.py 69.1% <ø> (ø)
flopy/export/shapefile_utils.py 90.2% <75.0%> (-0.4%) ⬇️
flopy/utils/flopy_io.py 79.0% <88.2%> (-0.3%) ⬇️
flopy/export/utils.py 65.2% <100.0%> (ø)
flopy/utils/check.py 75.7% <100.0%> (ø)

@wpbonelli wpbonelli force-pushed the fix-path-cleaning branch 3 times, most recently from 0a97e89 to 36b5849 Compare February 22, 2023 02:35
@wpbonelli wpbonelli changed the title fix(relpath): refactor path cleaning utilities refactor(flopy_io, notebooks): update path cleaning mechanism Feb 22, 2023
@wpbonelli wpbonelli force-pushed the fix-path-cleaning branch 3 times, most recently from 775eddf to d2f3442 Compare February 22, 2023 04:13
@wpbonelli wpbonelli marked this pull request as ready for review February 22, 2023 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants