multiscale / muscle3

The third major version of the MUltiScale Coupling Library and Environment
Apache License 2.0
25 stars 13 forks source link

Improve error message when component implementation cannot be found #161

Closed maarten-ic closed 1 year ago

maarten-ic commented 1 year ago

Reproduction scenario:

  1. Update file docs/source/examples/rd_python.ymmsl, change macro/implementation to diffusion_pythonX (or something else for which no entry exists in the implementations)
  2. Run muscle_manager (e.g. make test_examples)
  3. Observe error message:
Traceback (most recent call last):
  File "/home/maarten/projects/muscle3/docs/source/examples/python/build/venv/bin/muscle_manager", line 8, in <module>
    sys.exit(manage_simulation())
  File "/home/maarten/projects/muscle3/docs/source/examples/python/build/venv/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/maarten/projects/muscle3/docs/source/examples/python/build/venv/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/maarten/projects/muscle3/docs/source/examples/python/build/venv/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/maarten/projects/muscle3/docs/source/examples/python/build/venv/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/maarten/projects/muscle3/docs/source/examples/python/build/venv/lib/python3.8/site-packages/muscle3/muscle_manager.py", line 74, in manage_simulation
    manager.start_instances()
  File "/home/maarten/projects/muscle3/libmuscle/python/libmuscle/manager/manager.py", line 98, in start_instances
    self._instance_manager.start_all()
  File "/home/maarten/projects/muscle3/libmuscle/python/libmuscle/manager/instance_manager.py", line 97, in start_all
    allocations = self._planner.allocate_all(self._configuration)
  File "/home/maarten/projects/muscle3/libmuscle/python/libmuscle/planner/planner.py", line 467, in allocate_all
    exclusive = {
  File "/home/maarten/projects/muscle3/libmuscle/python/libmuscle/planner/planner.py", line 470, in <setcomp>
    not implementations[c.implementation].can_share_resources)}
KeyError: Reference("diffusion_pythonX")

Expected behaviour

A clear error message that the configuration is not correct (e.g. "Implementation 'diffusion_pythonX' of component 'macro' is not defined in the yMMSL configuration.")

LourensVeen commented 1 year ago

Hmm, shouldn't ymmsl.Configuration.check_consistent() catch this? Is it not getting called somehow?

maarten-ic commented 1 year ago

Looks like it's only called when using libmuscle.runner.run_simulation, not when using muscle_manager --start-all:

$ git grep 'check_consistent'
libmuscle/python/libmuscle/runner.py:284:    configuration.model.check_consistent()
$

So, then this issue may reduce to "Make sure check_consistent is called when starting the manager" (perhaps only when doing --start-all).