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

Obsfile path with spaces is not supported #564

Open
veenstrajelmer opened this issue Oct 10, 2023 · 0 comments
Open

Obsfile path with spaces is not supported #564

veenstrajelmer opened this issue Oct 10, 2023 · 0 comments
Labels
priority: high type: bug Something isn't working type: compatibility Changes needed to be compatible with the computational core

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Oct 10, 2023

Describe the bug
When there is a space in an obsfile path, HYDROLIB-core raises a ValidationError since it only reads the path up to the space:

ValidationError: 4 validation errors for Output
obsfile -> 0
  File: `C:\DATA\dfm_tools\dfm_tools\Vietnam_model_forissue\Vietnam` not found, skipped parsing. (type=value_error)
obsfile -> 0

The path of the obsfile is C:\DATA\dfm_tools\tests\examples_workinprogress\Vietnam _model_forissue\Vietnam_obs.xyn

To Reproduce

# import packages
import os
import hydrolib.core.dflowfm as hcdfm

# user input
model_name = 'Vietnam'
dir_output = os.path.abspath(f'./{model_name} _model_forissue') #TODO: space in path will raise ValidationError
os.makedirs(dir_output, exist_ok=True)

# construct and save empty obsfile
file_obs = os.path.join(dir_output, f'{model_name}_obs.xyn')
obs_mod = hcdfm.ObservationPointModel()
obs_mod.save(file_obs)

# construct and save empty extfile (old)
file_ext_old = os.path.join(dir_output, f'{model_name}_old.ext')
ext_old_mod = hcdfm.ExtOldModel()
ext_old_mod.save(file_ext_old)

# construct and save empty extfile (new)
file_ext_new = os.path.join(dir_output, f'{model_name}_new.ext')
ext_new_mod = hcdfm.ExtModel()
ext_new_mod.save(file_ext_new)

# initialize mdu file and update settings
mdu = hcdfm.FMModel()
# setting the ext files will work fine
mdu.external_forcing.extforcefile = file_ext_old
mdu.external_forcing.extforcefilenew = file_ext_new
# setting the obs file raises "ValidationError: 4 validation errors for Output"
mdu.output.obsfile = file_obs

Additional information
I noticed that when supplying mdu.output.obsfile = obs_mod instead of mdu.output.obsfile = file_obs, it raises:

ValidationError: 1 validation error for Output
obsfile
  value is not a valid list (type=type_error.list)

And when supplying mdu.output.obsfile = [obs_mod] or of mdu.output.obsfile = [file_obs], there is no error and the process successfully continues.

Expected behavior
If a space is included, it will still work. Just like for files like ext files and such, since it works here. With the insight from the additional information: align the error message if a user supplies a filepath with the one that is raised when a user supplies a ObservationPointModel.

Version info (please complete the following information):

  • OS: Windows
  • Version: 0.7.0
@priscavdsluis priscavdsluis added type: bug Something isn't working type: compatibility Changes needed to be compatible with the computational core priority: high labels Apr 9, 2024
@rhutten rhutten added this to To do in HYDROLIB-core via automation Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high type: bug Something isn't working type: compatibility Changes needed to be compatible with the computational core
Projects
HYDROLIB-core
  
To do
Development

No branches or pull requests

2 participants