Creating Docker Code issue with quotes

Dear All,

I build my docker image with my external code. I would like to make AiiDA to run it. I followed the instruction in the manual, where an example setup is shown:

verdi code create core.code.containerized \
    --non-interactive \
    --label containerized-code \
    --computer some-computer \
    --filepath-executable "/bin/sh" \
    --image-name "docker://alpine:3" \
    --engine-command "singularity exec --bind $PWD:$PWD {image_name}"

So far it is straight forward. However, I had an issue running my code, when I checked _aiidasubmit.sh I mediatelly saw where the problem is:

'docker' 'run' '-v' '$(pwd):/data' 'pq-aiida' '/bin/entrypoint.sh' < 'aiida.inp' > 'aiida-pq2.out'`

Since I want to mount the local directory into my container, I need to resolve $(pwd), but in that case I need double quotes not single. So I checked the documentation. There are two option that seams relevant: wrap_cmdline_params and use_double_quotes. So set them to (false,false), (true,false), (false,true) and (true,true) and non of the option actually could resolve my problem of $(pwd) being in single quotes as you can see on the respective results:

'docker' 'run' '-v' '$(pwd):/data' 'pq-aiida' '/bin/entrypoint.sh' < 'aiida.inp' > 'aiida-pq2.out'
'docker' 'run' '-v' '$(pwd):/data' 'pq-aiida' "'/bin/entrypoint.sh' < 'aiida.inp' > 'aiida-pq2.out' "
'docker' 'run' '-v' '$(pwd):/data' 'pq-aiida' "/bin/entrypoint.sh" < 'aiida.inp' > 'aiida-pq2.out'
'docker' 'run' '-v' '$(pwd):/data' 'pq-aiida' ""'"'"/bin/entrypoint.sh"'"'" < 'aiida.inp' > 'aiida-pq2.out' "

Last one is somewhat crazy, anyway, my quostion is how can I force AiiDA to use single quotes in order to mount mount my local directory to the container?

Hi @addman,
There is also double quote setup in computer setup, I think that what you need.

Last one is somewhat crazy.

Sorry for that, it escaped multiple times, but I am sure not matter how it escaped, it will run as expected in your case. If you use the double quotes for computer, the last one might a bit less crazy.

Dear @jusong.yu,

Isn’t what I am invoking with use_double_quotes? However this affects only the commands after the engine command. As you can see in my second result:

'docker' 'run' '-v' '$(pwd):/data' 'pq-aiida' "'/bin/entrypoint.sh' < 'aiida.inp' > 'aiida-pq2.out' "

That is the setting on the Code instance, but there is also the likely named property on the Computer. I think it is that what @jusong.yu is referring to. You can set it as follows:

In [1]: c = load_computer('localhost')

In [2]: c.get_use_double_quotes()
Out[2]: False

In [3]: c.set_use_double_quotes(True)

Change localhost with the name of your computer of course

1 Like

@sphuber thanks I just found it code and computer have its own double_quotes settings, as it can be seen here.