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.
from workflow.http.context import HTTPContext
ResultsContext = HTTPContext(backends=["results"])
results = ResultsContext.results
results
object. For example, you can call a method like this:
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
view(pipeline: str, query: Dict[str, Any], projection: Dict[str, bool] = {}, skip: int = 0, limit: int = 100) -> List[Dict[str, Any]]
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. |