gabrieldemarmiesse / python-on-whales

An awesome Python wrapper for an awesome Docker CLI!
MIT License
537 stars 100 forks source link

latest python on whales fails with docker buildx 0.13 #567

Closed Buillaume closed 5 months ago

Buillaume commented 5 months ago

Hi :) it seems that there's an incompatibility issue between python_on_whales and latest buildx version

Here's my setup

➜  ~ pip freeze | grep whales
python-on-whales==0.70.0
➜  ~ docker buildx version
github.com/docker/buildx v0.13.0 0de5f1c
➜  ~ docker buildx ls     
NAME/NODE     DRIVER/ENDPOINT   STATUS    BUILDKIT   PLATFORMS
default*      docker                                 
 \_ default    \_ default       running   v0.12.5    linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/386

Here's the error, note that with docker buildx 0.12.0 I don't have the problem

➜  ~ ipython
Python 3.10.4 (main, Sep 26 2023, 17:53:19) [GCC 11.4.0]
In [1]: from python_on_whales import docker

In [2]: docker.buildx.list()
Out[2]: ---------------------------------------------------------------------------
DockerException                           Traceback (most recent call last)
File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/IPython/core/formatters.py:708, in PlainTextFormatter.__call__(self, obj)
    701 stream = StringIO()
    702 printer = pretty.RepresentationPrinter(stream, self.verbose,
    703     self.max_width, self.newline,
    704     max_seq_length=self.max_seq_length,
    705     singleton_pprinters=self.singleton_printers,
    706     type_pprinters=self.type_printers,
    707     deferred_pprinters=self.deferred_printers)
--> 708 printer.pretty(obj)
    709 printer.flush()
    710 return stream.getvalue()

File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/IPython/lib/pretty.py:393, in RepresentationPrinter.pretty(self, obj)
    390 for cls in _get_mro(obj_class):
    391     if cls in self.type_pprinters:
    392         # printer registered in self.type_pprinters
--> 393         return self.type_pprinters[cls](obj, self, cycle)
    394     else:
    395         # deferred printer
    396         printer = self._in_deferred_types(cls)

File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/IPython/lib/pretty.py:640, in _seq_pprinter_factory.<locals>.inner(obj, p, cycle)
    638         p.text(',')
    639         p.breakable()
--> 640     p.pretty(x)
    641 if len(obj) == 1 and isinstance(obj, tuple):
    642     # Special case for 1-item tuples.
    643     p.text(',')

File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/IPython/lib/pretty.py:410, in RepresentationPrinter.pretty(self, obj)
    407                         return meth(obj, self, cycle)
    408                 if cls is not object \
    409                         and callable(cls.__dict__.get('__repr__')):
--> 410                     return _repr_pprint(obj, self, cycle)
    412     return _default_pprint(obj, self, cycle)
    413 finally:

File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/IPython/lib/pretty.py:778, in _repr_pprint(obj, p, cycle)
    776 """A pprint that just redirects to the normal repr function."""
    777 # Find newlines and replace them with p.break_()
--> 778 output = repr(obj)
    779 lines = output.splitlines()
    780 with p.group():

File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/python_on_whales/components/buildx/cli_wrapper.py:72, in Builder.__repr__(self)
     71 def __repr__(self):
---> 72     return f"python_on_whales.Builder(name='{self.name}', driver='{self.driver}')"

File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/python_on_whales/components/buildx/cli_wrapper.py:61, in Builder.driver(self)
     59 @property
     60 def driver(self) -> str:
---> 61     return self._get_inspect_result().driver

File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/python_on_whales/client_config.py:217, in ReloadableObject._get_inspect_result(self)
    215 def _get_inspect_result(self):
    216     if self._needs_reload():
--> 217         self.reload()
    218     return self._inspect_result

File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/python_on_whales/client_config.py:209, in ReloadableObject.reload(self)
    207 def reload(self):
    208     self._set_inspect_result(
--> 209         self._fetch_and_parse_inspect_result(self._immutable_id)
    210     )

File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/python_on_whales/components/buildx/cli_wrapper.py:52, in Builder._fetch_and_parse_inspect_result(self, reference)
     50 if reference is not None:
     51     full_cmd.append(reference)
---> 52 inspect_str = run(full_cmd)
     53 return BuilderInspectResult.from_str(inspect_str)

File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/python_on_whales/utils.py:194, in run(args, capture_stdout, capture_stderr, input, return_stderr, env, tty)
    186         if "no such volume" in decoded_stderr:
    187             raise NoSuchVolume(
    188                 args,
    189                 completed_process.returncode,
    190                 completed_process.stdout,
    191                 completed_process.stderr,
    192             )
--> 194     raise DockerException(
    195         args,
    196         completed_process.returncode,
    197         completed_process.stdout,
    198         completed_process.stderr,
    199     )
    201 if return_stderr:
    202     return (
    203         post_process_stream(completed_process.stdout),
    204         post_process_stream(completed_process.stderr),
    205     )

DockerException: The docker command executed was `/usr/bin/docker buildx inspect default*`.
It returned with code 1
The content of stdout is ''
The content of stderr is 'ERROR: no builder "default*" found
'
gabrieldemarmiesse commented 5 months ago

Thank you for the bug report. It seems that they change the convention around the inspection of the default builder. I'll take a look at it when I have the time.

