Client

Picsellia SDK Client can be used to communicate with Picsellia services.
You need an API Token, available on web platform in Profile Settings > Token.
From this client object, you will be able to retrieve python objects representing your data in the platform.

Examples

client = Client(api_token="a0c9f3bbf7e8bc175494fc44bfc6f89aae3eb9d0")

Arguments

  • api_token (str, optional) : your api token, that can be found on the web platform.
    Defaults to None, client will try to find it into your environment variable as 'PICSELLIA_TOKEN'

  • organization_id : (str or UUID, optional): Specify an organization to connect to by giving its id.
    Defaults to None, you will be connected to your main Organization.

  • organization_name : (str, optional): Specify an organization to connect to by giving its name.
    If id is also given, client will use organization_id.
    Defaults to None, you will be connected to your main Organization.

  • host (str, optional) : Define a custom host used for platform.
    Defaults to our Picsellia environment "https://app.picsellia.com".

  • session (requests.Session, optional) : Set up your own requests.Session object to add headers or proxies.

Properties

  • id Organization UUID connected with this (Client)

  • name Organization name connected with this (Client)


Methods

get_datalake

get_datalake(
   id: Optional[Union[str, UUID]] = None, name: Optional[str] = None
)

Description

Retrieve a datalake of your organization.
By default, is nothing is given, this will return your default datalake.

Examples

datalake = client.get_datalake()
datalake = client.get_datalake(name="default")
datalake = client.get_datalake(id="0188e773-db65-7546-8e3e-b38fe5bed6d2")

Arguments

  • id (str or UUID, optional) : id of the datalake to retrieve. Defaults to None.

  • name (str, optional) : name of the datalake to retrieve. Defaults to None.

Returns

The Datalake of the client that you are using


list_datalakes

list_datalakes()

Description

Retrieve all datalakes linked to this organization

Examples

datalakes = client.list_datalakes()

Returns

List of Datalake of the client that you are using


create_dataset

create_dataset(
   name: str, description: str = '', private: bool = None
)

Description

Create a Dataset in this organization.

This method allows user to create a dataset into the organization currently connected.
A dataset can then be versioned into DatasetVersion.
User can specify name of the dataset, a description and if the dataset is private or not.

Examples

Create a dataset named datatest with data from datalake and version it

foo_dataset = client.create_dataset('foo_dataset')
foo_dataset_version_1 = foo_dataset.create_version('first')
some_data = client.get_datalake().list_data(limit=10)
foo_dataset_version_1.add_data(some_data)

Arguments

  • name (str) : Name of the dataset. It must be unique in the organization.

  • description (str, optional) : A description of the dataset. Defaults to ''.

  • private (bool, optional) : Specify if the dataset is private. Defaults to True.

Returns

A Dataset that you can manipulate, connected to Picsellia


get_dataset

get_dataset(
   name: str
)

Description

Retrieve a dataset by its name

Examples

foo_dataset = client.get_dataset('datatest')
foo_dataset_version = foo_dataset.get_version('first')

Arguments

  • name (str) : Name of the dataset

Returns

A Dataset that you can use and manipulate


get_dataset_by_id

get_dataset_by_id(
   id: Union[UUID, str]
)

Description

Get a dataset by its id

Examples

dataset = client.get_dataset_by_id('918351d2-3e96-4970-bb3b-420f33ded895')

Arguments

  • id (str) : id of the dataset to retrieve

Returns

A Dataset that you can use and manipulate


list_datasets

list_datasets(
   limit: Optional[int] = None, offset: Optional[int] = None,
   order_by: Optional[List[str]] = None
)

Description

Retrieve all dataset of current organization

Examples

datasets = client.list_datasets()

Arguments

  • limit (int, optional) : Limit number of datasets to retrieve. Defaults to None, all datasets will be retrieved.

  • offset (int, optional) : Offset to begin with when listing datasets. Defaults to None, starting at 0.

  • order_by (List[str], optional) : Some fields to order datasets against. Defaults to None, datasets will not be sorted

Returns

A list of Dataset object that belongs to your organization


get_dataset_version_by_id

get_dataset_version_by_id(
   id: Union[UUID, str]
)

Description

Get a dataset version by its id

Examples

dataset_version = client.get_dataset_version_by_id('918351d2-3e96-4970-bb3b-420f33ded895')

