NDArray doesn't handle types with custom core schemas properly
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 42/100
Research direction
Start by running the inline reproduction with NDArray[MyEnum], TypeAdapter, and the numpy array to confirm the serialization failure. Trace how NDArray handles classes with custom pydantic core schemas, then verify that ta_my_array.dump_json(my_array) serializes the MyEnum value successfully.
Written by the indexing model from the issue text.
Description
Describe the bug
NDArray type does not handle classes with custom pydantic core schemas properly
To Reproduce
# /// script
# dependencies = [
# "csp",
# "ccflow>=0.5.1",
# ]
# ///
from csp import Enum
from ccflow import NDArray
from pydantic import TypeAdapter
import numpy as np
class MyEnum(Enum):
X = Enum.auto()
Y = Enum.auto()
ta_my_array = TypeAdapter(NDArray[MyEnum])
my_array = ta_my_array.validate_python(np.array([MyEnum.X]))
print(f'{my_array = }')
print(ta_my_array.dump_json(my_array))
Expected behavior
This should serialize properly
Error Message
Reading inline script metadata from /test_ccflow.py
my_array = array([<MyEnum.X: 0>], dtype=object)
Traceback (most recent call last):
File "/test_ccflow.py", line 23, in
print(ta_my_array.dump_json(my_array))
File "pydantic/type_adapter.py", line 581, in dump_json
return self.serializer.to_json(
pydantic_core._pydantic_core.PydanticSerializationError: Error serializing to JSON: PydanticSerializationError: Unable to serialize unknown type: <class 'main.MyEnum'>
Runtime Environment
0.5.1
3.9.16 | packaged by conda-forge | (main, Feb 1 2023, 21:39:03)
[GCC 11.3.0]
linux
ccflow version 0.5.1
- Dominant language
- Python
- Stars
- 44
- Forks
- 7
- Avg merge
- 18h 20m
- Merged PRs (30d)
- 14
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Point72/ccflow
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
type: enhancement
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
Similar issues
-
[BUG] HTTP lifecycle dispatch treats a NO_PROXY-only environment as corporate egress and skips the resolve-and-pinned sessionPossibly taken @bodapatisaikrishna claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
external
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
langchain-ai/docs#7652 ·
Maintainers usually reply within 1 day
-
[oblt-aw][autodoc] Document new e2e-secret-leak-artifacts workflow and update e2e-all leaf listOpen
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
elastic/oblt-aw#2513 · 1 comment ·
Maintainers usually reply within 1 day
-
bug p2
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 75/100
NCAR/CLM-Tutorial#113 · 1 comment ·
Maintainers usually reply within 1 day