If someone wants to investigate too that would be a huge help :)

On Tue, 12 Mar 2024, 12:39 Guillaume Bertrand, @.***> wrote:

Hi :) it seems that there's an incompatibility issue between python_on_whales and latest buildx version

Here's my setup

➜ ~ pip freeze | grep whalespython-on-whales==0.70.0 ➜ ~ docker buildx versiongithub.com/docker/buildx v0.13.0 0de5f1c ➜ ~ docker buildx ls NAME/NODE DRIVER/ENDPOINT STATUS BUILDKIT PLATFORMSdefault* docker _ default _ default running v0.12.5 linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/386

Here's the error, note that with docker buildx 0.12.0 I don't have the problem

➜ ~ ipythonPython 3.10.4 (main, Sep 26 2023, 17:53:19) [GCC 11.4.0]In [1]: from python_on_whales import docker In [2]: docker.buildx.list()Out[2]: ---------------------------------------------------------------------------DockerException Traceback (most recent call last)File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/IPython/core/formatters.py:708, in PlainTextFormatter.call(self, obj) 701 stream = StringIO() 702 printer = pretty.RepresentationPrinter(stream, self.verbose, 703 self.max_width, self.newline, 704 max_seq_length=self.max_seq_length, 705 singleton_pprinters=self.singleton_printers, 706 type_pprinters=self.type_printers, 707 deferred_pprinters=self.deferred_printers)--> 708 printer.pretty(obj) 709 printer.flush() 710 return stream.getvalue() File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/IPython/lib/pretty.py:393, in RepresentationPrinter.pretty(self, obj) 390 for cls in _get_mro(obj_class): 391 if cls in self.type_pprinters: 392 # printer registered in self.type_pprinters--> 393 return self.type_pprinters[cls](obj, self, cycle) 394 else: 395 # deferred printer 396 printer = self._in_deferred_types(cls) File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/IPython/lib/pretty.py:640, in _seq_pprinter_factory..inner(obj, p, cycle) 638 p.text(',') 639 p.breakable()--> 640 p.pretty(x) 641 if len(obj) == 1 and isinstance(obj, tuple): 642 # Special case for 1-item tuples. 643 p.text(',') File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/IPython/lib/pretty.py:410, in RepresentationPrinter.pretty(self, obj) 407 return meth(obj, self, cycle) 408 if cls is not object \ 409 and callable(cls.dict.get('repr')):--> 410 return _repr_pprint(obj, self, cycle) 412 return _default_pprint(obj, self, cycle) 413 finally: File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/IPython/lib/pretty.py:778, in _reprpprint(obj, p, cycle) 776 """A pprint that just redirects to the normal repr function.""" 777 # Find newlines and replace them with p.break()--> 778 output = repr(obj) 779 lines = output.splitlines() 780 with p.group(): File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/python_on_whales/components/buildx/cli_wrapper.py:72, in Builder.repr(self) 71 def repr(self):---> 72 return f"python_on_whales.Builder(name='{self.name}', driver='{self.driver}')" File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/python_on_whales/components/buildx/cli_wrapper.py:61, in Builder.driver(self) 59 @property 60 def driver(self) -> str:---> 61 return self._get_inspect_result().driver File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/python_on_whales/client_config.py:217, in ReloadableObject._get_inspect_result(self) 215 def _get_inspect_result(self): 216 if self._needs_reload():--> 217 self.reload() 218 return self._inspect_result File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/python_on_whales/client_config.py:209, in ReloadableObject.reload(self) 207 def reload(self): 208 self._set_inspect_result(--> 209 self._fetch_and_parse_inspect_result(self._immutable_id) 210 ) File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/python_on_whales/components/buildx/cli_wrapper.py:52, in Builder._fetch_and_parse_inspect_result(self, reference) 50 if reference is not None: 51 full_cmd.append(reference)---> 52 inspect_str = run(full_cmd) 53 return BuilderInspectResult.from_str(inspect_str) File ~/.pyenv/versions/3.10.4/envs/py310/lib/python3.10/site-packages/python_on_whales/utils.py:194, in run(args, capture_stdout, capture_stderr, input, return_stderr, env, tty) 186 if "no such volume" in decoded_stderr: 187 raise NoSuchVolume( 188 args, 189 completed_process.returncode, 190 completed_process.stdout, 191 completed_process.stderr, 192 )--> 194 raise DockerException( 195 args, 196 completed_process.returncode, 197 completed_process.stdout, 198 completed_process.stderr, 199 ) 201 if return_stderr: 202 return ( 203 post_process_stream(completed_process.stdout), 204 post_process_stream(completed_process.stderr), 205 ) DockerException: The docker command executed was /usr/bin/docker buildx inspect default*.It returned with code 1The content of stdout is ''The content of stderr is 'ERROR: no builder "default*" found '

— Reply to this email directly, view it on GitHub https://github.com/gabrieldemarmiesse/python-on-whales/issues/567, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADCLMK5URFP6TF7FDLUNYNLYX3SOZAVCNFSM6AAAAABESBYVZWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGE4DCNBQGI4TKMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

gabrieldemarmiesse commented 5 months ago

@Buillaume can you test on your side with pip install git+https://github.com/gabrieldemarmiesse/python-on-whales.git and tell me if that works?

Buillaume commented 5 months ago

works like a charm many thanks !!