eWaterCycle / eWaterCycle/ewatercycle

Lack of ewatercycle configuration (`CFG`) causes unclear error

Open
#320 0 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
41
Forks
6
Avg merge
8d 23h
Merged PRs (30d)
2

Description

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

```py
---------------------------------------------------------------------------
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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.