las package

Submodules

Module contents

class las.Client(credentials: Optional[las.credentials.Credentials] = None)[source]

Bases: object

A low level client to invoke api methods from Lucidtech AI Services.

create_app_client(generate_secret=True, logout_urls=None, callback_urls=None, login_urls=None, default_login_url=None, **optional_args) Dict[source]

Creates an appClient, calls the POST /appClients endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.create_app_client(name='<name>', description='<description>')
Parameters
  • name (str, optional) – Name of the appClient

  • description (str, optional) – Description of the appClient

  • generate_secret (Boolean) – Set to False to ceate a Public app client, default: True

  • logout_urls (List[str]) – List of logout urls

  • callback_urls (List[str]) – List of callback urls

  • login_urls (List[str]) – List of login urls

  • default_login_url (str) – Default login url

Returns

AppClient response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

create_asset(content: Union[bytes, bytearray, str, pathlib.Path, io.IOBase], **optional_args) Dict[source]

Creates an asset, calls the POST /assets endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.create_asset(b'<bytes data>')
Parameters
  • content (Content) – Content to POST

  • name (str, optional) – Name of the asset

  • description (str, optional) – Description of the asset

Returns

Asset response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

create_data_bundle(model_id, dataset_ids, **optional_args) Dict[source]

Creates a data bundle, calls the POST /models/{modelId}/dataBundles endpoint.

Parameters
  • model_id (str) – Id of the model

  • dataset_ids (List[str]) – Dataset Ids that will be included in the data bundle

  • name (str, optional) – Name of the data bundle

  • description (str, optional) – Description of the data bundle

Returns

Data Bundle response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

create_dataset(*, metadata: Optional[dict] = None, **optional_args) Dict[source]

Creates a dataset, calls the POST /datasets endpoint.

Parameters
  • name (str, optional) – Name of the dataset

  • description (str, optional) – Description of the dataset

  • metadata (dict, optional) – Dictionary that can be used to store additional information

Returns

Dataset response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

create_document(content: Union[bytes, bytearray, str, pathlib.Path, io.IOBase], content_type: Optional[str] = None, *, consent_id: Optional[str] = None, dataset_id: Optional[str] = None, ground_truth: Optional[Sequence[Dict[str, str]]] = None, retention_in_days: Optional[int] = None, metadata: Optional[dict] = None) Dict[source]

Creates a document, calls the POST /documents endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.create_document(b'<bytes data>', 'image/jpeg', consent_id='<consent id>')
Parameters
  • content (Content) – Content to POST

  • content_type (str) – MIME type for the document

  • consent_id (str, optional) – Id of the consent that marks the owner of the document

  • dataset_id (str, optional) – Id of the associated dataset

  • ground_truth (Sequence [ Dict [ str, Union [ str, bool ] ] ], optional) – List of items {‘label’: label, ‘value’: value} representing the ground truth values for the document

  • metadata (dict, optional) – Dictionary that can be used to store additional information

Returns

Document response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

create_model(field_config: dict, *, width: Optional[int] = None, height: Optional[int] = None, preprocess_config: Optional[dict] = None, postprocess_config: Optional[dict] = None, name: Optional[str] = None, description: Optional[str] = None, metadata: Optional[dict] = None, **optional_args) Dict[source]

Creates a model, calls the POST /models endpoint.

Parameters
  • field_config (dict) – Specification of the fields that the model is going to predict

  • width (int, optional) – The number of pixels to be used for the input image width of your model

  • height (int, optional) – The number of pixels to be used for the input image height of your model

  • preprocess_config (dict) – Specification of the processing steps prior to the prediction of an image

  • postprocess_config (dict) – Specification of the processing steps after the prediction of an image

  • name (str, optional) – Name of the model

  • description (str, optional) – Description of the model

  • metadata (dict, optional) – Dictionary that can be used to store additional information

Returns

Model response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

create_payment_method(**optional_args) Dict[source]

Creates a payment_method, calls the POST /paymentMethods endpoint.

Parameters
  • name (str, optional) – Name of the payment method

  • description (str, optional) – Description of the payment method

Returns

PaymentMethod response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

create_prediction(document_id: str, model_id: str, *, training_id: Optional[str] = None, max_pages: Optional[int] = None, auto_rotate: Optional[bool] = None, image_quality: Optional[str] = None, postprocess_config: Optional[dict] = None) Dict[source]

