caracal-pipeline / stimela

Stimela 2.0
GNU General Public License v2.0
5 stars 4 forks source link

need better error message when module is not found for "_include: (module)file.yml" #288

Open o-smirnov opened 7 months ago

o-smirnov commented 7 months ago

When including from a module, and the module is not found, the error is hard to decipher:

2024-05-03 09:12:22 STIMELA INFO: will load recipe/config file /home/oms/projects/breifast/breifast/tron.yml                                                                                                     
Traceback (most recent call last):
  File "/home/oms/.venv/stimela/bin/stimela", line 8, in <module>
    sys.exit(cli())
  File "/home/oms/.venv/stimela/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/oms/.venv/stimela/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/oms/.venv/stimela/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/oms/.venv/stimela/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/oms/.venv/stimela/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/oms/projects/stimela2/stimela/commands/run.py", line 261, in run
    available_recipes = load_recipe_files(files_to_load)
  File "/home/oms/projects/stimela2/stimela/commands/run.py", line 98, in load_recipe_files
    conf, deps = configuratt.load(filename, use_sources=[stimela.CONFIG, full_conf], no_toplevel_cache=True)
  File "/home/oms/projects/stimela2/scabha/configuratt/__init__.py", line 54, in load
    conf, deps = resolve_config_refs(subconf, pathname=path, location=location, name=name, 
  File "/home/oms/projects/stimela2/scabha/configuratt/resolvers.py", line 312, in resolve_config_refs
    accum_pre = load_include_files("_include")
  File "/home/oms/projects/stimela2/scabha/configuratt/resolvers.py", line 252, in load_include_files
    filename = os.path.join(os.path.dirname(mod.__file__), filename)
  File "/usr/lib/python3.10/posixpath.py", line 152, in dirname
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType
o-smirnov commented 7 months ago

A bit more subtle -- it's when the module is inside a package, but has no __init__.py.