Set "use_double_quotes"=True in ShellJob

Hi everybody,
until now I have been using an InstalledCode with use_double_quotes=True. As in:

code = InstalledCode(
    label='docker-something-local',
    computer=localhost,
    filepath_executable='/usr/local/bin/docker',
    default_calc_job_plugin='something',
    use_double_quotes=True,
)

I wanted to replace the Code and the CalcJob plugin with a ShellJob. I created a task:

hystmag_task = wg.add_task(
    "ShellJob",
    name='something',
    command='/usr/local/bin/docker',
    arguments=['run', '-v', '$(pwd):/io', 'something']
)

but of course this does not work without setting the double quotes option.

How can I make this work with the ShellJob?

Hi @andrea-petrocchi I am not quite sure how aiida-workgraph works, but as far as aiida-shell goes, under the hood a ShellJob still uses a Code instance as the code input. The launch_shell_job utility function just has some convenience functionality that transforms a str command to a Code instance. But you can also just manually create the Code and then pass that to launch_shell_job, or to the ShellJob process class when launching it manually.

@Xing does wg.add_task support passing a literal Code instance as input for command for the ShellJob task?

Yes, you can pass a Code instance to the command parameter in wg.add_task for a ShellJob task.

So, this should work:

code = InstalledCode(
    label='docker-something-local',
    computer=localhost,
    filepath_executable='/usr/local/bin/docker',
    default_calc_job_plugin='something',
    use_double_quotes=True,
)

hystmag_task = wg.add_task(
    "ShellJob",
    name='something',
    command=code,
    arguments=['run', '-v', '$(pwd):/io', 'something']
)

In fact, aiida-workgraph follows similar functionality as the launch_shell_job utility function from aiida-shell to prepare ShellJob tasks. Therefore, it should support the same features as documented in aiida-shell.

Thank you both! I made some confusion, and yes in fact this was more an aiida-workgraph question rather than a aiida-shell one, but your answers clarified that.

1 Like

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