Skip to content

fix for TypeError: Object of type PosixPath is not JSON serializable

Charles Girardot requested to merge pullover_fix_path into master

fix for following error got when trying pullover:

[17:42:08] {/Users/girardot/git/labid-cli/cli/__main__.py:117} ERROR - An unexpected error occurred during execution
Traceback (most recent call last):
  File "/Users/girardot/git/labid-cli/cli/__main__.py", line 115, in main
    app(prog_name=__app_name__)
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/typer/main.py", line 328, in __call__
    raise e
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/typer/main.py", line 311, in __call__
    return get_command(self)(*args, **kwargs)
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/typer/core.py", line 778, in main
    return _main(
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/typer/core.py", line 216, in _main
    rv = self.invoke(ctx)
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/typer/main.py", line 683, in wrapper
    return callback(**use_params)  # type: ignore
  File "/Users/girardot/git/labid-cli/cli/transfer.py", line 284, in transfer_assay_dir
    transfer_with_dma(hostname=hostname, dir_to_transfer=dir, delete_original=delete_original,
  File "/Users/girardot/git/labid-cli/cli/transfer.py", line 378, in transfer_with_dma
    assay_id, data = transfer_with_dma_pullover(
  File "/Users/girardot/git/labid-cli/cli/transfer.py", line 434, in transfer_with_dma_pullover
    result_data: Data = dma_client.request_pullover(
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/dma_client/client.py", line 32, in login_required
    return method(*args, **kwargs)
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/dma_client/client.py", line 373, in request_pullover
    resp = self.session.post('/data/pullover', json=payload)  # type: ignore
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/requests/sessions.py", line 635, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/dma_client/client.py", line 52, in request
    return super().request(method, url, *args, headers=headers, **kwargs)
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/requests/sessions.py", line 573, in request
    prep = self.prepare_request(req)
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/requests/sessions.py", line 484, in prepare_request
    p.prepare(
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/requests/models.py", line 371, in prepare
    self.prepare_body(data, files, json)
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/site-packages/requests/models.py", line 511, in prepare_body
    body = complexjson.dumps(json, allow_nan=False)
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/Users/girardot/mambaforge-pypy3/envs/labid-cli/lib/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type PosixPath is not JSON serializable

Merge request reports

Loading