Substra / substra

Low-level Python library used to interact with a Substra network

Home Page:https://docs.substra.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue when listing testtuples in json format

AlexandrePicosson opened this issue · comments

Bug description
As a user I want to be able to have the output of substra list testtuple in json for further processing.
This should be done using the -o json flag which does not work and throw an exception.

To Reproduce
Steps to reproduce the behavior:

  1. Register some testtuples on the platform
  2. substra list testtuple -o json

Expected behavior
A json output of the testtuples registered on the platform.

Traceback

Traceback (most recent call last):
  File "/home/.venv/bin/substra", line 8, in <module>
    sys.exit(cli())
  File "/home/.venv/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/.venv/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/.venv/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/.venv/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/.venv/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/.venv/lib/python3.6/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/.venv/lib/python3.6/site-packages/substra/cli/interface.py", line 266, in wrapper
    return fn(*args, **kwargs)
  File "/home/.venv/lib/python3.6/site-packages/substra/cli/interface.py", line 994, in list_
    printer.print(dict_res, is_list=True)
  File "/home/.venv/lib/python3.6/site-packages/substra/cli/printers.py", line 241, in print
    print(json.dumps(data, indent=2))
  File "/usr/lib/python3.6/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.6/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/usr/lib/python3.6/json/encoder.py", line 428, in _iterencode
    yield from _iterencode_list(o, _current_indent_level)
  File "/usr/lib/python3.6/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib/python3.6/json/encoder.py", line 404, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.6/json/encoder.py", line 437, in _iterencode
    o = _default(o)
  File "/usr/lib/python3.6/json/encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'Type' is not JSON serializable

Substra:

  • Version: 0.8.0

Thanks for the detailed bug report @AlexandrePicosson, we are looking into it.