Create a prediction on a document using specified model, calls the POST /predictions endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.create_prediction(document_id='<document id>', model_id='<model id>')
Parameters
  • document_id (str) – Id of the document to run inference and create a prediction on

  • model_id (str) – Id of the model to use for predictions

  • training_id (str) – Id of training to use for predictions

  • max_pages (int, optional) – Maximum number of pages to run predictions on

  • auto_rotate (bool, optional) – Whether or not to let the API try different rotations on the document when running predictions

  • image_quality (int, optional) – Image quality for prediction “LOW|HIGH”. high quality could give better result but will also take longer time.

  • postprocess_config (dict, optional) –

    Post processing configuration for prediction. {

    ’strategy’: ‘BEST_FIRST’ | ‘BEST_N_PAGES’, (required) ‘parameters’: { (required if strategy=BEST_N_PAGES, omit otherwise)

    ’n’: int, (required if strategy=BEST_N_PAGES, omit otherwise) ‘collapse’: True | False (optional if strategy=BEST_N_PAGES, omit otherwise)

    }

    } Examples: {‘strategy’: ‘BEST_FIRST’} {‘strategy’: ‘BEST_N_PAGES’, ‘parameters’: {‘n’: 3}} {‘strategy’: ‘BEST_N_PAGES’, ‘parameters’: {‘n’: 3, ‘collapse’: False}}

Returns

Prediction response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

create_secret(data: dict, **optional_args) Dict[source]

Creates an secret, calls the POST /secrets endpoint.

>>> from las.client import Client
>>> client = Client()
>>> data = {'username': '<username>', 'password': '<password>'}
>>> client.create_secret(data, description='<description>')
Parameters
  • data (str) – Dict containing the data you want to keep secret

  • name (str, optional) – Name of the secret

  • description (str, optional) – Description of the secret

Returns

Secret response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

create_training(model_id, data_bundle_ids, *, instance_type: Optional[str] = None, metadata: Optional[dict] = None, **optional_args) Dict[source]

Requests a training, calls the POST /models/{modelId}/trainings endpoint.

Parameters
  • model_id (str) – Id of the model

  • data_bundle_ids (List[str]) – Data bundle ids that will be used for training

  • instance_type (List[str]) – The type of instance that will be used for training

  • name (str, optional) – Name of the data bundle

  • description (str, optional) – Description of the training

  • metadata (dict, optional) – Dictionary that can be used to store additional information

Returns

Training response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

create_transition(transition_type: str, *, in_schema: Optional[dict] = None, out_schema: Optional[dict] = None, parameters: Optional[dict] = None, **optional_args) Dict[source]

Creates a transition, calls the POST /transitions endpoint.

>>> import json
>>> from pathlib import Path
>>> from las.client import Client
>>> client = Client()
>>> in_schema = {'$schema': 'https://json-schema.org/draft-04/schema#', 'title': 'in', 'properties': {...} }
>>> out_schema = {'$schema': 'https://json-schema.org/draft-04/schema#', 'title': 'out', 'properties': {...} }
>>> # A typical docker transition
>>> docker_params = {
>>>     'imageUrl': '<image_url>',
>>>     'credentials': {'username': '<username>', 'password': '<password>'}
>>> }
>>> client.create_transition('docker', in_schema=in_schema, out_schema=out_schema, params=docker_params)
>>> # A manual transition with UI
>>> assets = {'jsRemoteComponent': 'las:asset:<hex-uuid>', '<other asset name>': 'las:asset:<hex-uuid>'}
>>> manual_params = {'assets': assets}
>>> client.create_transition('manual', in_schema=in_schema, out_schema=out_schema, params=manual_params)
Parameters
  • transition_type (str) – Type of transition “docker”|”manual”

  • in_schema (dict, optional) – Json-schema that defines the input to the transition

  • out_schema (dict, optional) – Json-schema that defines the output of the transition

  • name (str, optional) – Name of the transition

  • parameters (dict, optional) – Parameters to the corresponding transition type

  • description (str, optional) – Description of the transition

Returns

Transition response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

create_user(email: str, *, app_client_id, **optional_args) Dict[source]

Creates a new user, calls the POST /users endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.create_user('<email>', name='John Doe')
Parameters
  • email (str) – Email to the new user

  • name (str, optional) – Name of the user

  • avatar (str, optional) – base64 encoded JPEG avatar of the user

Returns

User response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

create_workflow(specification: dict, *, error_config: Optional[dict] = None, completed_config: Optional[dict] = None, **optional_args) Dict[source]

Creates a new workflow, calls the POST /workflows endpoint. Check out Lucidtech’s tutorials for more info on how to create a workflow.

