sphuber / aiida-shell

AiiDA plugin that makes running shell commands easy.
MIT License
14 stars 7 forks source link

How to specify output file which is not in the jobs working directory? #86

Closed bilke closed 6 months ago

bilke commented 6 months ago

I have a shell job which produces some output files in a specific directory which is not the working directory of the job, e.g. /data/foo/bar.txt. I specify this when running launch_shell_job(..., outputs=['/data/foo/bar.txt']) but get the following error:

Warning: output parser returned exit code<303>: One or more output files defined in the `outputs` input were not retrieved: bar.txt.

I think it is because of https://github.com/sphuber/aiida-shell/blob/31ebfbcde77f30a34a5495f349c19424d8dc1984/src/aiida_shell/parsers/shell.py#L123.

Do you think it is possible to specify an absolute output file path? Thanks for your help!

sphuber commented 6 months ago

The problem is not really with the code that you highlighted, but rather in aiida-core. Currently it only allows a CalcJob implementation to specify files to retrieve within the working directory. However, I think the following work around may work for you:

launch_shell_job(
    ...,
    outputs=['bar.txt'],
    metadata={
        'options': {
            'append_text': 'ln -s /data/foo/bar.txt bar.txt',
        }
    }
)

The append_text are bash commands that are added to the submit script after the main command. So you can use it to create a soft link inside the working directory to the target file. The file can then be retrieved through the relative filename.

Let me know if that works.

bilke commented 6 months ago

Yes this works, thanks!