Skip to content

Buckets API

Bases: Client

HTTP Client for interacting with the Buckets backend.

Parameters:

Name Type Description Default
Client client

The base class for interacting with the backend.

required

Returns:

Name Type Description
Buckets

A client for interacting with the Buckets backend.

audit()

Audit work buckets backend.

The audit process retries failed work, expires any work past the expiration time and checks for any stale work older than 7 days.

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: The audit results.

delete_ids(ids)

Delete works from the buckets backend with the given ids.

Parameters:

Name Type Description Default
ids List[str]

The IDs of the works to delete.

required

Returns:

Name Type Description
bool bool

Whether the works were deleted successfully.

delete_many(pipeline, status=None, events=None, tags=None, parent=None, force=False, limit=100)

Delete works belonging to a pipeline from the buckets backend.

If a status is provided, only works with that status will be deleted. If an event number is provided, only works with that event will be deleted.

Parameters:

Name Type Description Default
pipeline str

The pipeline to delete works from.

required
status Optional[List[str]]

The status to delete works with. e.g. ["queued"].

None
event Optional[List[int]]

The event to delete works with.

required
force bool

Whether to force the deletion without requiring user confirmation. Defaults to False.

False
limit int

Limit of Work objects to remove. Defaults to False.

100

Returns:

Name Type Description
bool bool

Whether any works were deleted.

deposit(works, return_ids=False)

Deposit works into the buckets backend.

Parameters:

Name Type Description Default
works List[Dict[str, Any]]

The payload from the Work Object.

required
return_ids bool

Whether to return the ids of the works. Defaults to False.

False

Raises:

Type Description
RequestException

If the request fails.

Returns:

Type Description
Union[bool, List[str]]

Union[bool, List[str]]: Whether the request was successful or the ids of the works.

Examples:

from chime_frb_api.buckets import Buckets from chime_frb_api.tasks import Work work = Work(pipeline="sample") buckets.deposit([work.payload]) True buckets.deposit([work.payload], return_ids=True) ["5f9b5e1b7e5c4b5eb1b""]

info()

Get the version of the buckets backend.

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: The version of the buckets backend.

pipelines()

View the current pipelines in the buckets backend.

Returns:

Type Description
List[str]

List[str]: The current pipelines.

status(pipeline=None)

View the status of the buckets backend.

If overall is True, the status of all pipelines will be returned.

Parameters:

Name Type Description Default
pipeline Optional[str]

The pipeline to return the status of.

None

Returns:

Type Description
Dict[str, Any]

List[Dict[str, Any]]: The status of the buckets backend.

update(works)

Update works in the buckets backend.

Parameters:

Name Type Description Default
works List[Dict[str, Any]]

The payload from the Work Object.

required

Returns:

Name Type Description
bool bool

Whether the works were updated successfully.

view(query, projection={}, skip=0, limit=100)

View works in the buckets backend.

Parameters:

Name Type Description Default
query Dict[str, Any]

The query to filter the works with.

required
projection Dict[str, bool]

The projection to use to map the output.

{}
skip int

The number of works to skip. Defaults to 0.

0
limit Optional[int]

The number of works to limit to. Defaults to 100.

100

Returns:

Type Description
List[Dict[str, Any]]

List[Dict[str, Any]]: The works matching the query.

withdraw(pipeline, event=None, site=None, priority=None, user=None, tags=None, parent=None)

Withdraw queued work from the buckets backend.

Parameters:

Name Type Description Default
pipeline str | List[str]

The pipeline to withdraw work from.

required
event Optional[List[int]]

The event to filter by.

None
site Optional[str]

The site to filter by.

None
priority Optional[int]

The priority to withdraw from.

None
user Optional[str]

The user to filter by.

None
tags Optional[List[str]]

The tags to filter by.

None
parent Optional[str]

The parent to filter by.

None

Raises:

Type Description
RequestException

If the request fails.

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: The work withdrawn.