>>> from las.client import Client
>>> from pathlib import Path
>>> client = Client()
>>> specification = {'language': 'ASL', 'version': '1.0.0', 'definition': {...}}
>>> error_config = {'email': '<error-recipient>'}
>>> client.create_workflow(specification, error_config=error_config)
Parameters
  • specification (dict) – Specification of the workflow, currently supporting ASL: https://states-language.net/spec.html

  • name (str, optional) – Name of the workflow

  • description (str, optional) – Description of the workflow

  • error_config (dict, optional) – Configuration of error handler

  • completed_config (dict, optional) – Configuration of a job to run whenever a workflow execution ends

Returns

Workflow response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

delete_app_client(app_client_id: str) Dict[source]

Delete the appClient with the provided appClientId, calls the DELETE /appClients/{appClientId} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.delete_app_client('<app_client_id>')
Parameters

app_client_id (str) – Id of the appClient

Returns

AppClient response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

delete_asset(asset_id: str) Dict[source]

Delete the asset with the provided asset_id, calls the DELETE /assets/{assetId} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.delete_asset('<asset_id>')
Parameters

asset_id (str) – Id of the asset

Returns

Asset response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

delete_data_bundle(model_id: str, data_bundle_id: str) Dict[source]

Delete the data bundle with the provided data_bundle_id, calls the DELETE /models/{modelId}/dataBundles/{dataBundleId} endpoint.

Parameters
  • model_id (str) – Id of the model

  • data_bundle_id (str) – Id of the data bundle

Returns

Data Bundle response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

delete_dataset(dataset_id: str, delete_documents: bool = False) Dict[source]

Delete the dataset with the provided dataset_id, calls the DELETE /datasets/{datasetId} endpoint.

Parameters
  • dataset_id (str) – Id of the dataset

  • delete_documents (bool) – Set to true to delete documents in dataset before deleting dataset

Returns

Dataset response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

delete_document(document_id: str) Dict[source]

Delete the document with the provided document_id, calls the DELETE /documents/{documentId} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.delete_document('<document_id>')
Parameters

document_id (str) – Id of the document

Returns

Model response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

delete_documents(*, consent_id: Optional[Union[str, List[str]]] = None, dataset_id: Optional[Union[str, List[str]]] = None, max_results: Optional[int] = None, next_token: Optional[str] = None, delete_all: Optional[bool] = False) Dict[source]

Delete documents with the provided consent_id, calls the DELETE /documents endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.delete_documents(consent_id='<consent id>')
Parameters
  • consent_id (Queryparam, optional) – Ids of the consents that marks the owner of the document

  • dataset_id (Queryparam, optional) – Ids of the datasets to be deleted

  • max_results (int, optional) – Maximum number of documents that will be deleted

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

  • delete_all (bool, optional) – Delete all documents that match the given parameters doing multiple API calls if necessary. Will throw an error if parameter max_results is also specified.

Returns

Documents response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

delete_model(model_id: str) Dict[source]

Delete the model with the provided model_id, calls the DELETE /models/{modelId} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.delete_model('<model_id>')
Parameters

model_id (str) – Id of the model

Returns

Model response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

delete_payment_method(payment_method_id: str) Dict[source]

Delete the payment_method with the provided payment_method_id, calls the DELETE /paymentMethods/{paymentMethodId} endpoint.

Parameters

payment_method_id (str) – Id of the payment method

Returns

PaymentMethod response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

delete_secret(secret_id: str) Dict[source]

Delete the secret with the provided secret_id, calls the DELETE /secrets/{secretId} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.delete_secret('<secret_id>')
Parameters

secret_id (str) – Id of the secret

Returns

Secret response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

delete_transition(transition_id: str) Dict[source]
Delete the transition with the provided transition_id, calls the DELETE /transitions/{transitionId} endpoint.

Will fail if transition is in use by one or more workflows.

>>> from las.client import Client
>>> client = Client()
>>> client.delete_transition('<transition_id>')
Parameters

transition_id (str) – Id of the transition

Returns

Transition response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

delete_user(user_id: str) Dict[source]

Delete the user with the provided user_id, calls the DELETE /users/{userId} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.delete_user('<user_id>')
Parameters

user_id (str) – Id of the user

Returns

User response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

delete_workflow(workflow_id: str) Dict[source]

Delete the workflow with the provided workflow_id, calls the DELETE /workflows/{workflowId} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.delete_workflow('<workflow_id>')
Parameters

workflow_id (str) – Id of the workflow

Returns

Workflow response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

delete_workflow_execution(workflow_id: str, execution_id: str) Dict[source]