Arguments

  • id (str or UUID) : id of the dataset version to retrieve

Returns

A DatasetVersion


create_model

create_model(
   name: str, type: Union[str, InferenceType] = None, framework: Union[str,
   Framework] = None, private: Optional[bool] = None,
   description: str = 'Abrandnewmodel!'
)

Description

Create a new model.

Examples

model = client.create_model(name="foo_model", description="A brand new model!")

Arguments

  • name (str) : Model name to create.

  • description (str) : Description of this model

Returns

A Model object that you can manipulate


get_model_by_id

get_model_by_id(
   id: Union[UUID, str]
)

Description

Retrieve a model by its id

Examples

model = client.get_model_by_id(UUID("d8fae655-5c34-4a0a-a59a-e49c89f20998"))

Arguments

  • id (str) : id of the model that you are looking for

Returns

A Model object that you can manipulate


get_model

get_model(
   name: str
)

Description

Retrieve a model by its name.

Examples

model = client.get_model("foo_model")

Arguments

  • name (str) : name of the model you are looking for

Returns

A Model object that you can manipulate


get_public_model

get_public_model(
   name: str
)

Description

Retrieve a public model by its name.
It can only retrieve public model.

Examples

model = client.get_public_model("foo_public_model")

Arguments

  • name (str) : name of the public model you are looking for

Returns

A Model object that you can manipulate


list_models

list_models(
   limit: Optional[int] = None, offset: Optional[int] = None,
   order_by: Optional[List[str]] = None
)

Description

List all models stored in this organization

This will return all the models stored
If no project is found, will throw a ResourceNotFoundError

Examples

models = client.list_models()

Arguments

  • limit (int, optional) : Limit number of models to retrieve. Defaults to None, all models will be retrieved.

  • offset (int, optional) : Offset to begin with when listing models. Defaults to None, starting at 0.

  • order_by (List[str], optional) : Some fields to order models against. Defaults to None, models will not be sorted

Returns

A list of all Model that belong to this organization


list_public_models

list_public_models(
   limit: Optional[int] = None, offset: Optional[int] = None,
   order_by: Optional[List[str]] = None, name: Optional[str] = None, type: Union[str,
   InferenceType, None] = None
)

Description

List all public models of Picsellia Hub
This will return all public models of the hub

Arguments

  • limit (int, optional) : Limit number of public models to retrieve.
    Defaults to None, all public models will be retrieved.

  • offset (int, optional) : Offset to begin with when listing public models.
    Defaults to None, starting at 0.

  • order_by (List[str], optional) : Some fields to order models against.
    Defaults to None, models will not be sorted

  • name (str, optional) : A name to filter public models. It will return models with name containing
    this parameter. Defaults to None, models will not be filtered

  • type (str or InferenceType, optional) : A type to filter public models on.

Examples

public_detection_models = client.list_public_models(name="yolo")

Returns

A list of all public Model objects


get_model_version_by_id

get_model_version_by_id(
   id: Union[UUID, str]
)

Description

Get a model version by its id

Examples

model_version = client.get_model_version_by_id('918351d2-3e96-4970-bb3b-420f33ded895')

Arguments

  • id (str or UUID) : id of the model version to retrieve

Returns

A ModelVersion


create_project

create_project(
   name: str, description: Optional[str] = None, private: Optional[bool] = True
)

Description

Create a project with given name and parameters

This project will be registered into used organization.

Examples

my_project = client.create_project("my_project", description="My first project!")

Arguments

  • name (str) : name of the project

  • description (str) : description of the project

  • private (bool, deprecated) : This parameter is deprecated

Returns

A Project that you can manipulate to run experiments, or attach dataset


get_project

get_project(
   project_name: str
)

Description

Get a project from its name

Retrieve a project from its name.
Project must belong to used organization.

Examples

my_project = client.get_project("my_project")

Arguments

  • project_name (str) : name of the project to retrieve

Returns

A Project of your organization, you can manipulate to run experiments, or attach dataset


get_project_by_id

get_project_by_id(
   id: Union[UUID, str]
)

Description

Get a project from its id

Retrieve a project from its id.
Project must belong to used organization.
If no project is found, will throw a ResourceNotFoundError

Examples

my_project = client.get_project_by_id("2214aacc-b884-41e1-b70f-420c0cd7eefb")

