osrf / rocker

A tool to run docker containers with overlays and convenient options for things like GUIs etc.
Apache License 2.0
533 stars 68 forks source link

Cannot use --nvidia flag with updated empy==4.0 #259

Closed qw8z5fUB closed 7 months ago

qw8z5fUB commented 7 months ago

Hi there, I've noticed from my CI that fresh rocker installs are failing to run rocker with the --nvidia flag.

I've traced this back to a new empy release overnight, from version 3.3.4 to 4.0: https://pypi.org/project/empy/#history

I'm not sure if this is an empy bug, or a breaking API change requiring an update in rocker, in any case I'm logging a ticket here for awareness.

Here's how I reproduce the issue on Ubuntu 20.04.6 LTS, Python 3.8.10:

python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install rocker
rocker ros:humble --nvidia

This produces output:

Extension volume doesn't support default arguments. Please extend it.
Active extensions ['nvidia']
Step 1/6 : FROM golang:1.19 as detector
 ---> b47c7dfaaa93
Step 2/6 : RUN git clone -q https://github.com/dekobon/distro-detect.git &&     cd distro-detect &&     git checkout -q 5f5b9c724b9d9a117732d2a4292e6288905734e1 &&     CGO_ENABLED=0 go build .
 ---> Using cache
 ---> 12fcb20f77a7
Step 3/6 : FROM ros:humble
 ---> 83850d460372
Step 4/6 : COPY --from=detector /go/distro-detect/distro-detect /tmp/detect_os
 ---> a20d81fdf760
Step 5/6 : ENTRYPOINT [ "/tmp/detect_os", "-format", "json-one-line" ]
 ---> Running in 7699d168b43e
Removing intermediate container 7699d168b43e
 ---> 2b7f7c96c376
Step 6/6 : CMD [ "" ]
 ---> Running in 2b2116457cb6
Removing intermediate container 2b2116457cb6
 ---> 6f58212cced4
Successfully built 6f58212cced4
Successfully tagged rocker:os_detect_ros_humble
running,  docker run -it --rm 6f58212cced4
output:  {"name":"Ubuntu","id":"ubuntu","version":"22.04","lsb_release":{"DISTRIB_CODENAME":"jammy","DISTRIB_DESCRIPTION":"Ubuntu 22.04.2 LTS","DISTRIB_ID":"Ubuntu","DISTRIB_RELEASE":"22.04"},"os_release":{"BUG_REPORT_URL":"https://bugs.launchpad.net/ubuntu/","HOME_URL":"https://www.ubuntu.com/","ID":"ubuntu","ID_LIKE":"debian","NAME":"Ubuntu","PRETTY_NAME":"Ubuntu 22.04.2 LTS","PRIVACY_POLICY_URL":"https://www.ubuntu.com/legal/terms-and-policies/privacy-policy","SUPPORT_URL":"https://help.ubuntu.com/","UBUNTU_CODENAME":"jammy","VERSION":"22.04.2 LTS (Jammy Jellyfish)","VERSION_CODENAME":"jammy","VERSION_ID":"22.04"}}

Traceback (most recent call last):
  File "/tmp/venv/bin/rocker", line 8, in <module>
    sys.exit(main())
  File "/tmp/venv/lib/python3.8/site-packages/rocker/cli.py", line 64, in main
    dig = DockerImageGenerator(active_extensions, args_dict, base_image)
  File "/tmp/venv/lib/python3.8/site-packages/rocker/core.py", line 209, in __init__
    self.dockerfile = generate_dockerfile(active_extensions, self.cliargs, base_image)
  File "/tmp/venv/lib/python3.8/site-packages/rocker/core.py", line 343, in generate_dockerfile
    dockerfile_str += el.get_preamble(args_dict) + '\n'
  File "/tmp/venv/lib/python3.8/site-packages/rocker/nvidia_extension.py", line 119, in get_preamble
    return em.expand(preamble, self.get_environment_subs(cliargs))
  File "/tmp/venv/bin/em.py", line 5438, in expand
    interpreter = Interpreter(
  File "/tmp/venv/bin/em.py", line 4025, in __init__
    self.initialize(
  File "/tmp/venv/bin/em.py", line 4078, in initialize
    argv[0] = config.unknownScriptName
AttributeError: 'dict' object has no attribute 'unknownScriptName'

Package versions for the above error:

pip freeze
certifi==2023.11.17
charset-normalizer==3.3.2
docker==6.1.3
empy==4.0
idna==3.6
packaging==23.2
pexpect==4.9.0
pkg_resources==0.0.0
ptyprocess==0.7.0
requests==2.31.0
rocker==0.2.12
urllib3==2.1.0
websocket-client==1.6.4

Rolling back empy to the previous version resolves the issue:

pip install empy==3.3.4
tfoote commented 7 months ago

I have a fix in #260 if I can't find a full fix for compatibility, I'll merge that pinback short term and keep this open.

tfoote commented 7 months ago

Can you try out the fix in #261 on your system?

qw8z5fUB commented 7 months ago

Thanks, that's fixed it :+1:.

I ran:

python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install git+https://github.com/osrf/rocker.git@empy4_fixes

With that I am now able to run rocker with the nvidia flag: rocker ros:humble --nvidia

Pip freeze confirms I am in fact using empy 4:

certifi==2023.11.17
charset-normalizer==3.3.2
docker==6.1.3
empy==4.0
idna==3.6
packaging==23.2
pexpect==4.9.0
pkg_resources==0.0.0
ptyprocess==0.7.0
requests==2.31.0
rocker @ git+https://github.com/osrf/rocker.git@0e09053a4b808e49a3ac7a34667ff7a2397aec70
urllib3==2.1.0
websocket-client==1.7.0
tfoote commented 7 months ago

Thanks for verifying the fix!

qw8z5fUB commented 7 months ago

Oh, follow up question - would you consider updating the pypi release version to current main?

My CI is still failing because the current pypi release 0.2.12 does not include the empy fix.

Not sure how much hassle it is for you to push a new release.