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

Search experiments UI #288

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

Search experiments UI #288

wants to merge 1 commit into from

Conversation

Datron
Copy link
Collaborator

@Datron Datron commented Nov 20, 2024

Problem

Filtering and searching for experiments is not possible from the UI

Solution

Add support for filtering by experiment status, date, user who created it, experiment name or experiment ID

Screen.Recording.2024-12-12.at.3.50.41.PM.mov

@Datron Datron requested a review from a team as a code owner November 20, 2024 07:08
@Datron Datron force-pushed the search-experiments-ui branch from 836577f to f832429 Compare November 20, 2024 07:09
@Datron
Copy link
Collaborator Author

Datron commented Nov 20, 2024

dependent on #280

@Datron Datron force-pushed the search-experiments-ui branch 2 times, most recently from 4623eed to 5e4039e Compare November 20, 2024 12:06
#[serde(deserialize_with = "deserialize_stringified_list")] pub Vec<String>,
);

pub fn deserialize_stringified_list<'de, D, I>(
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we instead implement the Deserialize trait on StringArgs and write the logic in it instead of writing this as a function

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Examples for string array deserialization online use this method, it seems more verbose to implement deserialize here. We can though if needed

@@ -1,4 +1,4 @@
FROM public.ecr.aws/docker/library/postgres:12-alpine

COPY ./db_init.sql /docker-entrypoint-initdb.d/db_init.sql
# CMD ["postgres", "-c", "log_statement=all"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there any change here ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, I added this back for debugging

pub created_by: Option<StringArgs>,
pub context: Option<String>,
pub sort_on: Option<ExperimentSortOn>,
pub sort_by: Option<SortBy>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we want to have this as a separate filter ?
if so, then shouldn't we change it for context/list as well
there I had coupled sort_on and sort_by to a single enum list

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah we can do that, but it is out of scope of this PR

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ExpListFilters {
pub struct ExperimentListFilters {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ia this type not there in experimentation_platform for the api type ?

crates/frontend/src/components/table.rs Outdated Show resolved Hide resolved
crates/frontend/src/components/table.rs Outdated Show resolved Hide resolved
>
{column_name}
{
if current {
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is the meaning of the this current, I mean what does it signify ( I couldn't get it) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

current checks if this column is currently being sorted on, if it is - it will only show the up arrow or down arrow. If it is not, it will show both arrows

}
if let Some(ref context_search) = filters.context {
builder = builder.filter(
sql::<Bool>("context::text LIKE ")
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is this query doing here ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So the way we're storing contexts is like so:

{"and":[{"==":[{"var":"city"},"simple"]},{"==":[{"var":"vehicle_type"},"auto"]}]}

The query here is converting this (which is JSON in pg) to TEXT so we can use LIKE on it, for eg:

context::text LIKE '%{"==":[{"var":"city"},"simple"]}%'

Which would match any context that has city = simple as a dimension. It works for more than 1 dimension as well, where it does fail is if you specify vehicle=auto and city=simple but the experiment has city=simple and vehicle=auto (though city=simple or vehicle=auto would work). I want to see how folks use this feature, and if they encounter an issue I'll write the context search similar to how you've done it.

@Datron Datron force-pushed the search-experiments-ui branch from 3ea2b9b to afbb8df Compare December 12, 2024 10:54
@@ -134,11 +144,28 @@ pub struct ExperimentListFilters {
pub experiment_name: Option<String>,
pub experiment_ids: Option<String>,
pub created_by: Option<String>,
pub context: Option<String>,
pub context: Option<Value>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

the API is expecting String, why are we changing it to Value over here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Value is stringified when sent over, yes I am sending JSON in query params

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 change it later, I want to analyze how people use context search first

@@ -190,6 +518,12 @@ pub fn experiment_list() -> impl IntoView {
};
view! {
<ConditionCollapseProvider>
<div class="flex justify-start m-1">
Copy link
Collaborator

Choose a reason for hiding this comment

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

this div is not need here, it has only one child

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I need the flex and justify-start to align the button

}
>
<div class="card-body">
<div class="my-4">
Copy link
Collaborator

Choose a reason for hiding this comment

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

single child, div not needed, also can we please avoid using margins and model everything on paddings and gaps only, using margins is not very friendly for responsiveness

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

paddings and gaps only, using margins is not very friendly for responsiveness

What level of responsiveness are we looking for here? Also, can you share some resources that help me understand more about why padding and gaps are better than margins for responsiveness

</label>
<DateInput
id="experiment_from_date_input".into()
class="w-[19rem] flex-auto mt-3 mr-3".into()
Copy link
Collaborator

Choose a reason for hiding this comment

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

not commenting in all the places, but can we make sure that margins are totally avoided, at least whatever new code has been added

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@@ -33,21 +45,338 @@ struct CombinedResource {
default_config: Vec<DefaultConfig>,
}

#[component]
fn experiment_table_filter_widget(
Copy link
Collaborator

Choose a reason for hiding this comment

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

at some point, we should make this widget more generic, to simply take in structure and auto generate stuff

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed

@Datron Datron dismissed ayushjain17’s stale review December 17, 2024 06:51

replied to comments

@Datron Datron requested a review from ayushjain17 December 17, 2024 06:51
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