Apply advanced processing to purchased geospatial data.
View repositoryA data class that represents errors encountered during job validation.
Attributes
Attribute | Description |
---|---|
message | str The message of the validation error. |
name | str The name of the validation error. |
An enumeration class that defines possible statuses for a job.
Constants
Constant | Description | Value | Terminal status |
---|---|---|---|
CREATED | The job has been created, but not yet accepted. | created | |
LICENSED | The EULA has been accepted for this process. The job will move on to the validation stage. | licensed | |
UNLICENSED | The EULA hasn’t been accepted for this process. The job will fail. Accept the EULA through the console or the API and try again. | unlicensed | |
VALID | The job has been validated. | valid | |
INVALID | The job has failed validation. Fix your input parameters and try again. | invalid | |
ACCEPTED | The job has been validated and accepted. The credits corresponding to the price are temporarily withheld until the job is completed. | accepted | |
REJECTED | The job has been canceled due to an insufficient account balance. Top up your balance and try again. | rejected | |
RUNNING | The job is in progress. | running | |
SUCCESSFUL | The job has been completed, and the results have been delivered to your storage. | successful | |
FAILED | The job has failed. | failed | |
CAPTURED | The job has been completed, the results have been delivered to your storage, and any withheld credits have been deducted from your account balance. | captured | |
RELEASED | The job has failed. Any withheld credits have been released. Try again, and if the issue persists, contact support. | released |
A class that contains predefined sorting fields.
Attributes
Attribute | Description |
---|---|
process_id | utils.SortingField Sorts by process ID. The default order is ascending. |
status | utils.SortingField Sorts by job status. The default order is descending. |
created | utils.SortingField Sorts by creation date. The default order is descending. |
credits | utils.SortingField Sorts by credit consumption. The default order is descending. |
from itertools import islice
# Sort by cost, from the least expensive to the most expensivejobs_sorted = up42.Job.all(sort_by=up42.JobSorting.credits.asc)
# Sort by creation date, from the most recent to the earliest# jobs_sorted = up42.Job.all(sort_by=up42.JobSorting.created.desc)
# Sort by job status, in descending alphabetical order# jobs_sorted = up42.Job.all(sort_by=up42.JobSorting.status.desc)
# Sort by process ID in ascending alphabetical order# jobs_sorted = up42.Job.all(sort_by=up42.JobSorting.process_id.asc)
for job in islice(jobs_sorted, 0, 5): # Print first 5 results print(f"- Job ID: {job.id}") print(f" Price: {job.credits} credits") print(f" Created at: {job.created}") print(f" Status: {job.status.value}") print(f" Started at: {job.started}") print(f" Finished at: {job.finished or 'Not finished'}\n")
A data class that represents a job in the system.
Attributes
Attribute | Description |
---|---|
process_id | str The process ID in a name format. |
id | str The job ID. |
account_id | str The account ID. |
workspace_id | Optional[str] The workspace ID. |
definition | dict The inputs and other parameters used to execute the job. |
status | JobStatus The job status. |
created | datetime.datetime The timestamp when the job was created. |
updated | datetime.datetime The timestamp when the job was last updated. |
collection_url | Optional[str] = None The URL of the resulting STAC collection. Available only if the job status is terminal. |
errors | Optional[List[ValidationError]] Job errors. Available only if the job status is INVALID . |
credits | Optional[int] The job cost, in credits. |
started | Optional[datetime.datetime] The timestamp when the job was started. |
finished | Optional[datetime.datetime] The timestamp when the job was finished. |
# Select a jobjob_id = "a0d443a2-41e8-4995-8b54-a5cc4c448227"
# Fetch job infojob = up42.Job.get(job_id=job_id)
# Define outputprint(f"Job details for ID: {job.id}")print(f"Process ID: {job.process_id}")print(f"Definition: {job.definition}")print(f"Collection URL: {job.collection_url}")print(f"Price: {job.credits} credits")print(f"Created at: {job.created}")print(f"Status: {job.status.value}")print(f"Started at: {job.started}")print(f"Finished at: {job.finished or 'Not finished'}")
Properties
Contains the STAC collection associated with the job. Available only if the job status is terminal. Returns pystac.Collection.
# Select a jobjob_id = "a0d443a2-41e8-4995-8b54-a5cc4c448227"
# Fetch job infojob = up42.Job.get(job_id=job_id)
# Define outputprint(f"STAC collection ID: {job.collection.id}")
Methods
Tracks the job status by retrying until the status changes to a terminal status.
Parameter | Description |
---|---|
wait | int An interval between queries, in seconds. The default value is 60 . |
retries | int The duration of querying. The default value is 60 * 24 * 3 . |
# Select a jobjob_id = "a0d443a2-41e8-4995-8b54-a5cc4c448227"
# Fetch job infojob = up42.Job.get(job_id=job_id)print(f"Initial job status is '{job.status.value}'. Starting to track...\n")
# This will print a status log to your console every 20 seconds# and will PAUSE the script here until the job is donejob.track(wait=20)
# This line will only run AFTER the job has finished trackingprint("\nTracking complete!")print(f"The final job status is: {job.status.value}")
Fetches a specific job by its ID. Returns Job
.
Parameter | Description |
---|---|
job_id | str The job ID. |
# Select a jobjob_id = "a0d443a2-41e8-4995-8b54-a5cc4c448227"
# Fetch job infojob = up42.Job.get(job_id=job_id)
# Define outputprint(f"Job details for ID: {job.id}")print(f"Price: {job.credits} credits")print(f"Created at: {job.created}")print(f"Status: {job.status.value}")print(f"Started at: {job.started}")print(f"Finished at: {job.finished or 'Not finished'}")
Retrieves all jobs, with optional filtering. Returns Iterator["Job"]
. Use itertools.islice
to offset and limit the results.
Parameter | Description |
---|---|
process_id | Optional[List[str]] Process IDs. Use to search for jobs running any of the provided processes. |
workspace_id | Optional[str] The workspace ID. Use to get jobs from a specific workspace. Otherwise, jobs from the entire account will be returned. |
status | Optional[List[JobStatus]] Job statuses. Use to search for jobs with any of the provided statuses. |
min_duration | Optional[int] The minimum duration of a job. Use to get jobs with runtimes greater than or equal to a specific number of seconds. Only jobs with the following statuses will be displayed:
|
max_duration | Optional[int] The maximum duration of a job. Use to get jobs with runtimes less than or equal to a specific number of seconds. Only jobs with the following statuses will be displayed:
|
sort_by | Optional[utils.SortingField] The results sorting method that arranges elements in ascending or descending order based on a chosen field. To view the list of possible values, see JobSorting . |
# Fetch all jobs, filtered by max duration and sorted by process IDjobs = up42.Job.all( max_duration=500, sort_by=up42.JobSorting.process_id,)
# Define outputfor job in jobs: print(f"- Job ID: {job.id}") print(f" Process ID: {job.process_id}") print(f" Price: {job.credits} credits") print(f" Status: {job.status.value}") print(f" Created at: {job.created}") print(f" Started at: {job.started}") print(f" Finished at: {job.finished or 'Not finished'}\n")
A data class that compares the cost of a process with custom values. Supported comparison operators:
- Greater than:
<
- Greater than or equal to:
>
- Less than:
<=
- Less than or equal to:
=>
Attributes
Attribute | Description |
---|---|
strategy | str The pricing strategy used to calculate the cost. |
credits | int The process cost, in credits. |
size | Optional[int] The size of the input STAC item. |
unit | Optional[str] The unit of measurement used to calculate the size. |
from up42 import processing_templates
# Select an item11 collapsed lines
stac_item_id = "68567134-27ad-7bd7-4b65-d61adb11fc78"
# Get the item from the STAC clientstac_client = up42.stac_client()stac_item = next(stac_client.get_items(stac_item_id))
# Instanitate a DetectionTreesSpacept templatetemplate = processing_templates.DetectionTreesSpacept( title="Detect trees over UK", item=stac_item,)
# Verify that the template cost is less than or equal to 100 creditsacceptable_cost = 100
if template.cost <= acceptable_cost: print(f"Template cost: {template.cost.credits} credits") print(f"Template strategy: {template.cost.strategy}") print(f"STAC item size: {template.cost.size}") print(f"Unit of measurement: {template.cost.unit}")
else: print(f"Template cost is higher than {acceptable cost} credits")
A class for job templates that define the process ID and input validation logic.
Attributes
Attribute | Description |
---|---|
process_id | ClassVar[str] The process ID in a name format. |
workspace_id | Union[str, base.WorkspaceId] The workspace ID. |
errors | set[ValidationError] A list of errors populated if the job isn’t valid. |
Properties
Checks if the job is valid. Returns bool
:
True
: The job is valid.False
: The job isn’t valid.
from up42 import processing_templates
# Select an itemstac_item_id = "68567134-27ad-7bd7-4b65-d61adb11fc78"
# Get the item from the STAC clientstac_client = up42.stac_client()stac_item = next(stac_client.get_items(stac_item_id))
# Instanitate a DetectionTreesSpacept templatejob = processing_templates.DetectionTreesSpacept( title="Detect trees over UK", item=stac_item,)
# Assert that the job is valid, print errors if notif not job.is_valid: for error in job.errors: print(f"{error}\n")
Methods
Executes the job. Returns Job
.
from up42 import processing_templates
# Select an item11 collapsed lines
stac_item_id = "68567134-27ad-7bd7-4b65-d61adb11fc78"
# Get the item from the STAC clientstac_client = up42.stac_client()stac_item = next(stac_client.get_items(stac_item_id))
# Instanitate a DetectionTreesSpacept templatejob_template = processing_templates.DetectionTreesSpacept( title="Detect trees over UK", item=stac_item,)
# Execute the templated jobjob = job_template.execute()
# Define outputprint(f"Job details for ID: {job.id}")print(f"Process ID: {job.process_id}")print(f"Status: {job.status.value}")print(f"Price: {job.credits or 'N/A'} credits")print(f"Created at: {job.created}")
A data class for the process templates that require one STAC item as input:
Atributes
Attribute | Description |
---|---|
title | str The title of the resulting objects: STAC item and STAC collection. |
item | pystac.Item The STAC item to process. |
A data class for the process templates that require multiple STAC items as input:
Atributes
Attribute | Description |
---|---|
title | str The title of the resulting objects: STAC item and STAC collection. |
items | List[pystac.Item] The STAC items to process. |