Deletes the execution with the provided execution_id from workflow_id, calls the DELETE /workflows/{workflowId}/executions/{executionId} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.delete_workflow_execution('<workflow_id>', '<execution_id>')
Parameters
  • workflow_id (str) – Id of the workflow

  • execution_id (str) – Id of the execution

Returns

WorkflowExecution response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

execute_transition(transition_id: str) Dict[source]

Start executing a manual transition, calls the POST /transitions/{transitionId}/executions endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.execute_transition('<transition_id>')
Parameters

transition_id (str) – Id of the transition

Returns

Transition execution response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

execute_workflow(workflow_id: str, content: dict) Dict[source]

Start a workflow execution, calls the POST /workflows/{workflowId}/executions endpoint.

>>> from las.client import Client
>>> from pathlib import Path
>>> client = Client()
>>> content = {...}
>>> client.execute_workflow('<workflow_id>', content)
Parameters
  • workflow_id (str) – Id of the workflow

  • content (dict) – Input to the first step of the workflow

Returns

Workflow execution response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

get_asset(asset_id: str) Dict[source]

Get asset, calls the GET /assets/{assetId} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.get_asset(asset_id='<asset id>')
Parameters

asset_id (str) – Id of the asset

Returns

Asset response from REST API with content

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

get_dataset(dataset_id: str) Dict[source]

Get dataset, calls the GET /datasets/{datasetId} endpoint.

Parameters

dataset_id (str) – Id of the dataset

Returns

Dataset response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

get_document(document_id: str) Dict[source]

Get document, calls the GET /documents/{documentId} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.get_document('<document id>')
Parameters

document_id (str) – Id of the document

Returns

Document response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

get_log(log_id) Dict[source]

get log, calls the GET /logs/{logId} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.get_log('<log_id>')
Parameters

log_id (str) – Id of the log

Returns

Log response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

get_model(model_id: str) Dict[source]

Get a model, calls the GET /models/{modelId} endpoint.

Parameters

model_id (str) – The Id of the model

Returns

Model response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

get_organization(organization_id: str) Dict[source]

Get an organization, calls the GET /organizations/{organizationId} endpoint.

Parameters

organization_id (str) – The Id of the organization

Returns

Organization response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

get_payment_method(payment_method_id: str) Dict[source]

Get payment_method, calls the GET /paymentMethods/{paymentMethodId} endpoint.

Parameters

payment_method_id (str) – Id of the payment method

Returns

PaymentMethod response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

get_plan(plan_id: str) Dict[source]

Get information about a specific plan, calls the GET /plans/{plan_id} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.get_plan('<plan_id>')
Parameters

plan_id (str) – Id of the plan

Returns

Plan response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

get_transition(transition_id: str) Dict[source]

Get the transition with the provided transition_id, calls the GET /transitions/{transitionId} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.get_transition('<transition_id>')
Parameters

transition_id (str) – Id of the transition

Returns

Transition response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

get_transition_execution(transition_id: str, execution_id: str) Dict[source]

Get an execution of a transition, calls the GET /transitions/{transitionId}/executions/{executionId} endpoint

>>> from las.client import Client
>>> client = Client()
>>> client.get_transition_execution('<transition_id>', '<execution_id>')
Parameters
  • transition_id (str) – Id of the transition

  • execution_id (str) – Id of the executions

Returns

Transition execution responses from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

get_user(user_id: str) Dict[source]

Get information about a specific user, calls the GET /users/{user_id} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.get_user('<user_id>')
Parameters

user_id (str) – Id of the user

Returns

User response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

get_workflow(workflow_id: str) Dict[source]

Get the workflow with the provided workflow_id, calls the GET /workflows/{workflowId} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.get_workflow('<workflow_id>')
Parameters

workflow_id (str) – Id of the workflow

Returns

Workflow response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

get_workflow_execution(workflow_id: str, execution_id: str) Dict[source]

Get a workflow execution, calls the GET /workflows/{workflow_id}/executions/{execution_id} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.get_workflow_execution('<workflow_id>', '<execution_id>')
Parameters
  • workflow_id (str) – Id of the workflow that performs the execution

  • execution_id (str) – Id of the execution to get

Returns

Workflow execution response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

list_app_clients(*, max_results: Optional[int] = None, next_token: Optional[str] = None) Dict[source]

List appClients available, calls the GET /appClients endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.list_app_clients()
Parameters
  • max_results (int, optional) – Maximum number of results to be returned

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

Returns

AppClients response from REST API without the content of each appClient

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

