Skip to content

Commit

Permalink
Filtering and sorting (#3230)
Browse files Browse the repository at this point in the history
* first checkpoint

* second checkpoint

* formatting and linting

* Auto-update of LLM Finetuning template

* Auto-update of Starter template

* Auto-update of E2E template

* Auto-update of NLP template

* Auto-update of LLM Finetuning template

* Auto-update of Starter template

* Auto-update of E2E template

* Auto-update of NLP template

* formatting

* fixing the failing cli integration tests

* adjusting the models

* consistency check

* formatting

---------

Co-authored-by: GitHub Actions <[email protected]>
  • Loading branch information
bcdurak and actions-user authored Dec 13, 2024
1 parent 96034f9 commit f738d66
Show file tree
Hide file tree
Showing 25 changed files with 609 additions and 494 deletions.
46 changes: 44 additions & 2 deletions src/zenml/client.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
from zenml.step_operators import BaseStepOperator

if TYPE_CHECKING:
from zenml.config.base_settings import BaseSettings
from zenml.config.step_run_info import StepRunInfo
from zenml.models import PipelineDeploymentBase

Expand Down
20 changes: 12 additions & 8 deletions src/zenml/models/v2/base/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ class BaseFilter(BaseModel):
le=PAGE_SIZE_MAXIMUM,
description="Page size",
)

id: Optional[Union[UUID, str]] = Field(
default=None,
description="Id for this resource",
Expand Down Expand Up @@ -491,13 +490,13 @@ def validate_sort_by(cls, value: Any) -> Any:
)
value = column

if column in cls.FILTER_EXCLUDE_FIELDS:
if column in cls.CUSTOM_SORTING_OPTIONS:
return value
elif column in cls.FILTER_EXCLUDE_FIELDS:
raise ValueError(
f"This resource can not be sorted by this field: '{value}'"
)
elif column in cls.model_fields:
return value
elif column in cls.CUSTOM_SORTING_OPTIONS:
if column in cls.model_fields:
return value
else:
raise ValueError(
Expand Down Expand Up @@ -759,7 +758,7 @@ def offset(self) -> int:
return self.size * (self.page - 1)

def generate_filter(
self, table: Type[SQLModel]
self, table: Type["AnySchema"]
) -> Union["ColumnElement[bool]"]:
"""Generate the filter for the query.
Expand All @@ -779,7 +778,7 @@ def generate_filter(
filters.append(
column_filter.generate_query_conditions(table=table)
)
for custom_filter in self.get_custom_filters():
for custom_filter in self.get_custom_filters(table):
filters.append(custom_filter)
if self.logical_operator == LogicalOperators.OR:
return or_(False, *filters)
Expand All @@ -788,12 +787,17 @@ def generate_filter(
else:
raise RuntimeError("No valid logical operator was supplied.")

def get_custom_filters(self) -> List["ColumnElement[bool]"]:
def get_custom_filters(
self, table: Type["AnySchema"]
) -> List["ColumnElement[bool]"]:
"""Get custom filters.
This can be overridden by subclasses to define custom filters that are
not based on the columns of the underlying table.
Args:
table: The query table.
Returns:
A list of custom filters.
"""
Expand Down
Loading

0 comments on commit f738d66

Please sign in to comment.