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

instance.run_command not working + Client.execute problem #213

Open
EricDeveaud opened this issue Dec 7, 2023 · 8 comments
Open

instance.run_command not working + Client.execute problem #213

EricDeveaud opened this issue Dec 7, 2023 · 8 comments

Comments

@EricDeveaud
Copy link
Contributor

EricDeveaud commented Dec 7, 2023

Hello,

while testing singularity-cli I encountered a problem with instance.run_command method.
see:

from spython.main import Client
a = Client.instance('/my/image.sif', name='foo')
a.run_command(['ls'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/gensoft/adm/share/gensoft/spython/utils/terminal.py", line 186, in run_command
    cmd = _process_sudo_cmd(cmd, sudo, sudo_options)
  File "/opt/gensoft/adm/share/gensoft/spython/utils/terminal.py", line 30, in _process_sudo_cmd
    cmd = ["sudo"] + cmd
TypeError: can only concatenate list (not "Instance") to list

I tested instance.run_command method as I have a problem with Client.execute method

I have a singularity image that I need to test if it have nv support at runtime. from a different process than the one that instanciated it.

remember instance a was instanciated WITHOUT nv support in process1 but...
in process2
NB as expected instance.option is not available from different process

from spython.main import Client
foo = Client.instances('foo')
Client.execute(foo, ['nvidia-smi'], return_result=True)['return_code']
0
```
I was expecting anything but 0 ;-)

## Context

[provide more detailed introduction to the issue itself . This is for make a reproducible issue.]
* Operating System:
```
cat /etc/os-release
NAME="Red Hat Enterprise Linux"
VERSION="8.8 (Ootpa)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Red Hat Enterprise Linux 8.8 (Ootpa)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:8::baseos"
HOME_URL="https://www.redhat.com/"
DOCUMENTATION_URL="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_BUGZILLA_PRODUCT_VERSION=8.8
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.8"
```
* singularity version:

singularity --version
apptainer version 1.2.4-1.el8

* spython version: 0.3.11

* python version: 

python3 --version
Python 3.8.1


@vsoch
Copy link
Member

vsoch commented Dec 7, 2023

Let's start with the first issue posted above, which is fixed here #214 (pending your testing and approval) then (from that branch) let's update the thread here (or open a new issue) with a specific way to reproduce your second. Thanks!

@EricDeveaud
Copy link
Contributor Author

#214 tested and it ran smoothly.

thanks for the fix.

eric

@vsoch
Copy link
Member

vsoch commented Dec 8, 2023

Merged! If you want to install the master branch, and test again and update the issue for the second item, I'll have some time tomorrow or this weekend to work on it (going to bed now). Thanks!

@EricDeveaud
Copy link
Contributor Author

great.

I'm currently playing some tests in order to check the second problem.

PS have a good night ;-)

Eric

@EricDeveaud
Copy link
Contributor Author

I guess I miss-use or at least does not understand the diffrences beetween Client.execute(instance, [cmd]) and `instance.run_command([cmd])

see:

>>> from spython.main import Client
>>> a = Client.instance('/my/image.sif', name='foo', options=['--hostname', 'bar'])
>>> a.run_command(['hostname'])
'maestro-builder\n'
>>> Client.execute(a, ['hostname'])
'bar\n'

NB of course:
from the shell using the instance satrted from spython

singularity exec instance://foo hostname
bar

does it looks accurate for you ?
in my mind as run_command is an instance method, I was expecting the command to be run from the instance

@EricDeveaud
Copy link
Contributor Author

and finally problem 2 is not a problem...
it was on my side.

adding --contain to the instance solved the pb.
sorry for the noise

eric

@vsoch
Copy link
Member

vsoch commented Dec 8, 2023

No worries! So execute is supposed to minic singularity exec. And run_command was previously a more hidden helper command to (one off) run a random command, but not inside the container (to the system). I do think it would be more intuitive if this current run_command was an exec to the instance, and then the current was moved back to be a helper (hidden) function. I am happy to test this out and open another PR if you agree.

@EricDeveaud
Copy link
Contributor Author

yep agree. seems more logical

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

No branches or pull requests

2 participants