list_assets(*, max_results: Optional[int] = None, next_token: Optional[str] = None) Dict[source]

List assets available, calls the GET /assets endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.list_assets()
Parameters
  • max_results (int, optional) – Maximum number of results to be returned

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

Returns

Assets response from REST API without the content of each asset

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

list_data_bundles(model_id, *, max_results: Optional[int] = None, next_token: Optional[str] = None) Dict[source]

List data bundles available, calls the GET /models/{modelId}/dataBundles endpoint.

Parameters
  • model_id (str) – Id of the model

  • max_results (int, optional) – Maximum number of results to be returned

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

Returns

Data Bundles response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

list_datasets(*, max_results: Optional[int] = None, next_token: Optional[str] = None) Dict[source]

List datasets available, calls the GET /datasets endpoint.

Parameters
  • max_results (int, optional) – Maximum number of results to be returned

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

Returns

Datasets response from REST API without the content of each dataset

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

list_documents(*, consent_id: Optional[Union[str, List[str]]] = None, dataset_id: Optional[Union[str, List[str]]] = None, max_results: Optional[int] = None, next_token: Optional[str] = None, order: Optional[str] = None, sort_by: Optional[str] = None) Dict[source]

List documents available for inference, calls the GET /documents endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.list_documents(consent_id='<consent_id>')
Parameters
  • consent_id (Queryparam, optional) – Ids of the consents that marks the owner of the document

  • dataset_id (Queryparam, optional) – Ids of datasets that contains the documents of interest

  • max_results (int, optional) – Maximum number of results to be returned

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

  • order (str, optional) – Order of the executions, either ‘ascending’ or ‘descending’

  • sort_by (str, optional) – the sorting variable of the executions, currently only supports ‘createdTime’

Returns

Documents response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

list_logs(*, workflow_id: Optional[str] = None, workflow_execution_id: Optional[str] = None, transition_id: Optional[str] = None, transition_execution_id: Optional[str] = None, max_results: Optional[int] = None, next_token: Optional[str] = None) Dict[source]

List logs, calls the GET /logs endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.list_logs()
Parameters
  • workflow_id (str, optional) – Only show logs from this workflow

  • workflow_execution_id (str, optional) – Only show logs from this workflow execution

  • transition_id (str, optional) – Only show logs from this transition

  • transition_execution_id (str, optional) – Only show logs from this transition execution

  • max_results (int, optional) – Maximum number of results to be returned

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

Returns

Logs response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

list_models(*, max_results: Optional[int] = None, next_token: Optional[str] = None) Dict[source]

List models available, calls the GET /models endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.list_models()
Parameters
  • max_results (int, optional) – Maximum number of results to be returned

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

Returns

Models response from REST API without the content of each model

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

list_payment_methods(*, max_results: Optional[int] = None, next_token: Optional[str] = None) Dict[source]

List payment_methods available, calls the GET /paymentMethods endpoint.

Parameters
  • max_results (int, optional) – Maximum number of results to be returned

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

Returns

PaymentMethods response from REST API without the content of each payment method

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

list_plans(*, owner: Optional[Union[str, List[str]]] = None, max_results: Optional[int] = None, next_token: Optional[str] = None) Dict[source]

List plans available, calls the GET /plans endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.list_plans()
Parameters
  • owner (Queryparam, optional) – Organizations to retrieve plans from

  • max_results (int, optional) – Maximum number of results to be returned

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

Returns

Plans response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

list_predictions(*, max_results: Optional[int] = None, next_token: Optional[str] = None, order: Optional[str] = None, sort_by: Optional[str] = None) Dict[source]

List predictions available, calls the GET /predictions endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.list_predictions()
Parameters
  • max_results (int, optional) – Maximum number of results to be returned

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

  • order (str, optional) – Order of the executions, either ‘ascending’ or ‘descending’

  • sort_by (str, optional) – the sorting variable of the executions, currently only supports ‘createdTime’

Returns

Predictions response from REST API without the content of each prediction

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

list_secrets(*, max_results: Optional[int] = None, next_token: Optional[str] = None) Dict[source]

List secrets available, calls the GET /secrets endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.list_secrets()
Parameters
  • max_results (int, optional) – Maximum number of results to be returned

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

Returns

Secrets response from REST API without the username of each secret

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

list_trainings(model_id, *, max_results: Optional[int] = None, next_token: Optional[str] = None) Dict[source]

List trainings available, calls the GET /models/{modelId}/trainings endpoint.

Parameters
  • model_id (str) – Id of the model

  • max_results (int, optional) – Maximum number of results to be returned

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

