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

Fix serialization of pydantic.BaseModel fields with pathlib.Path dict keys #1157

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Commits on Oct 31, 2024

  1. Fix orjson serialization of dict keys

    Apply `_simple_default` serialization on dict keys to resolve this exception
    
    ```python
    Traceback (most recent call last):
      File "/Users/brendan/.local/share/virtualenvs/core-bRkH1-KB/lib/python3.11/site-packages/langsmith/client.py", line 281, in _dumps_json_single
        return orjson.dumps(
               ^^^^^^^^^^^^^
    TypeError: Dict key must a type serializable with OPT_NON_STR_KEYS
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/Users/brendan/.local/share/virtualenvs/core-bRkH1-KB/lib/python3.11/site-packages/langsmith/client.py", line 5802, in _tracing_thread_handle_batch
        client.multipart_ingest_runs(create=create, update=update, pre_sampled=True)
      File "/Users/brendan/.local/share/virtualenvs/core-bRkH1-KB/lib/python3.11/site-packages/langsmith/client.py", line 1675, in multipart_ingest_runs
        valb = _dumps_json(value)
               ^^^^^^^^^^^^^^^^^^
      File "/Users/brendan/.local/share/virtualenvs/core-bRkH1-KB/lib/python3.11/site-packages/langsmith/client.py", line 321, in _dumps_json
        return _dumps_json_single(obj, _serialize_json)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/brendan/.local/share/virtualenvs/core-bRkH1-KB/lib/python3.11/site-packages/langsmith/client.py", line 292, in _dumps_json_single
        result = json.dumps(
                 ^^^^^^^^^^^
      File "/usr/local/Cellar/python@3.11/3.11.10/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 238, in dumps
        **kw).encode(obj)
              ^^^^^^^^^^^
      File "/usr/local/Cellar/python@3.11/3.11.10/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 200, in encode
        chunks = self.iterencode(o, _one_shot=True)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/Cellar/python@3.11/3.11.10/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 258, in iterencode
        return _iterencode(o, 0)
               ^^^^^^^^^^^^^^^^^
    TypeError: keys must be str, int, float, bool or None, not PosixPath
    ```
    brendanator committed Oct 31, 2024
    Configuration menu
    Copy the full SHA
    ce68109 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5e37fe0 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    97b098d View commit details
    Browse the repository at this point in the history
  4. remove dead code

    brendanator committed Oct 31, 2024
    Configuration menu
    Copy the full SHA
    586eb4f View commit details
    Browse the repository at this point in the history

Commits on Nov 1, 2024

  1. Configuration menu
    Copy the full SHA
    4c6545e View commit details
    Browse the repository at this point in the history

Commits on Nov 5, 2024

  1. Configuration menu
    Copy the full SHA
    604affc View commit details
    Browse the repository at this point in the history
  2. update tests

    brendanator committed Nov 5, 2024
    Configuration menu
    Copy the full SHA
    8432823 View commit details
    Browse the repository at this point in the history