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

Guess image_mimetype for ImageNode #17422

Merged
merged 4 commits into from
Jan 4, 2025

Conversation

nerdai
Copy link
Contributor

@nerdai nerdai commented Jan 4, 2025

Description

This PR introduces a couple of enhancements when working with ImageNode's:

  1. It guesses the image_mimetype field from image_path if provided. (This is somewhat breaking as before we were guessing the mimetype from the path)
  2. Similar to TextNode we add forward-compatibility by enabling construction via a image media resource type.

Also, I made an implementation change for validating data and mimetype fields of a MediaResource. Specifically, I opt to use field_validator over model_validator to be able to handle the validation of these two separate fields "separately".

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Your pull-request will likely not be merged unless it is covered by some form of impactful unit testing.

  • I added new unit tests to cover this change

@nerdai nerdai requested a review from masci January 4, 2025 04:57
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jan 4, 2025
@nerdai nerdai requested a review from logan-markewich January 4, 2025 04:57
Copy link
Collaborator

@logan-markewich logan-markewich left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks @nerdai 🫡

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 4, 2025
@logan-markewich logan-markewich merged commit 64963e9 into main Jan 4, 2025
11 checks passed
@logan-markewich logan-markewich deleted the nerdai/fix-image-node-mimetype-guess branch January 4, 2025 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants