Skip to content

Helpful error message if the data path is wrong#115

Open
dorchard wants to merge 1 commit intom2lines:refactor_clifrom
dorchard:refactor_cli_report_no_path
Open

Helpful error message if the data path is wrong#115
dorchard wants to merge 1 commit intom2lines:refactor_clifrom
dorchard:refactor_cli_report_no_path

Conversation

@dorchard
Copy link
Copy Markdown

@dorchard dorchard commented Mar 27, 2026

If the user provides a non-existent directory for --path (or a file) they get a pretty inscrutable runtime error, e.g.

> python -m nemo_spinup_forecast --ye True --start 20 --end 50 --comp 1 --steps 30 --path tests/data/nonexistent
...
Preparing ssh...
Using normal PCA
Traceback (most recent call last):
  ...
  File ".../forecast.py", line 185, in get_attributes
    self.files[-1], decode_times=False, chunks={"time": 200, "x": 120}
IndexError: list index out of range

This PR checks earlier on in the cli.py whether the path is valid then gives a message e.g.:

> python -m nemo_spinup_forecast --ye True --start 20 --end 50 --comp 1 --steps 30 --path tests/data/nonexistent
usage: __main__.py [-h] --path PATH [--ye YE] --start START --end END --steps STEPS [--comp COMP] [--ocean-terms OCEAN_TERMS]
                   [--techniques-config TECHNIQUES_CONFIG]
__main__.py: error: Data path does not exist: tests/data/nonexistent
  Please check the path and try again.

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.

1 participant