Returns

Trainings response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

list_transition_executions(transition_id: str, *, status: Optional[Union[str, List[str]]] = None, execution_id: Optional[Union[str, List[str]]] = None, max_results: Optional[int] = None, next_token: Optional[str] = None, sort_by: Optional[str] = None, order: Optional[str] = None) Dict[source]

List executions in a transition, calls the GET /transitions/{transitionId}/executions endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.list_transition_executions('<transition_id>', '<status>')
Parameters
  • transition_id (str) – Id of the transition

  • status (Queryparam, optional) – Statuses of the executions

  • order (str, optional) – Order of the executions, either ‘ascending’ or ‘descending’

  • sort_by (str, optional) – the sorting variable of the executions, either ‘endTime’, or ‘startTime’

  • execution_id (Queryparam, optional) – Ids of the executions

  • max_results (int, optional) – Maximum number of results to be returned

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

Returns

Transition executions responses from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

list_transitions(*, transition_type: Optional[Union[str, List[str]]] = None, max_results: Optional[int] = None, next_token: Optional[str] = None) Dict[source]

List transitions, calls the GET /transitions endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.list_transitions('<transition_type>')
Parameters
  • transition_type (Queryparam, optional) – Types of transitions

  • max_results (int, optional) – Maximum number of results to be returned

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

Returns

Transitions response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

list_users(*, max_results: Optional[int] = None, next_token: Optional[str] = None) Dict[source]

List users, calls the GET /users endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.list_users()
Parameters
  • max_results (int, optional) – Maximum number of results to be returned

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

Returns

Users response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

list_workflow_executions(workflow_id: str, *, status: Optional[Union[str, List[str]]] = None, sort_by: Optional[str] = None, order: Optional[str] = None, max_results: Optional[int] = None, next_token: Optional[str] = None, from_start_time: Optional[Union[str, datetime.datetime]] = None, to_start_time: Optional[Union[str, datetime.datetime]] = None) Dict[source]

List executions in a workflow, calls the GET /workflows/{workflowId}/executions endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.list_workflow_executions('<workflow_id>', '<status>')
Parameters
  • workflow_id (str) – Id of the workflow

  • order (str, optional) – Order of the executions, either ‘ascending’ or ‘descending’

  • sort_by (str, optional) – the sorting variable of the executions, either ‘endTime’, or ‘startTime’

  • status (Queryparam, optional) – Statuses of the executions

  • max_results (int, optional) – Maximum number of results to be returned

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

  • from_start_time (str or datetime, optional) – Specify a datetime range for start_time with from_start_time as lower bound

  • to_start_time (str or datetime, optional) – Specify a datetime range for start_time with to_start_time as upper bound

Returns

Workflow executions responses from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

list_workflows(*, max_results: Optional[int] = None, next_token: Optional[str] = None) Dict[source]

List workflows, calls the GET /workflows endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.list_workflows()
Parameters
  • max_results (int, optional) – Maximum number of results to be returned

  • next_token (str, optional) – A unique token for each page, use the returned token to retrieve the next page.

Returns

Workflows response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

send_heartbeat(transition_id: str, execution_id: str) Dict[source]

Send heartbeat for a manual execution to signal that we are still working on it. Must be done at minimum once every 60 seconds or the transition execution will time out, calls the POST /transitions/{transitionId}/executions/{executionId}/heartbeats endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.send_heartbeat('<transition_id>', '<execution_id>')
Parameters
  • transition_id (str) – Id of the transition

  • execution_id (str) – Id of the transition execution

Returns

Empty response

Return type

None

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

update_app_client(app_client_id, **optional_args) Dict[source]

Updates an appClient, calls the PATCH /appClients/{appClientId} endpoint.

Parameters
  • app_client_id (str) – Id of the appClient

  • name (str, optional) – Name of the appClient

  • description (str, optional) – Description of the appClient

Returns

AppClient response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

update_asset(asset_id: str, **optional_args) Dict[source]

Updates an asset, calls the PATCH /assets/{assetId} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.update_asset('<asset id>', content=b'<bytes data>')
Parameters
  • asset_id (str) – Id of the asset

  • content (Content, optional) – Content to PATCH

  • name (str, optional) – Name of the asset

  • description (str, optional) – Description of the asset

Returns

Asset response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

update_data_bundle(model_id: str, data_bundle_id: str, **optional_args) Dict[source]

Updates a data bundle, calls the PATCH /models/{modelId}/dataBundles/{dataBundleId} endpoint.

