Skip to content

Only allow deserialization of KerasSaveables by module and name. #21429

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

Merged
merged 1 commit into from
Jun 29, 2025

Conversation

hertschuh
Copy link
Collaborator

Arbitrary functions and classes are not allowed.

  • Made Operation extend KerasSaveable, this required moving imports to avoid circular imports
  • Layer no longer need to extend KerasSaveable directly
  • Made feature space Cross and Feature extend KerasSaveable
  • Also dissallow public function enable_unsafe_deserialization

@hertschuh hertschuh marked this pull request as draft June 27, 2025 18:17
@codecov-commenter
Copy link

codecov-commenter commented Jun 27, 2025

Codecov Report

Attention: Patch coverage is 76.47059% with 8 lines in your changes missing coverage. Please review.

Project coverage is 82.72%. Comparing base (df58ec9) to head (c69516b).

Files with missing lines Patch % Lines
keras/src/saving/saving_lib.py 73.68% 3 Missing and 2 partials ⚠️
keras/src/saving/serialization_lib.py 33.33% 1 Missing and 1 partial ⚠️
keras/src/ops/operation.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21429      +/-   ##
==========================================
- Coverage   82.72%   82.72%   -0.01%     
==========================================
  Files         565      565              
  Lines       55222    55245      +23     
  Branches     8609     8612       +3     
==========================================
+ Hits        45683    45700      +17     
- Misses       7428     7433       +5     
- Partials     2111     2112       +1     
Flag Coverage Δ
keras 82.53% <76.47%> (-0.01%) ⬇️
keras-jax 63.34% <76.47%> (+<0.01%) ⬆️
keras-numpy 58.51% <50.00%> (-0.02%) ⬇️
keras-openvino 33.78% <29.41%> (-0.02%) ⬇️
keras-tensorflow 63.75% <76.47%> (+<0.01%) ⬆️
keras-torch 63.35% <50.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Arbitrary functions and classes are not allowed.

- Made `Operation` extend `KerasSaveable`, this required moving imports to avoid circular imports
- `Layer` no longer need to extend `KerasSaveable` directly
- Made feature space `Cross` and `Feature` extend `KerasSaveable`
- Also dissallow public function `enable_unsafe_deserialization`
@hertschuh hertschuh force-pushed the serialization_fix branch from fdf490e to c69516b Compare June 27, 2025 18:43
@hertschuh hertschuh marked this pull request as ready for review June 27, 2025 20:19
Copy link
Collaborator

@fchollet fchollet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Jun 29, 2025
@fchollet fchollet merged commit 713172a into keras-team:master Jun 29, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kokoro:force-run ready to pull Ready to be merged into the codebase size:M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants