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

Lack of ewatercycle configuration (CFG) causes unclear error #320

Open
BSchilperoort opened this issue Sep 30, 2022 · 0 comments
Open

Lack of ewatercycle configuration (CFG) causes unclear error #320

BSchilperoort opened this issue Sep 30, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@BSchilperoort
Copy link
Member

If a user has no configuration saved, or something went wrong with saving it, the user is greeted with the error below when they try to call model.setup.

Perhaps a check to see if a configuration is present/not empty could help users debug.

Full error trace
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In [8], line 1
----> 1 cfg_file, cfg_dir = model.setup(
      2     maximum_soil_moisture_storage=12.0,
      3     end_time="1989-02-01T00:00:00Z",
      4 )
      5 print(cfg_file)
      6 print(cfg_dir)

File ~/mambaforge/envs/ewatercycle/lib/python3.10/site-packages/ewatercycle/models/marrmot.py:143, in MarrmotM01.setup(self, maximum_soil_moisture_storage, initial_soil_moisture_storage, start_time, end_time, solver, cfg_dir, delay)
    140 if cfg_dir:
    141     cfg_dir_as_path = to_absolute_path(cfg_dir)
--> 143 cfg_dir_as_path = _generate_cfg_dir(cfg_dir_as_path)
    144 config_file = self._create_marrmot_config(cfg_dir_as_path, start_time, end_time)
    146 if CFG["container_engine"].lower() == "singularity":

File ~/mambaforge/envs/ewatercycle/lib/python3.10/site-packages/ewatercycle/models/marrmot.py:50, in _generate_cfg_dir(cfg_dir)
     46     # TODO this timestamp isnot safe for parallel processing
     47     timestamp = datetime.datetime.now(datetime.timezone.utc).strftime(
     48         "%Y%m%d_%H%M%S"
     49     )
---> 50     cfg_dir = to_absolute_path(f"marrmot_{timestamp}", parent=Path(scratch_dir))
     51 cfg_dir.mkdir(parents=True, exist_ok=True)
     52 return cfg_dir

File ~/mambaforge/envs/ewatercycle/lib/python3.10/pathlib.py:960, in Path.__new__(cls, *args, **kwargs)
    958 if cls is Path:
    959     cls = WindowsPath if os.name == 'nt' else PosixPath
--> 960 self = cls._from_parts(args)
    961 if not self._flavour.is_supported:
    962     raise NotImplementedError("cannot instantiate %r on your system"
    963                               % (cls.__name__,))

File ~/mambaforge/envs/ewatercycle/lib/python3.10/pathlib.py:594, in PurePath._from_parts(cls, args)
    589 @classmethod
    590 def _from_parts(cls, args):
    591     # We need to call _parse_args on the instance, so as to get the
    592     # right flavour.
    593     self = object.__new__(cls)
--> 594     drv, root, parts = self._parse_args(args)
    595     self._drv = drv
    596     self._root = root

File ~/mambaforge/envs/ewatercycle/lib/python3.10/pathlib.py:578, in PurePath._parse_args(cls, args)
    576     parts += a._parts
    577 else:
--> 578     a = os.fspath(a)
    579     if isinstance(a, str):
    580         # Force-cast str subclasses to str (issue #21127)
    581         parts.append(str(a))

TypeError: expected str, bytes or os.PathLike object, not NoneType
@BSchilperoort BSchilperoort added the enhancement New feature or request label Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant