`verdi deamon restart` VS `verdi deamon stop` and `verdi deamon start`

What’s the difference between verdi deamon restart and verdi deamon stop with verdi deamon start?
I got a problem in AiiDAlab, that the daemon (Process) can not load a module,

$ verdi process report 593
2024-04-27 09:50:57 [2 | ERROR]: Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/site-packages/aiida/engine/persistence.py", line 48, in load_object
    module = importlib.import_module(module_name)
  File "/opt/conda/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/jovyan/.local/lib/python3.9/site-packages/aiidalab_qe/workflows/__init__.py", line 9, in <module>
    from aiida_quantumespresso.data.hubbard_structure import HubbardStructureData
  File "/home/jovyan/.local/lib/python3.9/site-packages/aiida_quantumespresso/data/hubbard_structure.py", line 10, in <module>
    from aiida_quantumespresso.common.hubbard import Hubbard, HubbardParameters
  File "/home/jovyan/.local/lib/python3.9/site-packages/aiida_quantumespresso/common/hubbard.py", line 6, in <module>
    from pydantic import BaseModel, conint, constr, field_validator
  File "/home/jovyan/.local/lib/python3.9/site-packages/pydantic/__init__.py", line 395, in __getattr__
    module = import_module(module_name, package=package)
  File "/opt/conda/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/jovyan/.local/lib/python3.9/site-packages/pydantic/main.py", line 12, in <module>
    import pydantic_core
  File "/home/jovyan/.local/lib/python3.9/site-packages/pydantic_core/__init__.py", line 30, in <module>
    from .core_schema import CoreConfig, CoreSchema, CoreSchemaType, ErrorType
  File "/home/jovyan/.local/lib/python3.9/site-packages/pydantic_core/core_schema.py", line 15, in <module>
    from typing_extensions import deprecated
ImportError: cannot import name 'deprecated' from 'typing_extensions' (/opt/conda/lib/python3.9/site-packages/typing_extensions.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/site-packages/aiida/manage/external/rmq/launcher.py", line 90, in _continue
    result = await super()._continue(communicator, pid, nowait, tag)
  File "/opt/conda/lib/python3.9/site-packages/plumpy/process_comms.py", line 604, in _continue
    proc = cast('Process', saved_state.unbundle(self._load_context))
  File "/opt/conda/lib/python3.9/site-packages/plumpy/persistence.py", line 58, in unbundle
    return Savable.load(self, load_context)
  File "/opt/conda/lib/python3.9/site-packages/plumpy/persistence.py", line 446, in load
    load_cls = load_context.loader.load_object(class_name)
  File "/opt/conda/lib/python3.9/site-packages/aiida/engine/persistence.py", line 50, in load_object
    raise ImportError(f"module '{module_name}' from identifier '{identifier}' could not be loaded")
ImportError: module 'aiidalab_qe.workflows' from identifier 'aiidalab_qe.workflows:QeAppWorkChain' could not be loaded

But I can load the module in the pure Python interpreter,

$ python
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:58:50)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from aiida_quantumespresso.data.hubbard_structure import HubbardStructureData
>>> import aiida_quantumespresso
>>> aiida_quantumespresso.__path__
['/home/jovyan/.local/lib/python3.9/site-packages/aiida_quantumespresso']

So I ran verdi daemon restart. However, the daemon still could not load the module. Only after running verdi deamon stop and verdi deamon start, can the daemon load the module.

Any idea why?

verdi daemon restart is a soft reset, meaning just the daemon workers are restarted, not the daemonizer process itself. When the worker is restart for a soft stop, it inherits the state of the daemonizer process, which won’t have the updated module index.

To mimic verdi daemon stop && verdi daemon start you should do verdi daemon restart --reset, which actually restarts the daemonizer process as well as the workers. Note that on the main branch, the --reset flag is deprecated and verdi daemon restart now always performs a full restart.

3 Likes

Thanks for your kind reply! @sphuber .

on the main branch, the --reset flag is deprecated and verdi daemon restart now always performs a full restart.

This is very helpful!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.