Skip to content

Utilize polymorphic_serialization instead of Metaclass to adjust annotations#127

Open
NeejWeej wants to merge 7 commits intomainfrom
nk/serialize_as_any_updates
Open

Utilize polymorphic_serialization instead of Metaclass to adjust annotations#127
NeejWeej wants to merge 7 commits intomainfrom
nk/serialize_as_any_updates

Conversation

@NeejWeej
Copy link
Copy Markdown
Collaborator

@NeejWeej NeejWeej commented Oct 1, 2025

Utilize the polymorphic_serialization flag introduced in this PR:

pydantic/pydantic#12518

This PR will fail to build until a pydantic release has this feature in it.

@NeejWeej NeejWeej force-pushed the nk/serialize_as_any_updates branch from 781d7a1 to 31bdbb6 Compare October 31, 2025 20:02
@NeejWeej NeejWeej changed the base branch from pit/serialize_as_any to main October 31, 2025 20:06
Signed-off-by: Nijat Khanbabayev <nijat.khanbabayev@cubistsystematic.com>
@NeejWeej NeejWeej force-pushed the nk/serialize_as_any_updates branch from 31bdbb6 to 5367fd3 Compare October 31, 2025 20:27
Signed-off-by: Nijat Khanbabayev <nijat.khanbabayev@cubistsystematic.com>
@NeejWeej
Copy link
Copy Markdown
Collaborator Author

I think this is blocked by this: pydantic/pydantic#12382

Ex a build error. that occured:

E pydantic_core._pydantic_core.PydanticSerializationError: Unable to serialize unknown type: <class 'ccflow.tests.test_base_serialize.MyEnum'>

Even though MyEnum has a pydantic core schema defined (it's a ccflow enum)

Notably, the above issue states:
image

That first recommendation is what we currently do with the MetaClass, and apply the SerializeAsAny annotation to pydantic BaseModels here: https://github.com/Point72/ccflow/blob/main/ccflow/base.py#L117

image

It seems we can't move off of that until these issues are addressed

@NeejWeej NeejWeej changed the title Fix tests for serialize_as_any [WIP] Utilize serialize_as_any instead of Metaclass to adjust annotations Nov 2, 2025
@NeejWeej NeejWeej added the type: feature Feature requests label Nov 2, 2025
Signed-off-by: Nijat Khanbabayev <nijat.khanbabayev@cubistsystematic.com>
@NeejWeej NeejWeej force-pushed the nk/serialize_as_any_updates branch from ff8c9e3 to 1ac3bd8 Compare November 21, 2025 18:48
Signed-off-by: Nijat Khanbabayev <nijat.khanbabayev@cubistsystematic.com>
@NeejWeej NeejWeej changed the title [WIP] Utilize serialize_as_any instead of Metaclass to adjust annotations Utilize serialize_as_any instead of Metaclass to adjust annotations Nov 21, 2025
@NeejWeej NeejWeej changed the title Utilize serialize_as_any instead of Metaclass to adjust annotations Utilize polymorphic_serialization instead of Metaclass to adjust annotations Nov 21, 2025
@github-actions
Copy link
Copy Markdown
Contributor

Test Results

643 tests  +3   641 ✅ +3   1m 41s ⏱️ ±0s
  1 suites ±0     2 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 74c1ae8. ± Comparison against base commit cde4fbb.

This pull request removes 1 and adds 4 tests. Note that renamed tests count towards both.
ccflow.tests.test_base_serialize.TestBaseModelSerialization ‑ test_serialize_as_any
ccflow.tests.test_base_serialize.TestBaseModelSerialization ‑ test_serialization_nested_subclass_uses_duck_typing
ccflow.tests.test_evaluation_context_serialization ‑ test_mec_model_dump_basic
ccflow.tests.test_evaluation_context_serialization ‑ test_mec_model_dump_diamond_graph
ccflow.tests.test_evaluation_context_serialization ‑ test_mec_model_dump_with_multi_evaluator

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.02%. Comparing base (cde4fbb) to head (74c1ae8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #127      +/-   ##
==========================================
+ Coverage   95.96%   96.02%   +0.06%     
==========================================
  Files         140      141       +1     
  Lines        9680     9679       -1     
  Branches      563      551      -12     
==========================================
+ Hits         9289     9294       +5     
+ Misses        273      270       -3     
+ Partials      118      115       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@NeejWeej NeejWeej requested review from ptomecek and timkpaine April 13, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature Feature requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants