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

[CHORE]: Move image kernel out of daft-core #2804

Merged
merged 13 commits into from
Sep 10, 2024

Conversation

universalmind303
Copy link
Collaborator

No description provided.

@github-actions github-actions bot added the chore label Sep 6, 2024
Copy link

codspeed-hq bot commented Sep 6, 2024

CodSpeed Performance Report

Merging #2804 will improve performances by ×2.8

Comparing universalmind303:move-image-kernel (44841fb) with main (7bee225)

Summary

⚡ 2 improvements
✅ 14 untouched benchmarks

Benchmarks breakdown

Benchmark main universalmind303:move-image-kernel Change
test_count[1 Small File] 24 ms 20.8 ms +14.97%
test_show[100 Small Files] 227.2 ms 80.4 ms ×2.8

Copy link
Contributor

@jaychia jaychia left a comment

Choose a reason for hiding this comment

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

There's going to be some conflicts with #2806 we should talk about first!

daft/daft/image.pyi Show resolved Hide resolved
src/daft-core/src/datatypes/image_mode.rs Outdated Show resolved Hide resolved
src/daft-image/src/lib.rs Outdated Show resolved Hide resolved
src/daft-image/src/series.rs Show resolved Hide resolved
src/daft-image/src/lib.rs Show resolved Hide resolved
use daft_core::datatypes::ExtensionArray;
use daft_core::{prelude::DataType, series::Series};

pub fn html_value(s: &Series, idx: usize) -> String {
Copy link
Contributor

Choose a reason for hiding this comment

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

#2806 moves some of the display functionality out, we should reconcile with that!

Copy link
Member

Choose a reason for hiding this comment

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

One of the patterns that I did in #2806 is that I made a StrValue trait. What if we do the same for HTMLValue and somehow register the HTML function (Datatype -> Function) for ImageArray from the image crate. Let's say with the inventory crate?

Copy link
Member

Choose a reason for hiding this comment

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

A benefit of that is that we can preserve html rendering for a series

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Initially, i was trying to make a HTMLValue trait but was running into some issues that I think were addressed in #2806. Will take another look!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@samster25 I took another look, and I don't think this is possible with our current architecture. We would have to fully move ImageArray out of core and into daft-image which comes with it's own host of problems, and is a SIGNIFICANTLY larger refactor.

the problem is that the html_value implementation relies on the image crate, which is the main thing we want to pull out of core.

I'm not super familiar with the inventory crate, but I don't see how it is supposed to solve the problem.

If the goal is to remove the daft-image -> daft-table dependency, we could simple move the repr_html logic into python, which needs all dependencies anyways.

}

pub fn data_array(&self) -> &ListArray {
const IMAGE_DATA_IDX: usize = 0;
Copy link
Member

Choose a reason for hiding this comment

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

WDYT about baking these const in the ImageArray itself since it's spanning across crates?

@@ -125,10 +125,6 @@ macro_rules! impl_series_like_for_logical_array {
self.0.str_value(idx)
}

fn html_value(&self, idx: usize) -> String {
Copy link
Member

Choose a reason for hiding this comment

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

how are we ensuring that we still have html_value if we drop this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can't ensure that we have html_value on Series, instead we have to call the html_value function defined in daft-table. The issue is that the ImageArray definition is still in core, but the html_value implementation needed to be moved to the daft-image crate, so this logic needs to now happen further up in a crate that has access to both core and daft-image.

use daft_core::datatypes::ExtensionArray;
use daft_core::{prelude::DataType, series::Series};

pub fn html_value(s: &Series, idx: usize) -> String {
Copy link
Member

Choose a reason for hiding this comment

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

One of the patterns that I did in #2806 is that I made a StrValue trait. What if we do the same for HTMLValue and somehow register the HTML function (Datatype -> Function) for ImageArray from the image crate. Let's say with the inventory crate?

use daft_core::datatypes::ExtensionArray;
use daft_core::{prelude::DataType, series::Series};

pub fn html_value(s: &Series, idx: usize) -> String {
Copy link
Member

Choose a reason for hiding this comment

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

A benefit of that is that we can preserve html rendering for a series

@@ -4,14 +4,21 @@ comfy-table = {workspace = true}
common-error = {path = "../common/error", default-features = false}
daft-core = {path = "../daft-core", default-features = false}
daft-dsl = {path = "../daft-dsl", default-features = false}
daft-image = {path = "../daft-image", default-features = false}
Copy link
Member

Choose a reason for hiding this comment

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

we can likely drop this, if we perform the trait + register pattern discussed above

Copy link
Member

@samster25 samster25 left a comment

Choose a reason for hiding this comment

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

LGTM! Nice work :)

@universalmind303 universalmind303 merged commit 3e2d25b into Eventual-Inc:main Sep 10, 2024
35 checks passed
@universalmind303 universalmind303 deleted the move-image-kernel branch September 10, 2024 19:04
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