Skip to content

User Operations

Python platform client for interacting with the Deci platform.

Deci's Platform client allows you to perform basic and advanced use-cases through the Deci platform. This lets you, through python code, create and manage your models, workspaces, experiments, and more.

DeciPlatformClient(proxy_headers=None, logger=None)

Attributes:

Name Type Description
raw_api PlatformApi

This is a low-level interface to the platform. Shouldn't be used directly.

In order to use the client, you need to login to the platform. To do so, you'll need to set the following environment variables:

  • DECI_CLIENT_ID: The user's client ID generated in the Deci platform.
  • DECI_CLIENT_SECRET: The user's secret generated in the Deci platform.
  • DECI_WORKSPACE_ID: Optional desired workspace ID to use upon a successful login. If not specified, the client will use the first workspace retrieved. The workspace ID should be retrieved from the platform here

Parameters:

Name Type Description Default
proxy_headers Optional[dict[str, Any]]

A dictionary containing headers that will be sent to the proxy (urllib3.ProxyManager). In case of HTTP they are being sent with each request, while in the HTTPS/CONNECT case they are sent only once. Could be used for proxy authentication.

None
logger Optional[Logger]

An optional logger to use. If not specified, a default logger will be used.

None
Source code in deci_platform_client/client/deci_platform_client.py
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
def __init__(self, proxy_headers: "Optional[dict[str, Any]]" = None, logger: "Optional[Logger]" = None):
    """Create a new instance of the platform client.

    In order to use the client, you need to login to the platform.
    To do so, you'll need to set the following environment variables:

    * `DECI_CLIENT_ID`: The user's client ID generated in the [Deci platform](https://console.deci.ai/settings/api-tokens).
    * `DECI_CLIENT_SECRET`: The user's secret generated in the [Deci platform](https://console.deci.ai/settings/api-tokens).
    * `DECI_WORKSPACE_ID`: Optional desired workspace ID to use upon a successful login. If not specified, the client will use the first workspace retrieved. The workspace ID should be retrieved from the platform [here](https://console.deci.ai/settings/workspace)

    Args:
        proxy_headers: A dictionary containing headers that will be sent to the proxy (`urllib3.ProxyManager`). In case of HTTP they are being sent with each request, while in the HTTPS/CONNECT case they are sent only once. Could be used for proxy authentication.
        logger: An optional logger to use. If not specified, a default logger will be used.
    """
    self._logger = logger or get_logger(logger_name="deci_platform_client")

    configuration = Configuration(proxy_headers=proxy_headers)
    self.api_client = ApiClient(configuration)
    self.raw_api = PlatformApi(self.api_client)

    self.experiment: "Optional[TrainingExperiment]" = None
    self.experiments_pool: "dict[str, threading.Thread]" = dict()

    client_id = os.getenv("DECI_CLIENT_ID")
    secret = os.getenv("DECI_CLIENT_SECRET")
    if client_id is not None and secret is not None:
        self.login(client_id=client_id, secret=secret)

login(client_id, secret)

Login to the platform.

Tip

This method is called implicitly when you instantiate the client and specify the environment variables:

  • DECI_CLIENT_ID
  • DECI_CLIENT_SECRET

If you haven't done so, you'll need to call this method manually. You can generate the client ID and secret from your platform account

Parameters:

Name Type Description Default
client_id str

The user's client ID generated in the Deci platform.

required
secret str

The user's secret generated in the Deci platform.

required
Source code in deci_platform_client/client/deci_platform_client.py
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
def login(self, client_id: str, secret: str) -> None:
    """Login to the platform.

    Tip:
        This method is called implicitly when you instantiate the client and specify the environment variables:

        -   `DECI_CLIENT_ID`
        -   `DECI_CLIENT_SECRET`

        If you haven't done so, you'll need to call this method manually.
        You can generate the client ID and secret from your [platform account](https://console.deci.ai/settings/api-tokens)

    Args:
      client_id: The user's client ID generated in the Deci platform.
      secret: The user's secret generated in the Deci platform.

    """
    self.api_client.set_up_frontegg_auth(client_id=client_id, secret=secret)
    self._logger.info(
        f"Successfully logged in as {self.api_client.email} (Workspace ID - {self.api_client.workspace_id})."
    )

logout()

Log out from the Deci platform (Disposes the credentials).

Source code in deci_platform_client/client/deci_platform_client.py
137
138
139
140
def logout(self):
    """Log out from the Deci platform (Disposes the credentials)."""
    self.api_client.tear_down_frontegg_auth()
    self._logger.info("Successfully logged out.")