Skip to content

Conversation

@zeke
Copy link
Member

@zeke zeke commented Oct 24, 2025

UPDATE: Moving this back to draft pending an internal discussion about whether this change is actually needed.

This PR filters out None-valued inputs from all prediction and training creation methods before making API requests.

Changes

  • Add filter_none_values() utility function to recursively remove None values from dictionaries
  • Update encode_json() and async_encode_json() to filter None values when processing dicts
  • Apply filtering to deployments.predictions.create() and trainings.create() methods
  • Add comprehensive test suite for None filtering functionality

Example

Before:

replicate.use("black-forest-labs/flux-schnell")(prompt="banana", seed=None)
# Would send: {"prompt": "banana", "seed": null}

After:

replicate.use("black-forest-labs/flux-schnell")(prompt="banana", seed=None)
# Now sends: {"prompt": "banana"}

This preserves the legacy behavior where None-valued inputs are automatically removed before making API requests, preventing potential API errors.

Fixes https://linear.app/replicate/issue/DP-737

This PR filters out None-valued inputs from all prediction and training
creation methods before making API requests. This preserves legacy
behavior and prevents potential API errors when users pass None values.

Changes:
- Add filter_none_values() utility function to recursively remove None
  values from dictionaries
- Update encode_json() and async_encode_json() to filter None values
  when processing dicts
- Apply filtering to deployments.predictions.create() and
  trainings.create() methods
- Add comprehensive test suite for None filtering functionality

Fixes https://linear.app/replicate/issue/DP-737
@zeke zeke requested a review from a team as a code owner October 24, 2025 21:35
@zeke zeke marked this pull request as draft October 27, 2025 16:47
@zeke
Copy link
Member Author

zeke commented Oct 27, 2025

Red herring. Closing.

Screenshot 2025-10-27 at 10 27 26

@zeke zeke closed this Oct 27, 2025
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 this pull request may close these issues.

2 participants