Source code for dataset_client

[docs]def create_dataset(body): """ Create a new dataset with the specified name, description, and other details. :table:Input parameters summary: +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | Field | Input | Type | Description | +=========================+=======+=======+===============================================================================+ | dataset_name | body | str |The name of the new dataset to create | +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | dataset_description | body | str | A description for the new dataset | +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | dataset_type | body | str | The type of the new dataset (e.g. Image, Text, Audio, etc.). | +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | item_format | body | str |The format of the dataset items (e.g. image/jpeg, text/plain, audio/mpeg, etc.)| +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | metadata | body | dict | A dictionary of metadata to associate with the new dataset. | +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | s3IntermediateUrl | body | str | The S3 URL where the dataset items are processed | +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | aws_credentials_enabled | body | bool | Whether AWS credentials are enabled for the dataset | +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | aws_credentials | body | dict | A dictionary containing AWS credentials for the dataset | +-------------------------+-------+-------+-------------------------------------------------------------------------------+ Sample Request Body .. code-block:: python from pprint import pprint from tensoract.client import Tensoract # Initialize Tensoract client dataset_client = Tensoract(api_url="YOUR_API_URL",api_key="YOUR_API_KEY") body={ "dataset_name": "Test-Dataset-API", "dataset_description": "This is a test Dataset", "dataset_type": "Image", "item_format": "image/tiff", "metadata": { "Dataset": "Image Dataset" }, "s3IntermediateUrl": "s3://************************************", "aws_credentials_enabled": true, "aws_credentials": { "awsKey": "***********", "awsSecret": "**************", "awsRegion": "***********", "awsType": "key" } } pprint(dataset_client.create_dataset(body)) :table:Response summary: +------------+-----------------+-----------------------------------------------+ | Field | Type | Instructions | +============+=================+===============================================+ | dataset_id | str | Id of the dataset. | +------------+-----------------+-----------------------------------------------+ | value | str | Description or message indicating the result. | +------------+-----------------+-----------------------------------------------+ | status | str | The status of the operation | +------------+-----------------+-----------------------------------------------+ Sample Response .. code-block:: python { "dataset_id": "e20859abab70f7df3fb0b7c7", "value": "Dataset updated", "status": "success" } """
[docs]def get_dataset(dataset_id): """ Get a dataset by ID. :table:Input parameters summary: +--------------+----------+-------+--------------------------------------------------+ | Field | Input | Type | Description | +==============+==========+=======+==================================================+ | dataset_id | body | str | The Id of the dataset to retrieve | +--------------+----------+-------+--------------------------------------------------+ .. code-block:: python from pprint import pprint from tensoract.client import Tensoract # Initialize Tensoract client dataset_client = Tensoract(api_url="YOUR_API_URL",api_key="YOUR_API_KEY") # Invoke get_project method response = dataset_client.get_dataset(dataset_id="9373f3f9d3f1400cfba6ac6a") pprint(response) :table:Response summary: +-------------------------+-------+------------------------------------------------------------------------------+ | Field | Type | Description | +=========================+=======+==============================================================================+ | dataset_id | str |The Id of the dataset | +-------------------------+-------+------------------------------------------------------------------------------+ | dataset_name | str |The name of the new dataset to create | +-------------------------+-------+------------------------------------------------------------------------------+ | dataset_description | str | A description for the dataset | +-------------------------+-------+------------------------------------------------------------------------------+ | dataset_type | str | The type of the dataset | +-------------------------+-------+------------------------------------------------------------------------------+ | dataset_versions | list | A list of dictionaries containing version information for the dataset. | +-------------------------+-------+------------------------------------------------------------------------------+ | item_format | str |The format of the dataset items | +-------------------------+-------+------------------------------------------------------------------------------+ | metadata | dict | A dictionary containing metadata for the dataset. | +-------------------------+-------+------------------------------------------------------------------------------+ | aws_credentials_enabled | bool | Whether AWS credentials are enabled for the dataset | +-------------------------+-------+------------------------------------------------------------------------------+ | aws_credentials | dict | A dictionary containing AWS credentials for the dataset | +-------------------------+-------+------------------------------------------------------------------------------+ | s3IntermediateUrl | str | The S3 URL for intermediate data | +-------------------------+-------+------------------------------------------------------------------------------+ Sample Response .. code-block:: python { "dataset_id": "9373f3f9d3f1400cfba6ac6a", "dataset_name": "Test-Dataset-Recipes", "dataset_type": "PDFOCR", "dataset_versions": [ { "id": 0, "items": 29, "name": "V.1", "locked": false, "created": 1690173205, "modified": 1690173205 } ], "dataset_items": 29, "metadata": { "Dataset": "Recipes" }, "company": "60f38299446de8dabe9207e5", "company_name": "Objectways", "aws_credentials_enabled": true, "aws_credentials": { "awsType": "key", "awsKey": "********************", "awsSecret": "****************************************", "awsRegion": "*********" }, "s3IntermediateUrl": "*******************************" } """
[docs]def update_dataset(dataset_id,body): """ Update Dataset. :table:Input parameters summary: +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | Field | Input | Type | Description | +=========================+=======+=======+===============================================================================+ | dataset_id | body | str |The Id of the dataset | +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | dataset_name | body | str |The name of the new dataset to create | +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | dataset_description | body | str | A description for the dataset | +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | dataset_type | body | str | The type of the dataset | +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | dataset_versions | body | list | A list of dictionaries containing version information for the dataset. | +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | item_format | body | str |The format of the dataset items | +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | metadata | body | dict | A dictionary containing metadata for the dataset. | +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | aws_credentials_enabled | body | bool | Whether AWS credentials are enabled for the dataset | +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | aws_credentials | body | dict | A dictionary containing AWS credentials for the dataset | +-------------------------+-------+-------+-------------------------------------------------------------------------------+ | s3IntermediateUrl | body | str | The S3 URL for intermediate data | +-------------------------+-------+-------+-------------------------------------------------------------------------------+ Sample Request Body .. code-block:: python from pprint import pprint from tensoract.client import Tensoract # Initialize Tensoract client dataset_client = Tensoract(api_url="YOUR_API_URL",api_key="YOUR_API_KEY") body={ "dataset_name": "Test-Dataset-API", "dataset_description": "Update dataset", "dataset_type": "Image", "item_format": "image/tiff", "metadata": { "Dataset": "Image Dataset" }, "s3IntermediateUrl": "s3://************************************", "aws_credentials_enabled": true, "aws_credentials": { "awsKey": "***********", "awsSecret": "**************", "awsRegion": "***********", "awsType": "key" } } response = dataset_client.update_dataset(dataset_id="85bfac4fb66d935312a373ec",body=body) pprint(response) :table:Response summary: +-------------------------+-------+------------------------------------------------------------------------------+ | Field | Type | Description | +=========================+=======+==============================================================================+ | dataset_id | str |The ID of the dataset | +-------------------------+-------+------------------------------------------------------------------------------+ | dataset_name | str |The name of the new dataset to create | +-------------------------+-------+------------------------------------------------------------------------------+ | dataset_description | str | A description for the dataset | +-------------------------+-------+------------------------------------------------------------------------------+ | dataset_type | str | The type of the dataset | +-------------------------+-------+------------------------------------------------------------------------------+ | dataset_versions | list | A list of dictionaries containing version information for the dataset. | +-------------------------+-------+------------------------------------------------------------------------------+ | item_format | str |The format of the dataset items | +-------------------------+-------+------------------------------------------------------------------------------+ | metadata | dict | A dictionary containing metadata for the dataset. | +-------------------------+-------+------------------------------------------------------------------------------+ | aws_credentials_enabled | bool | Whether AWS credentials are enabled for the dataset | +-------------------------+-------+------------------------------------------------------------------------------+ | aws_credentials | dict | A dictionary containing AWS credentials for the dataset | +-------------------------+-------+------------------------------------------------------------------------------+ | s3IntermediateUrl | str | The S3 URL for intermediate data | +-------------------------+-------+------------------------------------------------------------------------------+ Sample Response .. code-block:: python { "dataset_id": "85bfac4fb66d935312a373ec", "dataset_name": "Test-Dataset-API", "dataset_type": "Image", "dataset_description": "Update Dataset", "dataset_versions": [ { "id": 0, "items": 0, "name": "V.1", "locked": false, "created": 1678442477, "modified": 1678442477 } ], "item_format": "image/tiff", "metadata": { "Dataset": "Image Dataset" }, "company": "60f38299446de8dabe9207e5", "aws_credentials_enabled": true, "aws_credentials": { "awsKey": "********************", "awsSecret": "****************************************", "awsRegion": "*********", "awsType": "key" }, "s3IntermediateUrl": "s3://************************************", } """
[docs]def delete_dataset(dataset_id): """ Delete Dataset. :table:Input parameters summary: +--------------+----------+-------+--------------------------------------------------+ | Field | Input | Type | Description | +==============+==========+=======+==================================================+ | dataset_id | body | str | The Id of the dataset to delete | +--------------+----------+-------+--------------------------------------------------+ .. code-block:: python from pprint import pprint from tensoract.client import Tensoract # Initialize Tensoract client dataset_client = Tensoract(api_url="YOUR_API_URL",api_key="YOUR_API_KEY") # Invoke delete_dataset method response = dataset_client.delete_dataset(dataset_id="8bc05ec26ab161e218a0e842") pprint(response) :table:Response summary: +------------+------------------+---------------------------------------------------------------+ | Field | Type | Description | +============+==================+===============================================================+ | status | str | The status of the operation | +------------+------------------+---------------------------------------------------------------+ | value | str | The result or value of the operation | +------------+------------------+---------------------------------------------------------------+ Sample Response .. code-block:: python { "status": "success", "value": "dataset deleted" } """
[docs]def list_datasets(dataset_id,dataset_name,active): """ List datasets. :table:Input parameters summary: +----------------+-------+-------+-----------------------------------------------+ | Field | Input | Type | Description | +================+=======+=======+===============================================+ | dataset_id | body | str |The Id of the dataset | +----------------+-------+-------+-----------------------------------------------+ | dataset_name | body | str |The name of the dataset | +----------------+-------+-------+-----------------------------------------------+ | active | body | bool |Whether to filter datasets by active status | +----------------+-------+-------+-----------------------------------------------+ Sample Request Body .. code-block:: python { from pprint import pprint from tensoract.client import Tensoract # Initialize Tensoract client dataset_client = Tensoract(api_url="YOUR_API_URL",api_key="YOUR_API_KEY") # Invoke list_datasets method response = dataset_client.list_datasets(dataset_id=None,dataset_name=None,active=True) pprint(response) } :table:Response summary: +-------------------------+------+-------------------------------------------------------------------------------+ | Field | Type | Description | +=========================+======+===============================================================================+ | dataset_id | str | The Id of the dataset | +-------------------------+------+-------------------------------------------------------------------------------+ | dataset_name | str | The name of the dataset | +-------------------------+------+-------------------------------------------------------------------------------+ | dataset_description | str | A description for the dataset | +-------------------------+------+-------------------------------------------------------------------------------+ | dataset_type | str | The type of the dataset | +-------------------------+------+-------------------------------------------------------------------------------+ | dataset_versions | list| A list of dictionaries containing version information for the dataset. | +-------------------------+------+-------------------------------------------------------------------------------+ | company | str | The Id of the company associated with the item. | +-------------------------+------+-------------------------------------------------------------------------------+ | company_name | str | The name of the company associated with the item. | +-------------------------+------+-------------------------------------------------------------------------------+ Sample Response .. code-block:: python [ { "dataset_id": "c8a04fbf7c8f95ef8912338f", "dataset_name": "Test Dataset", "dataset_type": "Image", "dataset_versions": [ { "id": 0, "items": 1, "name": "Base version", "locked": true, "created": 1657526913, "modified": 1657526913 }, { "id": 1, "items": 59, "name": "Version 2", "locked": true, "created": 1657527052, "modified": 1657527052 } ], "company": "60f38299446de8dabe9207e5", "company_name": "Objectways" }, { "dataset_id": "bd35da16cd39283f119454cc", "dataset_name": "Test Dataset 3", "dataset_type": "Image", "dataset_versions": [ { "id": 0, "items": 1, "name": "V.1", "locked": true, "created": 1657708086, "modified": 1657708086 }, { "id": 1, "items": 5, "name": "V.2", "locked": true, "created": 1657709319, "modified": 1657709319 }, ], "company": "60f38299446de8dabe9207e5", "company_name": "Objectways" } ] """