sempy_labs.surge_protection package

Module contents

sempy_labs.surge_protection.delete_background_operation_rules(capacity: str | UUID = None)

Deletes the background operation surge protection rules for the specified capacity.

Background Operations

When total CU consumption reaches the rejection threshold, reject new background operation requests. When total CU consumption drops below the recovery threshold, accept new background operation requests.

Parameters:

capacity (str | uuid.UUID, default=None) – The capacity name or ID. Defaults to None which resolves to the capacity id of the workspace of the attached lakehouse or if no lakehouse attached, resolves to the capacity name of the workspace of the notebook.

sempy_labs.surge_protection.delete_workspace_consumption_rules(capacity: str | UUID = None)

Deletes the workspace consumption surge protection rules for the specified capacity.

Workspace Consumption

When total CU consumption by a single workspace reaches the rejection threshold, reject new operation requests and block the workspace for the specified amount of time.

Parameters:

capacity (str | uuid.UUID, default=None) – The capacity name or ID. Defaults to None which resolves to the capacity id of the workspace of the attached lakehouse or if no lakehouse attached, resolves to the capacity name of the workspace of the notebook.

sempy_labs.surge_protection.get_background_operation_rules(capacity: str | UUID = None, return_dataframe: bool = True) DataFrame | dict

Retrieves the background operation surge protection rules for the specified capacity.

Background Operations

When total CU consumption reaches the rejection threshold, reject new background operation requests. When total CU consumption drops below the recovery threshold, accept new background operation requests.

Parameters:

capacity (str | uuid.UUID, default=None) – The capacity name or ID. Defaults to None which resolves to the capacity id of the workspace of the attached lakehouse or if no lakehouse attached, resolves to the capacity name of the workspace of the notebook.

Returns:

A pandas dataframe showing the background operation surge protection rules for the specified capacity, or a dictionary if return_dataframe is set to False.

Return type:

pandas.DataFrame | dict

sempy_labs.surge_protection.get_workspace_consumption_rules(capacity: str | UUID = None, return_dataframe: bool = True) DataFrame | dict

Retrieves the workspace consumption surge protection rules for the specified capacity.

Workspace Consumption

When CU consumption by a single workspace reaches the rejection threshold, reject new operation requests and block the workspace for the specified amount of time.

Parameters:

capacity (str | uuid.UUID, default=None) – The capacity name or ID. Defaults to None which resolves to the capacity id of the workspace of the attached lakehouse or if no lakehouse attached, resolves to the capacity name of the workspace of the notebook.

Returns:

A pandas dataframe showing the workspace consumption surge protection rules for the specified capacity, or a dictionary if return_dataframe is set to False.

Return type:

pandas.DataFrame | dict

sempy_labs.surge_protection.set_background_operation_rules(capacity: str | UUID = None, rejection_threshold: int = 75, recovery_threshold: int = 25) dict

Sets the background operation surge protection rules for the specified capacity.

Background Operations

When total CU consumption reaches the rejection threshold, reject new background operation requests. When total CU consumption drops below the recovery threshold, accept new background operation requests.

Parameters:
  • capacity (str | uuid.UUID, default=None) – The capacity name or ID. Defaults to None which resolves to the capacity id of the workspace of the attached lakehouse or if no lakehouse attached, resolves to the capacity name of the workspace of the notebook.

  • rejection_threshold (int, default=75) – The CU consumption percentage threshold (1-100) at which new background operation requests will be rejected.

  • recovery_threshold (int, default=25) – The CU consumption percentage threshold (5-100) at which new background operation requests will be accepted.

Returns:

A dictionary showing the background operation surge protection rules for the specified capacity.

Return type:

dict

sempy_labs.surge_protection.set_workspace_consumption_rules(capacity: str | UUID = None, rejection_threshold: int = 75, block_duration_hours: int = 24, block_indefinitely: bool = False) dict

Sets the workspace consumption surge protection rules for the specified capacity.

Workspace Consumption

When total CU consumption by a single workspace reaches the rejection threshold, reject new operation requests and block the workspace for the specified amount of time.

Parameters:
  • capacity (str | uuid.UUID, default=None) – The capacity name or ID. Defaults to None which resolves to the capacity id of the workspace of the attached lakehouse or if no lakehouse attached, resolves to the capacity name of the workspace of the notebook.

  • rejection_threshold (int, default=75) – The CU consumption percentage threshold (1-100) at which new operation requests will be rejected.

  • block_duration_hours (int, default=24) – The duration in hours to block the workspace when the rejection threshold is reached. Must be at least 1 hour. Ignored if block_indefinitely is set to True.

  • block_indefinitely (bool, default=False) – If True, the workspace will be blocked indefinitely when the rejection threshold is reached.

Returns:

A dictionary showing the workspace consumption surge protection rules for the specified capacity.

Return type:

dict