Open ltalirz opened 5 years ago
It turns out this error arises because the workchain was defined in the same file from where it was run. If the workchain definition is put into a separate file and imported from there, the problem disappears.
Independent of whether this is really necessary, I think the error message should be a bit more helpful in this regard. How could this be improved?
The same error also appears when the workchain cannot be found in the python path. It being in the same file might have the same origin as that problem. If these are two separate causes I am not sure the loader can determine the reason. But at least we could maybe update the exception message to give a suggestion to make sure the workchain is in the python path
Just to mention that when adapting the script to aiida 1.0
# run simple workchain
from aiida.engine import run
from aiida.engine import WorkChain, ToContext, append_
from aiida.orm import Int, List
class ListEcho(WorkChain):
@classmethod
def define(cls, spec):
super(ListEcho, cls).define(spec)
spec.input('list', valid_type=List)
spec.output('output', valid_type=List)
spec.outline(cls.do_echo)
def do_echo(self):
self.out('output', self.inputs.list)
expected_results = {}
my_list = List()
my_list.extend([1, 2, 3])
result = run(ListEcho, list=my_list)
print(result)
the error message is still thrown, although it seems like the script now actually manages to run properly with verdi run
.
$ verdi run wc.py
11/11/2019 12:16:29 PM <83083> plumpy.processes: [ERROR] Exception trying to save checkpoint, this means you will not be able to restart in case of a crash until the next successful checkpoint.
Traceback (most recent call last):
File "/Users/leopold/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/engine/persistence.py", line 50, in load_object
return getattr(module, name)
AttributeError: module '__main__' has no attribute 'ListEcho'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/leopold/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/engine/persistence.py", line 83, in save_checkpoint
bundle = plumpy.Bundle(process, plumpy.LoadSaveContext(loader=get_object_loader()))
File "/Users/leopold/Applications/miniconda3/envs/aiida_rmq_py3/lib/python3.7/site-packages/plumpy/persistence.py", line 40, in __init__
self.update(savable.save(save_context))
File "/Users/leopold/Applications/miniconda3/envs/aiida_rmq_py3/lib/python3.7/site-packages/plumpy/persistence.py", line 504, in save
Savable._set_class_name(out_state, loader.identify_object(self.__class__))
File "/Users/leopold/Applications/miniconda3/envs/aiida_rmq_py3/lib/python3.7/site-packages/plumpy/loaders.py", line 62, in identify_object
self.load_object(identifier)
File "/Users/leopold/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/engine/persistence.py", line 52, in load_object
raise ImportError("object '{}' from identifier '{}' could not be loaded".format(name, identifier))
ImportError: object 'ListEcho' from identifier '__main__:ListEcho' could not be loaded
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/leopold/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/engine/processes/process.py", line 207, in _save_checkpoint
self.runner.persister.save_checkpoint(self)
File "/Users/leopold/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/engine/persistence.py", line 87, in save_checkpoint
"Failed to create a bundle for '{}': {}".format(process, traceback.format_exc())
plumpy.exceptions.PersistenceError: Failed to create a bundle for '<ListEcho> (ProcessState.CREATED)': Traceback (most recent call last):
File "/Users/leopold/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/engine/persistence.py", line 50, in load_object
return getattr(module, name)
AttributeError: module '__main__' has no attribute 'ListEcho'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/leopold/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/engine/persistence.py", line 83, in save_checkpoint
bundle = plumpy.Bundle(process, plumpy.LoadSaveContext(loader=get_object_loader()))
File "/Users/leopold/Applications/miniconda3/envs/aiida_rmq_py3/lib/python3.7/site-packages/plumpy/persistence.py", line 40, in __init__
self.update(savable.save(save_context))
File "/Users/leopold/Applications/miniconda3/envs/aiida_rmq_py3/lib/python3.7/site-packages/plumpy/persistence.py", line 504, in save
Savable._set_class_name(out_state, loader.identify_object(self.__class__))
File "/Users/leopold/Applications/miniconda3/envs/aiida_rmq_py3/lib/python3.7/site-packages/plumpy/loaders.py", line 62, in identify_object
self.load_object(identifier)
File "/Users/leopold/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/engine/persistence.py", line 52, in load_object
raise ImportError("object '{}' from identifier '{}' could not be loaded".format(name, identifier))
ImportError: object 'ListEcho' from identifier '__main__:ListEcho' could not be loaded
11/11/2019 12:16:29 PM <83083> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [ERROR] Exception trying to save checkpoint, this means you will not be able to restart in case of a crash until the next successful checkpoint.
Traceback (most recent call last):
File "/Users/leopold/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/engine/persistence.py", line 50, in load_object
return getattr(module, name)
AttributeError: module '__main__' has no attribute 'ListEcho'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/leopold/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/engine/persistence.py", line 83, in save_checkpoint
bundle = plumpy.Bundle(process, plumpy.LoadSaveContext(loader=get_object_loader()))
File "/Users/leopold/Applications/miniconda3/envs/aiida_rmq_py3/lib/python3.7/site-packages/plumpy/persistence.py", line 40, in __init__
self.update(savable.save(save_context))
File "/Users/leopold/Applications/miniconda3/envs/aiida_rmq_py3/lib/python3.7/site-packages/plumpy/persistence.py", line 504, in save
Savable._set_class_name(out_state, loader.identify_object(self.__class__))
File "/Users/leopold/Applications/miniconda3/envs/aiida_rmq_py3/lib/python3.7/site-packages/plumpy/loaders.py", line 62, in identify_object
self.load_object(identifier)
File "/Users/leopold/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/engine/persistence.py", line 52, in load_object
raise ImportError("object '{}' from identifier '{}' could not be loaded".format(name, identifier))
ImportError: object 'ListEcho' from identifier '__main__:ListEcho' could not be loaded
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/leopold/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/engine/processes/process.py", line 207, in _save_checkpoint
self.runner.persister.save_checkpoint(self)
File "/Users/leopold/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/engine/persistence.py", line 87, in save_checkpoint
"Failed to create a bundle for '{}': {}".format(process, traceback.format_exc())
plumpy.exceptions.PersistenceError: Failed to create a bundle for '<ListEcho> (ProcessState.RUNNING)': Traceback (most recent call last):
File "/Users/leopold/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/engine/persistence.py", line 50, in load_object
return getattr(module, name)
AttributeError: module '__main__' has no attribute 'ListEcho'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/leopold/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/engine/persistence.py", line 83, in save_checkpoint
bundle = plumpy.Bundle(process, plumpy.LoadSaveContext(loader=get_object_loader()))
File "/Users/leopold/Applications/miniconda3/envs/aiida_rmq_py3/lib/python3.7/site-packages/plumpy/persistence.py", line 40, in __init__
self.update(savable.save(save_context))
File "/Users/leopold/Applications/miniconda3/envs/aiida_rmq_py3/lib/python3.7/site-packages/plumpy/persistence.py", line 504, in save
Savable._set_class_name(out_state, loader.identify_object(self.__class__))
File "/Users/leopold/Applications/miniconda3/envs/aiida_rmq_py3/lib/python3.7/site-packages/plumpy/loaders.py", line 62, in identify_object
self.load_object(identifier)
File "/Users/leopold/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/engine/persistence.py", line 52, in load_object
raise ImportError("object '{}' from identifier '{}' could not be loaded".format(name, identifier))
ImportError: object 'ListEcho' from identifier '__main__:ListEcho' could not be loaded
{'output': <List: uuid: b0b0dc09-dc8f-4ed6-920a-8b36e5096593 (pk: 1835) value: [1, 2, 3]>}
@sphuber I'm not quite sure at which point this should be improved.
Perhaps somewhere down the line, there should be a check whether the module name is __main__
, and then point out that the process needs to be defined in a separate script?
I'm trying to run my first workchain on
provenance_redesign
.verdi devel tests db.work
runs fineBut I get the following types of errors:
The code I'm trying to run is the following (copied from
.ci/workflows.py
):