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

Confusing parameter set path configuration in the model.ipynb #1

Open
geek-yang opened this issue Nov 3, 2023 · 0 comments
Open

Confusing parameter set path configuration in the model.ipynb #1

geek-yang opened this issue Nov 3, 2023 · 0 comments

Comments

@geek-yang
Copy link

The following path configuration is quite misleading. The code seems to ask user to give the correct path to unzipped demo folder and then everything would work.

"parameter_set_dir = \"<path where demo.zip was extracted to>\"\n",
"parameter_set = ewatercycle.parameter_sets.ParameterSet(\n",
" name=\"hype_demo\",\n",
" directory=parameter_set_dir,\n",
" config=\"info.txt\",\n",
" target_model=\"hype\",\n",

But this will end up with an error in the next cell:

model = ewatercycle.models.Hype(version="feb2021", parameter_set=parameter_set)

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[4], line 1
----> 1 model = ewatercycle.models.Hype(version="feb2021", parameter_set=parameter_set)

    [... skipping hidden 1 frame]

File /opt/conda/envs/ewatercycle/lib/python3.10/site-packages/ewatercycle_hype/model.py:45, in Hype._initialize_config(self)
     42 @model_validator(mode="after")
     43 def _initialize_config(self: "Hype") -> "Hype":
     44     """Load config from parameter set and update with forcing info."""
---> 45     self._config = self.parameter_set.config.read_text(encoding="cp437")
     47     start = _get_hype_time(_get_code_in_cfg(self._config, "bdate"))
     48     end = _get_hype_time(_get_code_in_cfg(self._config, "edate"))

File /opt/conda/envs/ewatercycle/lib/python3.10/pathlib.py:1132, in Path.read_text(self, encoding, errors)
   1128 """
   1129 Open the file in text mode, read it, and close the file.
   1130 """
   1131 encoding = io.text_encoding(encoding)
-> 1132 with self.open(mode='r', encoding=encoding, errors=errors) as f:
   1133     return f.read()

File /opt/conda/envs/ewatercycle/lib/python3.10/pathlib.py:1117, in Path.open(self, mode, buffering, encoding, errors, newline)
   1115 if "b" not in mode:
   1116     encoding = io.text_encoding(encoding)
-> 1117 return self._accessor.open(self, mode, buffering, encoding, errors,
   1118                            newline)

FileNotFoundError: [Errno 2] No such file or directory: 'info.txt'

Actually, user also needs to change config="info.txt" to config=parameter_set_dir + "info.txt". It is necessary to make it clear.

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

No branches or pull requests

1 participant