Skip to content

Connection

Connection

Connect to the Vectice backend (application).

The Connection class encapsulates a connection to the Vectice App. Thus, it authenticates and connects to Vectice. This allows you to start interacting with your Vectice assets.

A Connection can be initialized in three ways:

  1. Passing the relevant arguments to authenticate and connect to Vectice:

    import vectice
    
    connect = vectice.connect(
        api_token="your-api-key",
        host="https://app.vectice.com",
    )
    
  2. Passing the path to a configuration file:

    import vectice
    
    connect = vectice.connect(config="vectice_config.json")
    
  3. Letting Vectice find the configuration file in specific locations:

    import vectice
    
    connect = vectice.connect()
    

See Connection.connect for more info.

my_workspace property

my_workspace

Retrieve your personal workspace.

Returns:

Type Description
Workspace

Personal workspace.

connect staticmethod

connect(
    api_token=None,
    host=None,
    config=None,
    workspace=None,
    project=None,
)

Method to connect to the Vectice backend (application).

Authentication credentials are retrieved, in order, from:

  1. keyword arguments
  2. configuration file (config parameter)
  3. environment variables
  4. environment files in the following order
    • .vectice of the working directory
    • .vectice of the user home directory
    • .env of the working directory
    • .env of the user home directory
    • /etc/vectice/api.cfg file

This method uses the api_token, host, workspace, project arguments or the JSON config provided. The JSON config file is available from the Vectice webapp when creating an API token.

Parameters:

Name Type Description Default
api_token str | None

The api token provided by the Vectice webapp (API key).

None
host str | None

The backend host to which the client will connect. If not found, the default endpoint https://app.vectice.com is used.

None
config str | None

A JSON config file containing keys VECTICE_API_TOKEN and VECTICE_HOST as well as optionally WORKSPACE and PROJECT.

None
workspace str | None

The name or id of an optional workspace to return.

None
project str | None

The name or id of an optional project to return.

None

Returns:

Type Description
Connection | Workspace | Project

A Connection, Workspace, or Project.

browse

browse(asset)

Get an asset.

Parameters:

Name Type Description Default
asset str

The id of the desired asset.

required

Returns:

Type Description
Workspace | Project | Phase | Iteration | DatasetRepresentation | ModelRepresentation | DatasetVersionRepresentation | ModelVersionRepresentation

The desired asset.

workspace

workspace(workspace)

Get a workspace.

Parameters:

Name Type Description Default
workspace str

The id or the name of the desired workspace.

required

Returns:

Type Description
Workspace

The desired workspace.

project

project(project)

Get a project.

Parameters:

Name Type Description Default
project str

The id of the desired project.

required

Returns:

Type Description
Project

The desired project.

phase

phase(phase)

Get a phase.

Parameters:

Name Type Description Default
phase str

The id of the desired phase.

required

Returns:

Type Description
Phase

The desired phase.

iteration

iteration(iteration)

Get an iteration.

Parameters:

Name Type Description Default
iteration str

The id of the desired iteration.

required

Returns:

Type Description
Iteration

The desired iteration.

dataset

dataset(dataset)

Get a dataset.

Parameters:

Name Type Description Default
dataset str

The id of the desired dataset.

required

Returns:

Type Description
DatasetRepresentation

The representation of the desired dataset.

dataset_version

dataset_version(version)

Get a dataset version's metadata from Vectice.

Parameters:

Name Type Description Default
version str

The id of the desired dataset version. A Dataset version is identified with an ID starting with 'DTV-XXX'.

required

Returns:

Type Description
DatasetVersionRepresentation

The representation of the desired dataset version. (See Representation/ Dataset Version Representation).

model

model(model)

Get a model.

Parameters:

Name Type Description Default
model str

The id of the desired model.

required

Returns:

Type Description
ModelRepresentation

The representation of the desired model.

model_version

model_version(version)

Get a model version's metadata from Vectice.

Parameters:

Name Type Description Default
version str

The id of the desired model version. A model version is identified with an ID starting with 'MDV-XXX'.

required

Returns:

Type Description
ModelVersionRepresentation

The representation of the desired model version (See Representation/ Model Version Representation).

list_workspaces

list_workspaces(
    number_of_items=DEFAULT_NUMBER_OF_ITEMS,
    display_print=True,
)

Retrieves a list of workspaces belonging where you have access to. It will also print the first 10 workspaces as a tabular form.

Parameters:

Name Type Description Default
number_of_items int

The number of workspace to retrieve. Defaults to 30.

DEFAULT_NUMBER_OF_ITEMS
display_print bool

If set to True, it will print the first 10 workspaces in a tabular form.

True

Returns:

Type Description
list[Workspace]

A list of Workspace instances.