Parameters
  • model_id (str) – Id of the model

  • data_bundle_id (str) – Id of the data bundle

  • name (str, optional) – Name of the data bundle

  • description (str, optional) – Description of the data bundle

Returns

Data Bundle response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

update_dataset(dataset_id, metadata: Optional[dict] = None, **optional_args) Dict[source]

Updates a dataset, calls the PATCH /datasets/{datasetId} endpoint.

Parameters
  • dataset_id (str) – Id of the dataset

  • name (str, optional) – Name of the dataset

  • description (str, optional) – Description of the dataset

  • metadata (dict, optional) – Dictionary that can be used to store additional information

Returns

Dataset response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

update_document(document_id: str, ground_truth: Optional[Sequence[Dict[str, Union[str, None, bool]]]] = None, *, metadata: Optional[dict] = None, dataset_id: Optional[str] = None) Dict[source]

Update ground truth for a document, calls the PATCH /documents/{documentId} endpoint. Updating ground truth means adding the ground truth data for the particular document. This enables the API to learn from past mistakes.

Parameters
  • document_id (str) – Id of the document

  • dataset_id (str, optional) – Id of the dataset you want to associate your document with

  • ground_truth (Sequence [ Dict [ str, Union [ str, bool ] ] ], optional) – List of items {label: value} representing the ground truth values for the document

  • metadata (dict, optional) – Dictionary that can be used to store additional information

Returns

Document response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

update_model(model_id: str, *, width: Optional[int] = None, height: Optional[int] = None, field_config: Optional[dict] = None, preprocess_config: Optional[dict] = None, postprocess_config: Optional[dict] = None, metadata: Optional[dict] = None, **optional_args) Dict[source]

Updates a model, calls the PATCH /models/{modelId} endpoint.

Parameters
  • model_id (str, optional) – The Id of the model

  • width (int, optional) – The number of pixels to be used for the input image width of your model

  • height (int, optional) – The number of pixels to be used for the input image height of your model

  • field_config (dict) – Specification of the fields that the model is going to predict

  • preprocess_config (dict) – Specification of the processing steps prior to the prediction of an image

  • postprocess_config (dict) – Specification of the processing steps after the prediction of an image

  • metadata (dict, optional) – Dictionary that can be used to store additional information

  • training_id (str, optional) – Use training_id for model inference in POST /predictions

  • name (str, optional) – Name of the model

  • description (str, optional) – Description of the model

Returns

Model response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

update_organization(organization_id: str, *, payment_method_id: Optional[str] = None, **optional_args) Dict[source]

Updates an organization, calls the PATCH /organizations/{organizationId} endpoint.

Parameters
  • organization_id (str, optional) – Id of organization

  • payment_method_id (str, optional) – Id of paymentMethod to use

  • name (str, optional) – Name of the organization

  • description (str, optional) – Description of the organization

Returns

Organization response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

update_payment_method(payment_method_id: str, *, stripe_setup_intent_secret: Optional[str] = None, **optional_args) Dict[source]

Updates a payment_method, calls the PATCH /paymentMethods/{paymentMethodId} endpoint.

Parameters
  • payment_method_id (str) – Id of the payment method

  • stripe_setup_intent_secret (str, optional) – Stripe setup intent secret as returned from create_payment_method

  • name (str, optional) – Name of the payment method

  • description (str, optional) – Description of the payment method

Returns

PaymentMethod response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

update_secret(secret_id: str, *, data: Optional[dict] = None, **optional_args) Dict[source]

Updates an secret, calls the PATCH /secrets/secretId endpoint.

>>> from las.client import Client
>>> client = Client()
>>> data = {'username': '<username>', 'password': '<password>'}
>>> client.update_secret('<secret id>', data, description='<description>')
Parameters
  • secret_id (str) – Id of the secret

  • data (dict, optional) – Dict containing the data you want to keep secret

  • name (str, optional) – Name of the secret

  • description (str, optional) – Description of the secret

Returns

Secret response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

update_training(model_id: str, training_id: str, **optional_args) Dict[source]

Updates a training, calls the PATCH /models/{modelId}/trainings/{trainingId} endpoint.

Parameters
  • model_id (str) – Id of the model

  • training_id (str) – Id of the training

  • name (str, optional) – Name of the training

  • description (str, optional) – Description of the training

  • metadata (dict, optional) – Dictionary that can be used to store additional information

Returns

Training response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

update_transition(transition_id: str, *, in_schema: Optional[dict] = None, out_schema: Optional[dict] = None, assets: Optional[dict] = None, cpu: Optional[int] = None, memory: Optional[int] = None, image_url: Optional[str] = None, **optional_args) Dict[source]

