NOAA-GFDL / MDTF-diagnostics

Analysis framework and collection of process-oriented diagnostics for weather and climate simulations
https://mdtf-diagnostics.readthedocs.io/en/main/
Other
64 stars 100 forks source link

Error messages #660

Closed aradhakrishnanGFDL closed 3 months ago

aradhakrishnanGFDL commented 3 months ago

Improved messaging to users

When the conda environment or executable path in the runtime config file is set to an invalid path or something not accessible, the framework errors out as expected. However, most of the traceback may fit the log file better, and the messaging could be improved and made more readable for common exceptions. In this instance, error message was to fix my runtime config json, not the settings.json.

/proj/MDTF-diagnostics/src/util/dataclass.py:836: SyntaxWarning: invalid escape sequence '\='
  """Given a dataclass *dc* (may be the class or an instance of it), and a dict,
ERROR: /local/home/Jacob.Mims/miniconda3/envs/_MDTF_python3_base not found.
CRITICAL: **********************************************************************
Uncaught exception:
Traceback (most recent call last):
  File "/proj/MDTF-diagnostics/src/pod_setup.py", line 199, in verify_pod_settings
    verify_runtime_reqs(self.pod_settings['runtime_requirements'])
  File "/proj/MDTF-diagnostics/src/pod_setup.py", line 164, in verify_runtime_reqs
    assert os.path.isdir(env_dir), self.log.error(f'%s not found.', env_dir)
           ^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/proj/MDTF-diagnostics/mdtf_framework.py", line 243, in <module>
    exit_code = main(prog_name='MDTF-diagnostics')
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/_MDTF_base/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/_MDTF_base/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/_MDTF_base/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/_MDTF_base/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/_MDTF_base/lib/python3.12/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/proj/MDTF-diagnostics/mdtf_framework.py", line 185, in main
    pods[pod_name].setup_pod(ctx.config, model_paths, cases, append_vars)
  File "/proj/MDTF-diagnostics/src/pod_setup.py", line 278, in setup_pod
    self.verify_pod_settings()
  File "/proj/MDTF-diagnostics/src/pod_setup.py", line 201, in verify_pod_settings
    raise util.PodConfigError('POD runtime requirements not defined in specified Conda environment') \
src.util.exceptions.PodConfigError: Couldn't parse the settings.jsonc file: POD runtime requirements not defined in specified Conda environment.
wrongkindofdoctor commented 3 months ago

@jtmims @aradhakrishnanGFDL We can add info that this may mean the the path is inaccessible to this message.

jtmims commented 3 months ago

Before, we would check that everything is okay with conda and mamba while setting up each POD. I wrote some simple logic to run after the config file is parsed. It can be found on this PR #663