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.
The easy way
Section titled “The easy way”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>")The Python way
Section titled “The Python way”If you need to search for resources programmatically, you can do so via our API.
Begin by preparing a query. We provide convenience classes for making a WorkDataQuery, ProcessingStepQuery, or JobQuery in pinexq.client.job_management.
Provide a configured PineXQ client, as well as your search parameters. For example:
# previously set up clientfrom pinexq.client.job_management import enter_jma
# previously configured clientwd_query = WorkDataQuery.create(client, name_contains="my_data.csv", sort_by_property_name="CreatedAt", sort_by_sort_type="Descending")You can then call wd_query.execute() to get your results as a WorkDataQueryResultHco.
For more examples and information, see Convenience classes.
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.
| Operator | Description | Example |
|---|---|---|
= | Exact match | 1.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 |
* | Wildcard | 0.1.* |
<start> <end> | Range query | >1.0.0 <2.1.3 |
Iterating through your results
Section titled “Iterating through your results”The classes JobQueryResultHco, ProcessingStepQueryResultHco, and WorkDataQueryResultHco returned by query.execute() represent a single page of query results.
To get results from the next page, one must navigate to the next_link, provided that it is not None.
To make it easier to process all items returned by the query, these classes contain two methods: iter() and iter_flat().
iter()
Section titled “iter()”The iter() method returns an Iterable of pages of the query result so that all pages can be processed in a loop.
for page in jobs_root.job_query_action.execute(query).iter(): for job in page.jobs: # process the jobiter_flat()
Section titled “iter_flat()”The iter_flat() method flattens the result provided by iter() and returns an Iterable of the corresponding
HCO entity (Job, ProcessingStep or Workdata), allowing these entities to be processed in a loop.
for job in jobs.job_query_action.execute(query).iter_flat(): # process the job