Arguments

  • id (str) : id of the project to retrieve

Returns

A Project of your organization, you can manipulate to run experiments, or attach dataset


list_projects

list_projects(
   limit: Optional[int] = None, offset: Optional[int] = None,
   order_by: Optional[List[str]] = None
)

Description

List all projects of your organization.

Retrieve all projects of your organization

Examples

projects = client.list_projects()

Arguments

  • limit (int, optional) : Limit number of projects to retrieve. Defaults to None, all projects will be retrieved.

  • offset (int, optional) : Offset to begin with when listing projects. Defaults to None, starting at 0.

  • order_by (List[str], optional) : Some fields to order projects against. Defaults to None, projects will not be sorted

Returns

A list of Project of your organization


get_experiment_by_id

get_experiment_by_id(
   id: Union[UUID, str]
)

Description

Get an experiment by its id

Examples

experiment = client.get_experiment_by_id('918351d2-3e96-4970-bb3b-420f33ded895')

Arguments

  • id (str or UUID) : id of the experiment to retrieve

Returns

A Experiment


get_deployment

get_deployment(
   name: str
)

Description

Get a Deployment from its name.

Examples

deployment = client.get_deployment(
    name="awesome-deploy"
)

Arguments

  • name (str) : auto-generated name of your deployment.

Returns

A Deployment object connected and authenticated to all the services.


get_deployment_by_id

get_deployment_by_id(
   id: Union[UUID, str]
)

Description

Get a Deployment from its name.

Examples

deployment = client.get_deployment_by_id(
    id="YOUR DEPLOYMENT ID"
)

Arguments

  • id (str) : deployment id displayed in your deployment settings.

Returns

A Deployment object connected and authenticated to all the services.


list_deployments

list_deployments(
   limit: Optional[int] = None, offset: Optional[int] = None,
   order_by: Optional[List[str]] = None
)

Description

List all Deployment of your organization

Examples

our_deployments = client.list_deployments()

Arguments

  • limit (int, optional) : number max of results to return

  • offset (int, optional) : offset of page for pagination

  • order_by (list[str], optional) : keys on which deployments shall be sorted

Returns

  • of Deployment : all deployments object connected and authenticated to all the services.

create_deployment

create_deployment(
   model_version: ModelVersion, shadow_model_version: Optional[ModelVersion] = None,
   name: Optional[str] = None, min_threshold: Optional[float] = None,
   target_datalake: Optional[Datalake] = None,
   disable_serving: Optional[bool] = False
)

Description

Create a Deployment from a model.

This method allows you to create a Deployment on Picsellia. You will then have
access to the monitoring dashboard and eventually a hosted endpoint.

Examples

Create a serverless deployment

model_version = client.get_model_version_by_id('918351d2-3e96-4970-bb3b-420f33ded895')
deployment = client.create_deployment(model_version=model_version)

Arguments

  • model_version ModelVersion : ModelVersion to deploy.

  • shadow_model_version (ModelVersion, optional) : ModelVersion to perform shadow predictions.

  • name (str, optional) : Name of your deployment. Defaults to a random name.

  • min_threshold (float, optional) : Threshold of detection scores used by models when predicting. Defaults to 0.

  • target_datalake (Datalake, optional) : Datalake to use when data are pushed into Picsellia.
    Defaults to organization default Datalake.

  • disable_serving (bool, optional) : Whether to not use Picsellia Serving. Defaults to False.

Returns

A Deployment


create_datasource

create_datasource(
   name: str
)

Description

Create a data source into this organization

Examples

data_source = client.create_datasource()

Arguments

  • name (str) : Name of the datasource to create

Returns

A DataSource object that belongs to your organization


get_datasource

get_datasource(
   name: str
)

Description

Retrieve a datasource by its name

Examples

data_sources = client.get_datasource("datasource_1")

Arguments

  • name (str) : Name of the datasource to retrieve

Returns

A DataSource object that belongs to your organization


get_or_create_datasource

get_or_create_datasource(
   name: str
)

Description

Retrieve a datasource by its name or create it if it does not exist.

Examples

datasource = client.get_or_create_datasource("new_source")

Arguments

  • name (str) : Datasource name to retrieve or create

Returns

A DataSource object


list_datasources

list_datasources(
   limit: Optional[int] = None, offset: Optional[int] = None,
   order_by: Optional[List[str]] = None
)

