Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passing unstored data node surfaces programming error in aiida-core #3511

Closed
ltalirz opened this issue Nov 4, 2019 · 3 comments · Fixed by #3513
Closed

passing unstored data node surfaces programming error in aiida-core #3511

ltalirz opened this issue Nov 4, 2019 · 3 comments · Fixed by #3513
Labels
Milestone

Comments

@ltalirz
Copy link
Member

ltalirz commented Nov 4, 2019

as discovered by @danieleongari, you can get an error message like this

 File "/home/daniele/anaconda3/envs/aiida1/lib/python3.6/site-packages/plumpy/process_states.py", line 220, in execute
    result = self.run_fn(*self.args, **self.kwargs)
  File "/home/daniele/aiida1/aiida_core/aiida/engine/processes/calcjobs/calcjob.py", line 261, in run
    upload_calculation(self.node, transport, calc_info, script_filename, dry_run=True)
  File "/home/daniele/aiida1/aiida_core/aiida/engine/daemon/execmanager.py", line 176, in upload_calculation
    handle.write(data_node.get_object_content(filename, mode='rb'))
UnboundLocalError: local variable 'data_node' referenced before assignment

when passing an unstored node as input to a builder like this:
https://github.com/danieleongari/aiida-raspa/blob/6ebe6117b6d28bbe655b4d33309c550b4ad35ee2/examples/simple_calculations/test_ff_files.py#L74-L79

In my view, there are two issues here:

  1. There's a minor programming error, where this should be under finally:
    with NamedTemporaryFile(mode='wb+') as handle:
    handle.write(data_node.get_object_content(filename, mode='rb'))
    handle.flush()
    handle.seek(0)
    transport.put(handle.name, target)
  2. For some reason, the node is not stored automatically when passed to the Process via the builder - to figure out why
@ltalirz
Copy link
Member Author

ltalirz commented Nov 4, 2019

@sphuber Do you happen to know the reason for 2.?

@sphuber
Copy link
Contributor

sphuber commented Nov 4, 2019

Most likely because he ran a dry_run with store_provenance=False.

Regarding the bug itself, it should not be in the finally but the else. If you were to put it in the finally it would also get there in case of the exception, i.e. the node could not be loaded. However, we might want to change this code, because this is essentially broken when running without provenance. We don't give very strong guarantees yet about running without provenance, but something could be said that it should at least work in combination with dry_run, in which case we recommend setting store_provenance=False. Essentially we would have to pass in the process inputs into the upload_calculation call, which should use them, instead of loading it by UUID to get the relevant data nodes used in the local_copy_list specifications. However, since the input space can be nested, finding the corresponding node will have to be done recursively. Think it can be done, but would be a bit ugly.

@ltalirz
Copy link
Member Author

ltalirz commented Nov 4, 2019

Regarding the bug itself, it should not be in the finally but the else

Hehe thanks ;-) turns out I had not understood what finally actually does.
I checked it and now I know more :-)

it should at least work in combination with dry_run, in which case we recommend setting store_provenance=False

I would agree...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants