Skip to content

feat: expose image attribute as expression #4848

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Jay-ju
Copy link
Contributor

@Jay-ju Jay-ju commented Jul 25, 2025

Changes Made

Related Issues

Checklist

  • Documented in API Docs (if applicable)
  • Documented in User Guide (if applicable)
  • If adding a new documentation page, doc is added to docs/mkdocs.yml navigation
  • Documentation builds and is formatted properly (tag @/ccmao1130 for docs review)

Copy link

codecov bot commented Jul 25, 2025

Codecov Report

❌ Patch coverage is 71.42857% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.18%. Comparing base (0129008) to head (07ea9c5).

Files with missing lines Patch % Lines
src/daft-image/src/ops.rs 46.34% 22 Missing ⚠️
src/daft-image/src/series.rs 41.66% 7 Missing ⚠️
src/daft-image/src/functions/attribute.rs 84.61% 4 Missing ⚠️
src/daft-schema/src/image_property.rs 85.18% 4 Missing ⚠️
daft/__init__.py 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4848      +/-   ##
==========================================
- Coverage   79.59%   79.18%   -0.41%     
==========================================
  Files         917      919       +2     
  Lines      127014   127139     +125     
==========================================
- Hits       101094   100674     -420     
- Misses      25920    26465     +545     
Files with missing lines Coverage Δ
daft/expressions/expressions.py 95.80% <100.00%> (+0.02%) ⬆️
src/daft-core/src/array/image_array.rs 98.31% <100.00%> (+0.18%) ⬆️
src/daft-core/src/lit/conversions.rs 62.24% <ø> (ø)
src/daft-image/src/functions/mod.rs 100.00% <100.00%> (ø)
src/daft-schema/src/python/mod.rs 100.00% <100.00%> (ø)
daft/__init__.py 25.00% <0.00%> (ø)
src/daft-image/src/functions/attribute.rs 84.61% <84.61%> (ø)
src/daft-schema/src/image_property.rs 85.18% <85.18%> (ø)
src/daft-image/src/series.rs 77.86% <41.66%> (-3.66%) ⬇️
src/daft-image/src/ops.rs 66.29% <46.34%> (-3.62%) ⬇️

... and 13 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -5154,6 +5154,18 @@ def to_mode(self, mode: str | ImageMode) -> Expression:
f = native.get_function_from_registry("to_mode")
return Expression._from_pyexpr(f(self._expr, mode=image_mode))

def attribute(self, name: str) -> Expression:
Copy link
Contributor

Choose a reason for hiding this comment

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

since we know what attributes are available, use a Literal['width', 'height', 'channel', 'mode'] for better typings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good

@@ -194,6 +195,31 @@ impl ImageOps for ImageArray {
.collect();
image_array_from_img_buffers(self.name(), &buffers, Some(mode))
}

fn attribute(&self, attr: &str) -> DaftResult<DataArray<UInt32Type>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use an Enum to model the attributes instead of the &str

@universalmind303
Copy link
Contributor

@Jay-ju what's the status on this PR? I think once those two small changes are implemented, we could merge this one in!

@Jay-ju Jay-ju force-pushed the image_attribute branch 4 times, most recently from a72a431 to 367bfd9 Compare August 14, 2025 09:50
@Jay-ju
Copy link
Contributor Author

Jay-ju commented Aug 14, 2025

@Jay-ju what's the status on this PR? I think once those two small changes are implemented, we could merge this one in!

@universalmind303 so sorry, I've been busy with other matters these few weeks. Some updates have been made here. Please take a look when you have time.

@Jay-ju
Copy link
Contributor Author

Jay-ju commented Aug 14, 2025

image code style is confused. run local success.

@srilman
Copy link
Contributor

srilman commented Aug 14, 2025

@Jay-ju how are you running pre-commit locally?

@Jay-ju
Copy link
Contributor Author

Jay-ju commented Aug 15, 2025

@Jay-ju how are you running pre-commit locally?

image

@srilman
When executing make precommit locally, an error occurs. However, in the CI, if the comment # type: ignore[type-arg] in Embedding = np.typing.NDArray # type: ignore[type-arg] is deleted, an error will occur, so this comment is retained here.

If simply executing pre-commit run --all-files, it is successful locally, but an error occurs in the CI, and the reason for the error is not displayed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants