Skip to content

cmem_client.repositories.rule_blocks¤

Rule block repository.

Rule blocks are listed through the generic task search endpoint. Because TaskSearchRepository.fetch_data already requests task parameters, the search response carries the complete ruleBlockModel including the declared input ports, so no additional request is needed to report them.

Classes:

RuleBlockDeleteConfig¤

Bases: DeleteConfig

Rule block deletion configuration.

remove_dependent_tasks maps to the required removeDependentTasks query parameter of the task delete endpoint. When true, DataIntegration deletes every task that directly or indirectly references the rule block. When false, referencing tasks are left behind holding a dangling reference, which DataIntegration reports nowhere - callers are expected to check for dependents themselves before passing false.

Attributes:

model_config¤

model_config = ConfigDict(extra='allow', populate_by_name=True)

remove_dependent_tasks¤

remove_dependent_tasks: bool = False

RuleBlocksRepository¤

Bases: TaskSearchRepository, DeleteItemProtocol

Repository for rule blocks.

Functions:

  • create_item – Create a new rule block in a project.
  • delete_all – Delete all items from the repository
  • delete_item – Delete an item from the repository
  • evaluate – Evaluate a rule block against the input examples stored with it.
  • fetch_data – Fetch a list from the DI task search endpoint via a type adapter.
  • from_task_response – Reshape a task detail response into the canonical RuleBlock structure.
  • get_item – Get full rule block details including metadata timestamps.
  • get_task – Get full task details from the API.
  • items – Get the items of the repository
  • keys – Get the keys of the repository
  • update_item – Replace an existing rule block with the given one.
  • values – Get the values of the repository

Attributes:

  • logger (Logger) – Gets the client logger

create_item¤

create_item(item)

Create a new rule block in a project.

Parameters:

  • item (RuleBlock) – RuleBlock with project_id, id, metadata and optionally data.rule_block_model.

Returns:

  • RuleBlock – The created rule block, read back from the server.

Raises:

  • HTTPStatusError – If the creation request fails.

delete_all¤

delete_all()

Delete all items from the repository

delete_item¤

delete_item(key, skip_if_missing=False, configuration=None)

Delete an item from the repository

Parameters:

  • key (str) – The key of the item to delete
  • skip_if_missing (bool) – If True, it is ignored if the deleted item even exists
  • configuration (DeleteItemConfig) – Optional configuration for deletion

Raises:

evaluate¤

evaluate(project_id, rule_block_id, model)

Evaluate a rule block against the input examples stored with it.

Both the project and the rule block task must exist; the endpoint is task-scoped and there is no project-free evaluation mode.

Parameters:

  • project_id (str) – The project ID.
  • rule_block_id (str) – The rule block ID.
  • model (RuleBlockModel) – The rule block model to evaluate.

Returns:

  • list[Any] – One result entry per stored input example.

Raises:

  • HTTPStatusError – If the project or rule block does not exist.

fetch_data¤

fetch_data()

Fetch a list from the DI task search endpoint via a type adapter.

from_task_response¤

from_task_response(data)

Reshape a task detail response into the canonical RuleBlock structure.

The task detail endpoint nests the model under data.parameters. It is requested without labels, because with labels every parameter value is wrapped into an additional value object.

Parameters:

  • data (dict[str, Any]) – The JSON response of the task detail endpoint.

Returns:

  • RuleBlock – The rule block with the ruleBlockModel parameter moved under data.

get_item¤

get_item(project_id, rule_block_id)

Get full rule block details including metadata timestamps.

Parameters:

  • project_id (str) – The project ID.
  • rule_block_id (str) – The rule block ID.

Returns:

  • RuleBlock – RuleBlock model with the full model and metadata.

Raises:

  • HTTPStatusError – If the rule block is not found.

get_task¤

get_task(project_id, task_id, with_labels=True)

Get full task details from the API.

Parameters:

  • project_id (str) – The project ID.
  • task_id (str) – The task ID.
  • with_labels (bool) – Whether to include labels in the response.

Returns:

  • TaskResponse – The full task details as a TaskResponse model.

items¤

items()

Get the items of the repository

keys¤

keys()

Get the keys of the repository

logger¤

logger: logging.Logger

Gets the client logger

update_item¤

update_item(item)

Replace an existing rule block with the given one.

Parameters:

  • item (RuleBlock) – RuleBlock with project_id, id, metadata and data.rule_block_model.

Raises:

  • HTTPStatusError – If the update request fails.

values¤

values()

Get the values of the repository

Comments