Skip to content

Workflow Results

You can use the Results API to perform actions such as fetching, viewing, updating, locking and deleting results from the database, along with many other actions.

Usage

You can instantiate the Results object to interact with the API.

Python
from workflow.http.context import HTTPContext

ResultsContext = HTTPContext(backends=["results"])

results = ResultsContext.results
Once this is done, all of the methods listed below will be available on the results object. For example, you can call a method like this:

Python
results.get_by_count('header-localization', 10)

Methods

Bases: Client

HTTP Client for interacting with the Results backend.

Parameters:

Name Type Description Default
Client client

The base class for interacting with the backend.

required

Returns:

Name Type Description
Results

A client for interacting with the Buckets backend.

count(pipeline, query)

Get count of results filtered by the query.

Parameters:

Name Type Description Default
pipeline str

Name of pipeline.

required
query Dict[str, Any]

MongoDB query.

required

Returns:

Name Type Description
int int

The number of results that match the query.

delete_ids(pipeline, ids)

Delete results from the results backend.

Parameters:

Name Type Description Default
pipeline str

Name of pipeline.

required
ids List[str]

The IDs of the works to delete.

required

Returns:

Name Type Description
bool bool

Whether the results were deleted successfully.

deposit(works)

Deposit works into the results backend.

Parameters:

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

A list of payloads from Work Objects.

required
Note

This method is not intended for direct use by the user. Work status must be 'success' or 'failure'.

Raises:

Type Description
AssertionError

If work status is not 'success' or 'failure'.

Returns:

Type Description
Dict[str, bool]

Dict[str, bool]: Dictionary of deposit results for each pipeline.

Examples:

from workflow.http.results import Results from workflow.definitions.work import Work results = Results() work = Work.withdraw(pipeline="test) work.status = "success" status = results.deposit([work.payload])

get_by_count(pipeline, count=10)

Get results by count from the specified pipeline.

Parameters:

Name Type Description Default
pipeline str

The name of the pipeline.

required
count int

The number of results to get. Defaults to 10.

10

Returns:

Type Description
List[Dict[str, Any]]

List[Dict[str, Any]]: Retrieved results.

get_by_event(pipeline, event_number)

Get work filtered by event number from the results backend.

Parameters:

Name Type Description Default
pipeline str

The name of the pipeline.

required
event_number int

The event number of the event.

required

Returns:

Type Description
List[Dict[str, Any]]

List[Dict[str, Any]]: Retrieved results.

get_by_id(pipeline, ids)

Get results by ID from the specified pipeline.

Parameters:

Name Type Description Default
pipeline str

The name of the pipeline.

required
ids List[str]

The IDs of the results to get.

required

Returns:

Type Description
List[Dict[str, Any]]

List[Dict[str, Any]]: Retrieved results.

get_locked(pipeline, skip=0, count=10)

Get work that is locked from the results backend.

Parameters:

Name Type Description Default
pipeline str

The name of the pipeline.

required
skip int

The number of results to skip. Defaults to 0.

0
count int

The maximum number of results. Defaults to 10.

10
Note

Only results with valid results, plots and products are returned.

Returns:

Type Description
List[Dict[str, Any]]

List[Dict[str, Any]]: A list of the locked results.

get_locked_count(pipeline)

Retrieves the count of locked results.

Parameters:

Name Type Description Default
pipeline str

The name of the pipeline.

required

Returns:

Name Type Description
int int

The count of locked results.

info()

Get the version of the results backend.

Returns:

Type Description
Dict[str, Any]

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

lock(pipeline, ids)

Lock results.

Note

A locked result cannot be deleted or updated.

Parameters:

Name Type Description Default
pipeline str

The name of the pipeline.

required
ids List[str]

The IDs of the results to lock.

required

Returns:

Name Type Description
Boolean bool

True if successful, False if not.

status()

Get the status of the results backend.

Returns:

Type Description
Dict[str, int]

Dict[str, int]: The status of the results backend.

unlock(pipeline, ids, force=False)

Unlock results.

Parameters:

Name Type Description Default
pipeline str

The pipeline name.

required
ids List[str]

The IDs of the results to unlock.

required
force bool

Force the unlock. Defaults to False.

False

Returns:

Name Type Description
Bool bool

True if successful, False if not.

update(works)

Update works in the results backend.

Parameters:

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

A list of payloads from Work Objects.

required
Note

This method is not intended for direct use by the user. Work status must be 'success' or 'failure'.

Returns:

Name Type Description
bool bool

Whether the works were updated successfully.

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

View works in the results backend.

Parameters:

Name Type Description Default
pipeline str

Name of pipeline.

required
query Dict[str, Any]

MongoDB query.

required
projection Dict[str, bool]

MongoDB projection. Defaults to {}.

{}
skip int

Number of works to skip. Defaults to 0.

0
limit int

Number of works to limit to. -1 for no limit. Defaults to 100.

100

Returns:

Type Description
List[Dict[str, Any]]

List[Dict[str, Any]]: List of work payloads.