osrf / rocker

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

Nvidia extension stopped working #155

Closed InigoMoreno closed 3 years ago

InigoMoreno commented 3 years ago

Running a simple rocker command with nvidia (rocker --nvidia ubuntu) yields the following error:

detect_os.py:1: DeprecationWarning: distro.linux_distribution() is deprecated. 
It should only be used as a compatibility shim with Python's platform.linux_distribution().
Please use distro.id(), distro.version() and distro.name() instead. 
InigoMoreno commented 3 years ago

See https://github.com/python-distro/distro/pull/296

InigoMoreno commented 3 years ago

A possible fix would be to force distro==1.5.0 in: https://github.com/osrf/rocker/blob/dc046c7d0965892d5dbb8156aefa8306c74fd4fb/src/rocker/os_detector.py#L32

tfoote commented 3 years ago

Can you clarify if you're seeing a warning or an error? This appears to be a deprecation warning that was added 26 days ago.

Also what platform and installation method are you using to be able to reproduce this error?

We should be able to move forward to the new syntax instead of pinning back. But there should be an overlap period long enough to cover all our supported platforms for them to deprecate the API which we should double check.

InigoMoreno commented 3 years ago

Can you clarify if you're seeing a warning or an error?

There is an error, click below for full traceback.

Full Traceback

``` Traceback (most recent call last): File "/home/inigo/.venv/rocker_venv/bin/rocker", line 11, in load_entry_point('rocker==0.2.3', 'console_scripts', 'rocker')() File "/home/inigo/.venv/rocker_venv/lib/python3.8/site-packages/rocker/cli.py", line 66, in main dig = DockerImageGenerator(active_extensions, args_dict, base_image) File "/home/inigo/.venv/rocker_venv/lib/python3.8/site-packages/rocker/core.py", line 208, in __init__ self.dockerfile = generate_dockerfile(active_extensions, self.cliargs, base_image) File "/home/inigo/.venv/rocker_venv/lib/python3.8/site-packages/rocker/core.py", line 334, in generate_dockerfile dockerfile_str += el.get_preamble(args_dict) + '\n' File "/home/inigo/.venv/rocker_venv/lib/python3.8/site-packages/rocker/nvidia_extension.py", line 99, in get_preamble return em.expand(preamble, self.get_environment_subs(cliargs)) File "/home/inigo/.venv/rocker_venv/lib/python3.8/site-packages/rocker/nvidia_extension.py", line 79, in get_environment_subs detected_os = detect_os(cliargs['base_image'], print, nocache=cliargs.get('nocache', False)) File "/home/inigo/.venv/rocker_venv/lib/python3.8/site-packages/rocker/os_detector.py", line 76, in detect_os _detect_os_cache[image_name] = literal_eval(output.strip()) File "/usr/lib/python3.8/ast.py", line 59, in literal_eval node_or_string = parse(node_or_string, mode='eval') File "/usr/lib/python3.8/ast.py", line 47, in parse return compile(source, filename, mode, flags, File "", line 1 detect_os.py:1: DeprecationWarning: distro.linux_distribution() is deprecated. It should only be used as a compatibility shim with Python's platform.linux_distribution(). Please use distro.id(), distro.version() and distro.name() instead. ^ SyntaxError: invalid syntax FAIL ```

Also what platform and installation method are you using to be able to reproduce this error?

Ubuntu 20.04 focal. Installed latest version with pip3 install git+https://github.com/osrf/rocker.git

We should be able to move forward to the new syntax instead of pinning back.

I think I know how to do that, should I create a merge request?

tfoote commented 3 years ago

Disabling caching I was able to reproduce the issue. The stretch image is much more current than I expected. I've patched it in #156 and landed it in main will plan to do a release tomorrow after some more QA. If you can validate that fix it would be great.

tfoote commented 3 years ago

Also I forgot to say thanks for the traceback and quick feedback as well as offering the fix. In the future that would be greatly appreciated. Your offer came in while I was finishing fixing it already.