Evaluate module

class Calculation(*, formula: str, alias: str)[source]

Bases: BaseModel

Model for creating a calculation to be used in evaluate endpoint.

Parameters:
  • formula (str) – The formula to be applied. Current legal calculations are found here.

  • alias (string) – A short alias to use in formulas as well as in the data frame results.

Example

>>> from pyclarify import Calculation

Creating a calculation assuming we have items with aliases “i1” and “i2”.

>>> calculation = Calculation(
...     formula="i1 + i2"
...     alias="c1"
... )

Creating a calculation using other calculations.

>>> calc1 = Calculation(
...     formula="i1 + i2"
...     alias="c1"
... )
>>> calc2 = Calculation(
...     formula="c1**2 + i1"
...     alias="c1"
... )
alias: str
formula: str
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'alias': FieldInfo(annotation=str, required=True, metadata=[_PydanticGeneralMetadata(pattern='^[A-Za-z_][A-Za-z0-9_]{0,27}$')]), 'formula': FieldInfo(annotation=str, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class GroupAggregation(*, query: ResourceQuery, timeAggregation: TimeAggregationMethod, groupAggregation: GroupAggregationMethod, state: int | None = None, lead: int | None = None, lag: int | None = None, alias: str)[source]

Bases: BaseModel

Model for creating a group aggregation to be used with the clarify.evaluate method.

Parameters:
  • query (ResourceQuery) – A query matching items to be added to the group.

  • timeAggregation (TimeAggregationMethod | str) – The time aggregation type to be done within items. Current legal aggregations are found here.

  • groupAggregation (GroupAggregationMethod | str) – The group aggregation type to be done across groups. Current legal aggregations are found here.

  • state (int[0:9999]) – The integer denoting the state to be used in the aggregation. Only necessary when using state based aggregation.

  • lead (int[-1000:1000]) – Shift buckets backwards by N.

  • lag (int[-1000:1000]) – Shift buckets forwards by N.

  • alias (str) – A short alias to use in formulas as well as in the data frame results.

Example

>>> from pyclarify import GroupAggregation

Creating a minimal group aggregation.

>>> group_aggregation = GroupAggregation(
...     query=ResourceQuery(filter={}),
...     timeAggregation="max",
...     groupAggregationMethod="max"
...     alias="g1"
... )

Creating a group aggregation with all attributes set.

>>> group_aggregation = GroupAggregation(
...     query=ResourceQuery(filter={}),
...     timeAggregationMethod="max",
...     groupAggregationMethod="max",
...     state=1,
...     lead=1,
...     lag=1,
...     alias="g1"
... )
alias: str
groupAggregation: GroupAggregationMethod
lag: int | None
lead: int | None
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'alias': FieldInfo(annotation=str, required=True, metadata=[_PydanticGeneralMetadata(pattern='^[A-Za-z_][A-Za-z0-9_]{0,27}$')]), 'groupAggregation': FieldInfo(annotation=GroupAggregationMethod, required=True), 'lag': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Ge(ge=-1000), Le(le=1000)])], NoneType], required=False), 'lead': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Ge(ge=-1000), Le(le=1000)])], NoneType], required=False), 'query': FieldInfo(annotation=ResourceQuery, required=True), 'state': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Ge(ge=0), Lt(lt=10000)])], NoneType], required=False), 'timeAggregation': FieldInfo(annotation=TimeAggregationMethod, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

query: ResourceQuery
state: int | None
timeAggregation: TimeAggregationMethod
class ItemAggregation(*, id: str, aggregation: TimeAggregationMethod, state: int | None = None, lead: int | None = None, lag: int | None = None, alias: str)[source]

Bases: BaseModel

Model for creating an item aggregation to be used with the clarify.evaluate method.

Parameters:
  • id (ResourceID) – The ID of the item to be aggregated.

  • aggregation (TimeAggregationMethod | str) – The aggregation type to be done. Current legal aggregations are found here.

  • state (int[0:9999]) – The integer denoting the state to be used in the aggregation. Only necessary when using state based aggregation.

  • lead (int[-1000:1000]) – Shift buckets backwards by N.

  • lag (int[-1000:1000]) – Shift buckets forwards by N.

  • alias (str) – A short alias to use in formulas as well as in the data frame results.

Example

>>> from pyclarify import ItemAggregation

Creating a minimal item aggregation.

>>> item_aggregation = ItemAggregation(
...     id="cbpmaq6rpn52969vfl0g",
...     aggregation="max",
...     alias="i2"
... )

Creating an item aggregation with all attributes set.

>>> item_aggregation = ItemAggregation(
...     id="cbpmaq6rpn52969vfl00",
...     aggregation="max",
...     state=1,
...     lead=1,
...     lag=1,
...     alias="i1"
... )
aggregation: TimeAggregationMethod
alias: str
id: str
lag: int | None
lead: int | None
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'aggregation': FieldInfo(annotation=TimeAggregationMethod, required=True), 'alias': FieldInfo(annotation=str, required=True, metadata=[_PydanticGeneralMetadata(pattern='^[A-Za-z_][A-Za-z0-9_]{0,27}$')]), 'id': FieldInfo(annotation=str, required=True, metadata=[_PydanticGeneralMetadata(pattern='^[a-v0-9]{20}$')]), 'lag': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Ge(ge=-1000), Le(le=1000)])], NoneType], required=False), 'lead': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Ge(ge=-1000), Le(le=1000)])], NoneType], required=False), 'state': FieldInfo(annotation=Union[Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Ge(ge=0), Lt(lt=10000)])], NoneType], required=False)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

state: int | None