Updates a transition, calls the PATCH /transitions/{transitionId} endpoint.

>>> import json
>>> from pathlib import Path
>>> from las.client import Client
>>> client = Client()
>>> client.update_transition('<transition-id>', name='<name>', description='<description>')
Parameters
  • transition_id (str) – Id of the transition

  • name (str, optional) – Name of the transition

  • description (str, optional) – Description of the transition

  • in_schema (dict, optional) – Json-schema that defines the input to the transition

  • out_schema (dict, optional) – Json-schema that defines the output of the transition

  • assets (dict, optional) – A dictionary where the values are assetIds that can be used in a manual transition

  • environment (dict, optional) – Environment variables to use for a docker transition

  • environment_secrets (list, optional) – A list of secretIds that contains environment variables to use for a docker transition

  • cpu (int, optional) – Number of CPU units to use for a docker transition

  • memory (int, optional) – Memory in MiB to use for a docker transition

  • image_url (str, optional) – Docker image url to use for a docker transition

  • secret_id (str, optional) – Secret containing a username and password if image_url points to a private docker image

Returns

Transition response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

update_transition_execution(transition_id: str, execution_id: str, status: str, *, output: Optional[dict] = None, error: Optional[dict] = None, start_time: Optional[Union[str, datetime.datetime]] = None) Dict[source]

Ends the processing of the transition execution, calls the PATCH /transitions/{transition_id}/executions/{execution_id} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> output = {...}
>>> client.update_transition_execution('<transition_id>', '<execution_id>', 'succeeded', output)
>>> error = {"message": 'The execution could not be processed due to ...'}
>>> client.update_transition_execution('<transition_id>', '<execution_id>', 'failed', error)
Parameters
  • transition_id (str) – Id of the transition that performs the execution

  • execution_id (str) – Id of the execution to update

  • status (str) – Status of the execution ‘succeeded|failed’

  • output (dict, optional) – Output from the execution, required when status is ‘succeded’

  • error (dict, optional) – Error from the execution, required when status is ‘failed’, needs to contain ‘message’

  • start_time (str, optional) – start time that will replace the original start time of the execution

Returns

Transition execution response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

update_user(user_id: str, **optional_args) Dict[source]

Updates a user, calls the PATCH /users/{userId} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.update_user('<user id>', name='John Doe')
Parameters
  • user_id (str) – Id of the user

  • name (str, optional) – Name of the user

  • avatar (str, optional) – base64 encoded JPEG avatar of the user

Returns

User response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

update_workflow(workflow_id: str, *, error_config: Optional[dict] = None, completed_config: Optional[dict] = None, **optional_args) Dict[source]

Updates a workflow, calls the PATCH /workflows/{workflowId} endpoint.

>>> import json
>>> from pathlib import Path
>>> from las.client import Client
>>> client = Client()
>>> client.update_workflow('<workflow-id>', name='<name>', description='<description>')
Parameters
  • workflow_id – Id of the workflow

  • name (str, optional) – Name of the workflow

  • description (str, optional) – Description of the workflow

  • error_config (dict, optional) – Configuration of error handler

  • completed_config (dict, optional) – Configuration of a job to run whenever a workflow execution ends

Returns

Workflow response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

update_workflow_execution(workflow_id: str, execution_id: str, next_transition_id: str) Dict[source]

Retry or end the processing of a workflow execution, calls the PATCH /workflows/{workflow_id}/executions/{execution_id} endpoint.

>>> from las.client import Client
>>> client = Client()
>>> client.update_workflow_execution('<workflow_id>', '<execution_id>', '<next_transition_id>')
Parameters
  • workflow_id (str) – Id of the workflow that performs the execution

  • execution_id (str) – Id of the execution to update

  • next_transition_id (str) – the next transition to transition into, to end the workflow-execution, use: las:transition:commons-failed

Returns

Workflow execution response from REST API

Return type

dict

Raises

InvalidCredentialsException, TooManyRequestsException, LimitExceededException, requests.exception.RequestException

class las.Credentials(client_id: str, client_secret: str, auth_endpoint: str, api_endpoint: str, cached_profile: Optional[str] = None, cache_path: pathlib.Path = PosixPath('/home/runner/.lucidtech/token-cache.json'))[source]

Bases: object

Used to fetch and store credentials and to generate/cache an access token.

Parameters
  • client_id – The client id

  • client_secret – The client secret

  • auth_endpoint – The auth endpoint

  • api_endpoint – The api endpoint

property access_token: str