Inference
geostudio.backends.v2.ginference.client
Client
Client(
api_config: GeoFmSettings = None,
session: Session = None,
api_token: str = None,
api_key: str = None,
api_key_file: str = None,
geostudio_config_file: str = None,
*args,
**kwargs
)
Bases: BaseClient
A client for interacting with the Geospatial Studio inference API endpoints
Source code in geostudio/backends/base_client.py
create_model
create_model(data: ModelCreateInput, output: str = 'json')
Creates a new model using the provided data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ModelCreateInput`
|
The input data required to create a new model. |
required |
output
|
str
|
The desired output format. Defaults to "json". |
'json'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The response containing the created model Metadata. |
Source code in geostudio/backends/v2/ginference/client.py
list_models
list_models(output: str = 'json')
Lists all available models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
The format of the response. Defaults to "json". |
'json'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
A dictionary containing the list of models. |
Source code in geostudio/backends/v2/ginference/client.py
update_model
update_model(
model_id: UUID,
data: ModelUpdateInput,
output: str = "json",
)
Updates metadata of a specified model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_id
|
UUID
|
The unique identifier of the model to be updated. |
required |
data
|
dict
|
A dictionary containing the new metadata for the model. |
required |
output
|
str
|
The format of the response. Defaults to "json". |
'json'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The response from the server containing the updated metadata. |
Source code in geostudio/backends/v2/ginference/client.py
deploy_model
deploy_model(
model_id: str,
data: ModelOnboardingInputSchema,
output="json",
)
Deploys a model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_id
|
str
|
The unique identifier of the model to be deployed |
required |
data
|
ModelOnboardingInputSchema
|
Urls to the model checkpoint and configs |
required |
Source code in geostudio/backends/v2/ginference/client.py
get_model
Retrieves a model's information using its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_id
|
UUID
|
The unique identifier of the model to retrieve. |
required |
output
|
str
|
The desired output format. Defaults to "json". |
'json'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The model's status and information |
Source code in geostudio/backends/v2/ginference/client.py
delete_model
Deletes a specified model using its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_id
|
str
|
The ID of the model to be deleted. |
required |
output
|
str
|
The format of the response. Defaults to "json". |
'json'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The response from the server after deleting the model. |
Source code in geostudio/backends/v2/ginference/client.py
submit_inference
submit_inference(
data: InferenceCreateInput, output: str = "json"
)
Submits an inference task to the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
InferenceCreateInput
|
The input data for the inference task. |
required |
output
|
str
|
The desired output format. Defaults to "json". |
'json'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The server's response containing the results of the inference task. |
Source code in geostudio/backends/v2/ginference/client.py
list_inferences
list_inferences(output: str = 'json')
Lists inferences submitted to the Studio. Limit to most recent 10.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
The desired output format. Defaults to "json". |
'json'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
A dictionary containing a list of inference tasks submitted to the studio |
Source code in geostudio/backends/v2/ginference/client.py
get_inference
Retrieves the inference with the given inference ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inference_id
|
UUID
|
The unique identifier of the inference task. |
required |
output
|
str
|
The desired output format. Defaults to "json". |
'json'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The inference task data in the specified output format. |
Source code in geostudio/backends/v2/ginference/client.py
delete_inference
Deletes an inference using its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inference_id
|
UUID
|
The ID of the inference to be deleted. |
required |
output
|
str
|
The format of the response. Defaults to "json". |
'json'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The response from the server after deleting the inference. |
Source code in geostudio/backends/v2/ginference/client.py
get_inference_tasks
Retrieves the tasks associated with an inference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inference_id
|
UUID
|
The unique identifier of the inference. |
required |
output
|
str
|
The desired output format. Defaults to "json". |
'json'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The inference task data in the specified output format. |
Source code in geostudio/backends/v2/ginference/client.py
get_task_output_url
Retrieves the output url for a specific inference task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_id
|
UUID
|
The unique identifier of the task. |
required |
output
|
str
|
The desired output format. Defaults to "json". |
'json'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The inference task data in the specified output format. |
Source code in geostudio/backends/v2/ginference/client.py
get_task_step_logs
Retrieves the logs for a specific step of an inference task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_id
|
UUID
|
The unique identifier of the task. |
required |
output
|
str
|
The desired output format. Defaults to "json". |
'json'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The inference task data in the specified output format. |
Source code in geostudio/backends/v2/ginference/client.py
check_data_availability
check_data_availability(
datasource: str,
data: DataAdvisorIn,
output: str = "json",
)
Query data-advisor service to check data availability before running an inference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
A dictionary containing the necessary parameters for the data availability check. |
required |
output
|
str
|
The desired output format. Default is "json". |
'json'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The response from the server containing the data availability information. |
Source code in geostudio/backends/v2/ginference/client.py
list_datasource_collections
Query data-advisor to list collections available for a specific data source
Source code in geostudio/backends/v2/ginference/client.py
list_datasource
list_datasource(
connector: str = None,
collection: str = None,
limit: int = 25,
skip: int = 0,
output: str = "json",
)
Lists all data sources available in the studio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
The format of the response. Defaults to "json". |
'json'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
A dictionary containing a list of data sources available through the studio |
Source code in geostudio/backends/v2/ginference/client.py
get_datasource
Retrieves a specific data source's information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasource_id
|
UUID
|
The unique identifier of the data source to retrieve. |
required |
output
|
str
|
The format of the response. Defaults to "json". |
'json'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The response from the server containing the data source details. |
Source code in geostudio/backends/v2/ginference/client.py
get_fileshare_links
get_fileshare_links(object_name: str)
Generate presigned urls for sharing files i.e uploading and downloading files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
object_name
|
str
|
The name of the object (file) for which to generate upload links. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
A dictionary containing the upload links. |
Source code in geostudio/backends/v2/ginference/client.py
upload_file_to_url
Uploads a file to a specified URL using a PUT request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
upload_url
|
str
|
The URL to which the file will be uploaded. |
required |
filepath
|
str
|
The path to the file that will be uploaded. |
required |
Returns:
| Type | Description |
|---|---|
|
requests.Response: The response from the server after the file upload. |
Source code in geostudio/backends/v2/ginference/client.py
upload_file
upload_file(filename: str)
Streamlines :py:meth:get_upload_links and :py:meth:upload_file_to_url.
Uploads a file to a specified location using the provided upload links.
Source code in geostudio/backends/v2/ginference/client.py
create_download_presigned_url
create_download_presigned_url(
bucket_name: str,
object_key: str,
endpoint_url: str,
region_name: str,
service_name: str,
aws_access_key_id: str = None,
aws_secret_access_key: str = None,
expiration: int = 3600,
**kwargs
)
Function to create presigned url to download object from bucket
Parameters
bucket_name : str The bucket name in the instance object_key : str Object path to pre-sign endpoint_url: str s3 Endpoint i.e https://s3.us-east.cloud-object-storage.appdomain.cloud region_name: str Region where bucket lives. i.e us-east service_name: str service to connect to i.e s3 aws_access_key_id: str AWS Access key to the instance aws_secret_access_key: str AWS secret access key to the instance expiration : int, optional Expiration duration in seconds, by default 3600
Returns
str Presigned download url
Source code in geostudio/backends/v2/ginference/client.py
create_upload_presigned_url
create_upload_presigned_url(
bucket_name: str,
object_key: str,
endpoint_url: str,
region_name: str,
service_name: str,
aws_access_key_id: str = None,
aws_secret_access_key: str = None,
expiration: int = 3600,
**kwargs
)
Function to create presigned url to upload object from bucket
Parameters
bucket_name : str The bucket name in the instance object_key : str Object path to pre-sign endpoint_url: str s3 Endpoint i.e https://s3.us-east.cloud-object-storage.appdomain.cloud region_name: str Region where bucket lives. i.e us-east service_name: str service to connect to i.e s3 aws_access_key_id: str AWS Access key to the instance aws_secret_access_key: str AWS secret access key to the instance expiration : int, optional Expiration duration in seconds, by default 3600
Returns
str Presigned upload url
Source code in geostudio/backends/v2/ginference/client.py
poll_inference_until_finished
Polls the status of an inference task until it is completed or failed. Defaults to a minimum of 5seconds poll frequency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inference_id
|
str
|
The unique identifier of the inference task. |
required |
poll_frequency
|
int
|
The time interval in seconds between polls. Defaults to 5 seconds. |
10
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The response from the inference task when it is completed or failed. |