Description

Retrieve all data source of current organization

Examples

data_sources = client.list_datasources()

Arguments

  • limit (int, optional) : Limit number of data sources to retrieve. Defaults to None, all data sources will be retrieved.

  • offset (int, optional) : Offset to begin with when listing data sources. Defaults to None, starting at 0.

  • order_by (List[str], optional) : Some fields to order data sources against. Defaults to None, data sources will not be sorted

Returns

A list of DataSource object that belongs to your organization


create_dataset_tag

create_dataset_tag(
   name: str
)

Description

Create a Dataset Tag, usable only on Dataset objects

Examples

tag = client.create_dataset_tag("global")

Arguments

  • name (str) : Name of the tag

Returns

A Tag object


create_dataset_version_tag

create_dataset_version_tag(
   name: str
)

Description

Create a Dataset Version Tag, usable only on Dataset Version objects

Examples

tag = client.create_dataset_version_tag("train")

Arguments

  • name (str) : Name of the tag

Returns

A Tag object


create_model_tag

create_model_tag(
   name: str
)

Description

Create a Model Tag, usable only on Model objects

Examples

tag = client.create_model_tag("model")

Arguments

  • name (str) : Name of the tag

Returns

A Tag object


create_model_version_tag

create_model_version_tag(
   name: str
)

Description

Create a Model Version Tag, usable only on Model Version objects

Examples

tag = client.create_model_version_tag("initial")

Arguments

  • name (str) : Name of the tag

Returns

A Tag object


create_deployment_tag

create_deployment_tag(
   name: str
)

Description

Create a Deployment Tag, usable only on Deployment objects

Examples

tag = client.create_deployment_tag("operation")

Arguments

  • name (str) : Name of the tag

Returns

A Tag object


list_dataset_tags

list_dataset_tags()

Description

List all Dataset tags, usable only on Dataset objects

Examples

tags = client.list_dataset_tags()

Returns

A list of Tag objects


list_dataset_version_tags

list_dataset_version_tags()

Description

List all Dataset Version tags, usable only on Dataset Version objects

Examples

tags = client.list_dataset_version_tags()

Returns

A list of Tag objects


list_model_tags

list_model_tags()

Description

List all Model tags, usable only on Model objects

Examples

tags = client.list_model_tags()

Returns

A list of Tag objects


list_model_version_tags

list_model_version_tags()

Description

List all Model Version tags, usable only on Model Version objects

Examples

tags = client.list_model_version_tags()

Returns

A list of Tag objects


list_deployment_tags

list_deployment_tags()

Description

List all Deployment tags, usable only on Deployment Version objects

Examples

tags = client.list_deployment_tags()

Returns

A list of Tag objects


find_dataset_tag

find_dataset_tag(
   name: str
)

Description

Find a Dataset tag, usable only on Dataset objects, from its name

Examples

tag = client.find_dataset_tag("global")

Arguments

  • name (str) : Name of the tag

Returns

A Tag object


find_dataset_version_tag

find_dataset_version_tag(
   name: str
)

Description

Find a Dataset Version tag, usable only on Dataset Version objects, from its name

Examples

tag = client.find_dataset_version_tag("train")

Arguments

  • name (str) : Name of the tag

Returns

A Tag object


find_model_tag

find_model_tag(
   name: str
)

Description

Find a Model tag, usable only on Model objects, from its name

Examples

tag = client.find_model_tag("model")

Arguments

  • name (str) : Name of the tag

Returns

A Tag object


find_model_version_tag

find_model_version_tag(
   name: str
)

Description

Find a Model Version tag, usable only on Model version objects, from its name

Examples

tag = client.find_model_version_tag("initial")

Arguments

  • name (str) : Name of the tag

Returns

A Tag object


find_deployment_tag

find_deployment_tag(
   name: str
)

Description

Find a Deployment tag, usable only on Deployment objects, from its name

Examples

tag = client.find_deployment_tag("operation")

Arguments

  • name (str) : Name of the tag

Returns

A Tag object


get_job_by_id

get_job_by_id(
   id: Union[UUID, str]
)

Description

Get a Job from its id.

Examples

job = client.get_job_by_id(
    id="YOUR JOB ID"
)

Arguments

  • id (str) : job id displayed in your job page.

Returns

A Job object