Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tiled[client] need pydantic #846

Closed
dylanmcreynolds opened this issue Jan 14, 2025 · 2 comments · Fixed by #863
Closed

tiled[client] need pydantic #846

dylanmcreynolds opened this issue Jan 14, 2025 · 2 comments · Fixed by #863

Comments

@dylanmcreynolds
Copy link
Contributor

On a fresh environment, installed tiled[client]. pip reports version 0.1.0b13.

client = [

Receive the following error:


Cell In[6], [line 1](vscode-notebook-cell:?execution_count=6&line=1)
----> [1](vscode-notebook-cell:?execution_count=6&line=1) smi['raw']

File ~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/client/container.py:338, in Container.__getitem__(self, keys, _ignore_inlined_contents)
    [336](https://file+.vscode-resource.vscode-cdn.net/home/dmcreynolds/dev/arroyoGISAXS/notebooks/~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/client/container.py:336)             item = content["data"]
    [337](https://file+.vscode-resource.vscode-cdn.net/home/dmcreynolds/dev/arroyoGISAXS/notebooks/~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/client/container.py:337)             break
--> [338](https://file+.vscode-resource.vscode-cdn.net/home/dmcreynolds/dev/arroyoGISAXS/notebooks/~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/client/container.py:338)     result = client_for_item(
    [339](https://file+.vscode-resource.vscode-cdn.net/home/dmcreynolds/dev/arroyoGISAXS/notebooks/~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/client/container.py:339)         self.context,
    [340](https://file+.vscode-resource.vscode-cdn.net/home/dmcreynolds/dev/arroyoGISAXS/notebooks/~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/client/container.py:340)         self.structure_clients,
    [341](https://file+.vscode-resource.vscode-cdn.net/home/dmcreynolds/dev/arroyoGISAXS/notebooks/~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/client/container.py:341)         item,
    [342](https://file+.vscode-resource.vscode-cdn.net/home/dmcreynolds/dev/arroyoGISAXS/notebooks/~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/client/container.py:342)         include_data_sources=self._include_data_sources,
    [343](https://file+.vscode-resource.vscode-cdn.net/home/dmcreynolds/dev/arroyoGISAXS/notebooks/~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/client/container.py:343)     )
    [344](https://file+.vscode-resource.vscode-cdn.net/home/dmcreynolds/dev/arroyoGISAXS/notebooks/~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/client/container.py:344) return result

File ~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/client/utils.py:181, in client_for_item(context, structure_clients, item, structure, include_data_sources)
    [179](https://file+.vscode-resource.vscode-cdn.net/home/dmcreynolds/dev/arroyoGISAXS/notebooks/~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/client/utils.py:179) specs = item["attributes"].get("specs", []) or []
    [180](https://file+.vscode-resource.vscode-cdn.net/home/dmcreynolds/dev/arroyoGISAXS/notebooks/~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/client/utils.py:180) for spec in specs:
--> [181](https://file+.vscode-resource.vscode-cdn.net/home/dmcreynolds/dev/arroyoGISAXS/notebooks/~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/client/utils.py:181)     class_ = structure_clients.get(spec["name"])
    [182](https://file+.vscode-resource.vscode-cdn.net/home/dmcreynolds/dev/arroyoGISAXS/notebooks/~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/client/utils.py:182)     if class_ is not None:
    [183](https://file+.vscode-resource.vscode-cdn.net/home/dmcreynolds/dev/arroyoGISAXS/notebooks/~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/client/utils.py:183)         break

File <frozen _collections_abc>:807, in get(self, key, default)
...
----> [8](https://file+.vscode-resource.vscode-cdn.net/home/dmcreynolds/dev/arroyoGISAXS/notebooks/~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/server/schemas.py:8) import pydantic.generics
      [9](https://file+.vscode-resource.vscode-cdn.net/home/dmcreynolds/dev/arroyoGISAXS/notebooks/~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/server/schemas.py:9) from pydantic import ConfigDict, Field, StringConstraints
     [10](https://file+.vscode-resource.vscode-cdn.net/home/dmcreynolds/dev/arroyoGISAXS/notebooks/~/miniconda3/envs/gisaxs/lib/python3.12/site-packages/tiled/server/schemas.py:10) from pydantic_core import PydanticCustomError

ModuleNotFoundError: No module named 'pydantic'
@danielballan
Copy link
Member

The dependency sneaked in when type hints were added, and imported some parts of tiled.server into modules that did not used to depend on it. I think the best solution is to rework to remove the dependency.

@DiamondJoseph
Copy link
Contributor

# All dependencies are optional; it depends on whether you are running
# a client or server (or both) and what data structures you care about.
# Use pip install tiled[all] to get everything.
dependencies = []

Is there reason to continue this? Minimal_client and minimal_server have overlapping requirements. I would add pydantic to these, and elevate them to core dependencies. Pydantic is our serialisation library for client/server communication.

# overlapping requirements of minimal_server, minimal_client
[
    "httpx >=0.20.0,!=0.23.1",
    "json-merge-patch",
    "jsonpatch",
    "jsonschema",
    "msgpack >=1.0.0",
    "orjson",
    "platformdirs",
    "pyyaml",
    "rich",
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants