Skip to content

Searching for resources

When running jobs, it is often necessary to search available functions, WorkData, or jobs. This can be done by querying the API.

If you only need to search once for a specific item, this is more easily done with Portal or the generic API explorer HUI. You can then use the found self link (a URL) and create e.g. a ProcessingStep object with it.

from pinexq.client.job_management.tools import ProcessingStep
my_step = ProcessingStep.from_url(client=client, processing_step_url="<url>")

If you need to search for resources programmatically, you can do so via our API.

Each searchable resource can be queried by accessing the corresponding root. For example, suppose we wish to find the most recent version of “my_function”. We begin by finding the ProcessingStep root:

# previously set up client
from pinexq.client.job_management import enter_jma
entrypoint = enter_jma(self.client)
processing_steps_root = entrypoint.processing_step_root_link.navigate()

The jobs_root_link and workdata_root_link can be accessed and navigated in a similar way.

Continuing with the previous example, we now need to configure our query and execute it on the root. We can then construct a ProcessingStep, for example, from the HCO, as well as view other information.

from pinexq.client.job_management.tool import ProcessingStep
from pinexq.client.job_management.model import (
ProcessingStepQueryParameters,
ProcessingStepSortPropertiesSortParameter,
ProcessingStepSortProperties,
SortTypes,
ProcessingStepFilterParameter,
FunctionNameMatchTypes
)
# build the query
query_param = ProcessingStepQueryParameters(
Filter=ProcessingStepFilterParameter(
FunctionName="my_function",
FunctionNameMatchType=FunctionNameMatchTypes.match_exact,
Version=None
),
SortBy=ProcessingStepSortPropertiesSortParameter(
PropertyName=ProcessingStepSortProperties.last_modified_at,
SortType=SortTypes.descending
)
)
# execute the query
query_result = processing_steps_root.query_action.execute(query_param)
# access the query result (HCOs)
result_hco = query_result[0]
print(f"Found function version {result_hco.version}")
# create a convenience object from the first HCO
most_recent_processing_step = ProcessingStep.from_hco(query_result[0])

Note that, for performance reasons, query_result will only contain the first 20 results by default (pagination). To learn how to iterate through them all, see the next section.

Version queries for ProcessingStepSortProperties

Section titled “Version queries for ProcessingStepSortProperties”

ProcessingSteps have a property version which follow Semantic Versioning. For more robust use of versions e.g. in workflows or in queries PineXQ supports specifying version ranges.

OperatorDescriptionExample
=Exact match1.5.2
>Greater than>1.2.0
>=Greater than or equal to>=2.0.0
<Less than<3.0.0
<=Less than or equal to<=3.0.0
^Major fixed (Compatible)^2.0.0
~Major & minor fixed (Patch)~2.0.0
*Wildcard0.1.*
<start> <end>Range query>1.0.0 <2.1.3