Skip to content

Commit

Permalink
Fix Filter Docs (#714)
Browse files Browse the repository at this point in the history
  • Loading branch information
czaloom authored Aug 22, 2024
1 parent 40f7b3b commit ab45038
Show file tree
Hide file tree
Showing 39 changed files with 388 additions and 16 deletions.
41 changes: 41 additions & 0 deletions client/valor/schemas/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,47 @@

@dataclass
class Filter:
"""
A data class that encapsulates filter conditions for various Valor components.
Attributes
----------
datasets : dict | FunctionType, optional
Filter conditions to apply to datasets.
models : dict | FunctionType, optional
Filter conditions to apply to models.
datums : dict | FunctionType, optional
Filter conditions to apply to datums.
annotations : dict | FunctionType, optional
Filter conditions to apply to annotations.
groundtruths : dict | FunctionType, optional
Filter conditions to apply to groundtruths.
predictions : dict | FunctionType, optional
Filter conditions to apply to predictions.
labels : dict | FunctionType, optional
Filter conditions to apply to labels.
embeddings : dict | FunctionType, optional
Filter conditions to apply to embeddings.
Examples
--------
Filter annotations by area and label.
>>> Filter(
... annotations=And(
... Label.key == "name",
... Annotation.raster.area > upper_bound,
... )
... )
Filter datums by annotations and labels.
>>> Filter(
... datums=And(
... Label.key == "name",
... Annotation.raster.area > upper_bound,
... )
... )
"""

datasets: Optional[Union[dict, FunctionType]] = None
models: Optional[Union[dict, FunctionType]] = None
datums: Optional[Union[dict, FunctionType]] = None
Expand Down
87 changes: 84 additions & 3 deletions client/valor/schemas/symbolic/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,35 @@ def to_dict(self):


class And(Function):
"""Implementation of logical AND (&)."""
"""
Implementation of logical AND (&).
This class represents a logical AND operation that can be performed on
two or more arguments. It supports chaining of multiple AND operations
using the `&` operator.
Parameters
----------
*args : Any
The arguments to be logically ANDed together. At least two arguments
are required.
Raises
------
ValueError
If fewer than two arguments are provided.
Examples
--------
>>> a = And(Label.key == "k1", Label.value == "v1")
>>> b = And(Label.key == "k1", Label.value == "v2")
>>> c = a & b
Methods
-------
__and__(other)
Supports chaining of multiple `And` operations using the `&` operator.
"""

def __init__(self, *args):
if len(args) < 2:
Expand All @@ -116,7 +144,34 @@ def __and__(self, other: Any):


class Or(Function):
"""Implementation of logical OR (|)."""
"""Implementation of logical OR (|).
This class represents a logical OR operation that can be performed on
two or more arguments. It supports chaining of multiple OR operations
using the `|` operator.
Parameters
----------
*args : Any
The arguments to be logically ORed together. At least two arguments
are required.
Raises
------
ValueError
If fewer than two arguments are provided.
Examples
--------
>>> a = Or(Label.key == "k1", Label.key == "k2")
>>> b = Or(Label.value == "v1", Label.value == "v2")
>>> c = a | b
Methods
-------
__or__(other)
Supports chaining of multiple `Or` operations using the `|` operator.
"""

def __init__(self, *args):
if len(args) < 2:
Expand All @@ -132,7 +187,33 @@ def __or__(self, other: Any):


class Not(Function):
"""Implementation of logical negation (~)."""
"""Implementation of logical negation (~).
This class represents a logical NOT operation that can be performed on
on a single arguments. It supports chaining of multiple NOT operations
using the `~` operator.
Parameters
----------
*args : Any
The arguments to be logically ORed together. At least two arguments
are required.
Raises
------
ValueError
If the number of args is not equal to one.
Examples
--------
>>> a = Not(Label.key == "k1")
>>> b = ~a
Methods
-------
__invert__()
Supports chaining of multiple `Not` operations using the `~` operator.
"""

def __init__(self, *args):
if len(args) != 1:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions docs/client_api/filtering/Conditions/Contains.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
::: valor.schemas.symbolic.operators.Contains
handler: python
options:
show_root_heading: false
show_root_toc_entry: false
show_root_full_path: true
show_root_members_full_path: false
show_object_full_path: true
show_category_heading: True
show_if_no_docstring: false
show_signature: true
show_signature_annotations: false
show_bases: true
group_by_category: true
heading_level: 2
members_order: alphabetical
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
::: valor.schemas.filters
::: valor.schemas.Gt
handler: python
options:
show_root_heading: false
Expand Down
16 changes: 16 additions & 0 deletions docs/client_api/filtering/Conditions/Gte.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
::: valor.schemas.Gte
handler: python
options:
show_root_heading: false
show_root_toc_entry: false
show_root_full_path: true
show_root_members_full_path: false
show_object_full_path: true
show_category_heading: True
show_if_no_docstring: false
show_signature: true
show_signature_annotations: false
show_bases: true
group_by_category: true
heading_level: 2
members_order: alphabetical
16 changes: 16 additions & 0 deletions docs/client_api/filtering/Conditions/Inside.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
::: valor.schemas.Inside
handler: python
options:
show_root_heading: false
show_root_toc_entry: false
show_root_full_path: true
show_root_members_full_path: false
show_object_full_path: true
show_category_heading: True
show_if_no_docstring: false
show_signature: true
show_signature_annotations: false
show_bases: true
group_by_category: true
heading_level: 2
members_order: alphabetical
16 changes: 16 additions & 0 deletions docs/client_api/filtering/Conditions/Intersects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
::: valor.schemas.Intersects
handler: python
options:
show_root_heading: false
show_root_toc_entry: false
show_root_full_path: true
show_root_members_full_path: false
show_object_full_path: true
show_category_heading: True
show_if_no_docstring: false
show_signature: true
show_signature_annotations: false
show_bases: true
group_by_category: true
heading_level: 2
members_order: alphabetical
16 changes: 16 additions & 0 deletions docs/client_api/filtering/Conditions/IsNotNull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
::: valor.schemas.IsNotNull
handler: python
options:
show_root_heading: false
show_root_toc_entry: false
show_root_full_path: true
show_root_members_full_path: false
show_object_full_path: true
show_category_heading: True
show_if_no_docstring: false
show_signature: true
show_signature_annotations: false
show_bases: true
group_by_category: true
heading_level: 2
members_order: alphabetical
16 changes: 16 additions & 0 deletions docs/client_api/filtering/Conditions/IsNull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
::: valor.schemas.IsNull
handler: python
options:
show_root_heading: false
show_root_toc_entry: false
show_root_full_path: true
show_root_members_full_path: false
show_object_full_path: true
show_category_heading: True
show_if_no_docstring: false
show_signature: true
show_signature_annotations: false
show_bases: true
group_by_category: true
heading_level: 2
members_order: alphabetical
16 changes: 16 additions & 0 deletions docs/client_api/filtering/Conditions/Lt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
::: valor.schemas.Lt
handler: python
options:
show_root_heading: false
show_root_toc_entry: false
show_root_full_path: true
show_root_members_full_path: false
show_object_full_path: true
show_category_heading: True
show_if_no_docstring: false
show_signature: true
show_signature_annotations: false
show_bases: true
group_by_category: true
heading_level: 2
members_order: alphabetical
16 changes: 16 additions & 0 deletions docs/client_api/filtering/Conditions/Lte.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
::: valor.schemas.Lte
handler: python
options:
show_root_heading: false
show_root_toc_entry: false
show_root_full_path: true
show_root_members_full_path: false
show_object_full_path: true
show_category_heading: True
show_if_no_docstring: false
show_signature: true
show_signature_annotations: false
show_bases: true
group_by_category: true
heading_level: 2
members_order: alphabetical
16 changes: 16 additions & 0 deletions docs/client_api/filtering/Conditions/Ne.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
::: valor.schemas.Ne
handler: python
options:
show_root_heading: false
show_root_toc_entry: false
show_root_full_path: true
show_root_members_full_path: false
show_object_full_path: true
show_category_heading: True
show_if_no_docstring: false
show_signature: true
show_signature_annotations: false
show_bases: true
group_by_category: true
heading_level: 2
members_order: alphabetical
16 changes: 16 additions & 0 deletions docs/client_api/filtering/Conditions/Outside.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
::: valor.schemas.Outside
handler: python
options:
show_root_heading: false
show_root_toc_entry: false
show_root_full_path: true
show_root_members_full_path: false
show_object_full_path: true
show_category_heading: True
show_if_no_docstring: false
show_signature: true
show_signature_annotations: false
show_bases: true
group_by_category: true
heading_level: 2
members_order: alphabetical
16 changes: 16 additions & 0 deletions docs/client_api/filtering/Filter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
::: valor.schemas.Filter
handler: python
options:
show_root_heading: false
show_root_toc_entry: false
show_root_full_path: true
show_root_members_full_path: false
show_object_full_path: true
show_category_heading: True
show_if_no_docstring: false
show_signature: true
show_signature_annotations: false
show_bases: true
group_by_category: true
heading_level: 2
members_order: alphabetical
16 changes: 16 additions & 0 deletions docs/client_api/filtering/Logic/And.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
::: valor.schemas.And
handler: python
options:
show_root_heading: false
show_root_toc_entry: false
show_root_full_path: true
show_root_members_full_path: false
show_object_full_path: true
show_category_heading: True
show_if_no_docstring: false
show_signature: true
show_signature_annotations: false
show_bases: true
group_by_category: true
heading_level: 2
members_order: alphabetical
16 changes: 16 additions & 0 deletions docs/client_api/filtering/Logic/Not.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
::: valor.schemas.Not
handler: python
options:
show_root_heading: false
show_root_toc_entry: false
show_root_full_path: true
show_root_members_full_path: false
show_object_full_path: true
show_category_heading: True
show_if_no_docstring: false
show_signature: true
show_signature_annotations: false
show_bases: true
group_by_category: true
heading_level: 2
members_order: alphabetical
16 changes: 16 additions & 0 deletions docs/client_api/filtering/Logic/Or.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
::: valor.schemas.Or
handler: python
options:
show_root_heading: false
show_root_toc_entry: false
show_root_full_path: true
show_root_members_full_path: false
show_object_full_path: true
show_category_heading: True
show_if_no_docstring: false
show_signature: true
show_signature_annotations: false
show_bases: true
group_by_category: true
heading_level: 2
members_order: alphabetical
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit ab45038

Please sign in to comment.