Client

Client is the main entry point for users to interact with the DDS Cloud API. After initializing it with a Config class, users can use it to upload files, trigger tasks, and check for the results.

A simple example illustrating the major interface:

from dds_cloudapi_sdk import Config
from dds_cloudapi_sdk import Client

token = "Your API Token Here"
config = Config(token)
client = Client(config)

# upload local file with client
url = client.upload_file("/path/to/local_file.jpg")

# run a task with client
client.run(task)
print(task.result)

API Reference

class Client(config)[source]
This is the SDK client for dds cloud APIs.
It is initialized with the API token, and talks to the server to:
    1. upload files to get the visible url

    1. run tasks and wait for the results

Parameters:

config (Config) – The Config object.

upload_file(local_path)[source]
Upload local file to dds server, return a visible url ready for calling dds cloud API.
Although users can trigger tasks with any publicly visible url, uploading file to dds server and use the dds hosted url as task parameter is necessary to conform the network security policy of the DDS server.
Parameters:

local_path (str) – The local file path.

Return type:

str

trigger_task(task)[source]

Trigger a task and return immediately without waiting for the result.

Parameters:

task (BaseTask) – The task to trigger.

check_task(task)[source]

Check the task’s status.

Parameters:

task (BaseTask) – The task to check.

wait_task(task)[source]
Wait for the task to complete.
This blocks the current thread until the task is done.
Parameters:

task (BaseTask) – The task to wait.

run_task(task)[source]
Trigger a task and wait for it to complete.
This blocks the current thread until the task is done.
Parameters:

task (BaseTask) – The task to run.