MLMI2-CSSI/foundry

Using quickstart example, the `Foundry.json()` method errors on DLHubClient not JSON serializable

Closed this issue · 2 comments

NOTE: This is related to JOSS review openjournals/joss-reviews#5467

Describe the bug
It appears the Foundry.json() for quick start in README currently raises an exception due to DLHubClient being unserializable

To Reproduce

  1. Use following script modified from quickstart README:
from foundry import Foundry
f = Foundry(index="mdf")
f = f.load("10.18126/e73h-3w6n")
f.json()
  1. Should see following traceback:
Traceback (most recent call last):
  File "/path/to/script.py", line 4, in <module>
    f.json()
  File "pydantic/main.py", line 504, in pydantic.main.BaseModel.json
  File "/.../python3.10/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/.../python3.10/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/.../python3.10/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "pydantic/json.py", line 90, in pydantic.json.pydantic_encoder
TypeError: Object of type 'DLHubClient' is not JSON serializable

Expected behavior
Foundry.json() to produce JSON from quickstart; possibly put a unit test around this?

Screenshots
N/A

Desktop (please complete the following information):

  • OS: Ubuntu 20.04
  • Version foundry-ml==0.6.3
  • Python Version 3.10

Additional context
Related, is there no way to get the version from the module?

import foundry
foundry.__version__

gives:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'foundry' has no attribute '__version__'

Found out version via a pip freeze instead

Related PR: #374

Updated Quickstart docs to reflect the proper usage; documentation has been deployed. I'll close this issue until further notice.