devo_ml.modelmanager#

Easy-to-use ML Model Manager interface.

class Client(url, auth, *, downloader=None, **kwargs)[source]#

A client for ML Model Manager server 2.4.0 and above.

__init__(url, auth, *, downloader=None, **kwargs)[source]#

Creates a Client.

Parameters:
add_model(name, engine, model_file, description=None, force=None)#

Adds a model.

Parameters:
  • name (str) – The name of the models

  • engine (str) – The engine of the model

  • model_file (str) – The path of the file of the model

  • description (Optional[str]) – The description of the model

  • force (Optional[bool]) – Whether to override the model if already exist

Raises:

ModelAlreadyExists – If the model already exists and not force

Return type:

None

find_model(name, download_file=None)#

Finds a model by its name.

Parameters:
  • name (str) – The name of the model

  • download_file (Optional[bool]) – Whether to download the model file

Return type:

Optional[dict]

Returns:

The model data or nothing if the model doesn’t exist

get_model(name, download_file=None)#

Gets a model by its name.

Parameters:
  • name (str) – The name of the model

  • download_file (Optional[bool]) – Whether to download the model file

Raises:

ModelNotFound – If the model doesn’t exist

Return type:

dict

Returns:

The model data

get_models()#

Gets the list of the models in the system.

Return type:

List[dict]

Returns:

The list of the models

property url: str#

The URL of the ML Model Manager server.

Returns:

URL of the ML Model Manager server

class LegacyClient(url, domain, auth, *, downloader=None, **kwargs)[source]#

A client for ML Model Manager server prior to 2.4.0.

__init__(url, domain, auth, *, downloader=None, **kwargs)[source]#

Creates a LegacyClient.

Parameters:
  • url (str) – The URL of the server

  • domain (str) – The domain to connect to

  • kwargs – Options to the underlying requests

add_model(name, engine, model_file, description=None, force=None)#

Adds a model.

Parameters:
  • name (str) – The name of the models

  • engine (str) – The engine of the model

  • model_file (str) – The path of the file of the model

  • description (Optional[str]) – The description of the model

  • force (Optional[bool]) – Whether to override the model if already exist

Raises:

ModelAlreadyExists – If the model already exists and not force

Return type:

None

find_model(name, download_file=None)#

Finds a model by its name.

Parameters:
  • name (str) – The name of the model

  • download_file (Optional[bool]) – Whether to download the model file

Return type:

Optional[dict]

Returns:

The model data or nothing if the model doesn’t exist

get_model(name, download_file=None)#

Gets a model by its name.

Parameters:
  • name (str) – The name of the model

  • download_file (Optional[bool]) – Whether to download the model file

Raises:

ModelNotFound – If the model doesn’t exist

Return type:

dict

Returns:

The model data

get_models()#

Gets the list of the models in the system.

Return type:

List[dict]

Returns:

The list of the models

property url: str#

The URL of the ML Model Manager server.

Returns:

URL of the ML Model Manager server

create_client_from_token(url, token, auth_type=None, download_path=None, **kwargs)[source]#

Creates an ML Model Manager Client with token authentication.

Parameters:
  • url (str) – The URL of the server

  • token (str) – The token to authenticate

  • auth_type (Optional[str]) – The type of authentication to use; STANDALONE or BEARER. get_default_auth_type() is used if is not provided

  • download_path (Optional[str]) – The path where model files will be downloaded. The current directory . is used if not provided.

  • kwargs – Additional options for underlying request, e.g. timeout. These options are the same of the requests library can manage

Return type:

Client

Returns:

A ready to use Client object

create_client_from_profile(profile, path=None, **kwargs)[source]#

Creates an ML Model Manager Client from a profile located in a file.

The profile file is an INI file with this shape:

[dev]
url = https://dev_url
token = 8a3vf98ai28sar1234lkj2l43td6f89a
auth_type = standalone
download_path = ~/models
Parameters:
  • profile (str) – The name of the profile to use

  • path (Optional[str]) – The path, file path or filename to search for a profile

  • kwargs – Additional options for underlying request, e.g. timeout. These options are the same of the Requests library can manage

Return type:

Client

Returns:

A ready to use Client object

get_models(url, token, auth_type=None, **kwargs)[source]#

Gets the list of the models in the system.

Parameters:
  • url (str) – The URL of the server. Must be valid

  • token (str) – The token to authenticate

  • auth_type (Optional[str]) – The type of the authentication, get_default_auth_type is used if it is not provided

  • kwargs – Options to the underlying requests

Return type:

List[dict]

Returns:

The list of the models

get_model(url, token, name, auth_type=None, download_path=None, **kwargs)[source]#

Gets a model by its name.

Parameters:
  • url (str) – The URL of the server. Must be valid

  • token (str) – The token to authenticate

  • name (str) – The name of the model

  • auth_type (Optional[str]) – The type of the authentication, get_default_auth_type is used if it is not provided

  • download_path (Optional[str]) –

  • kwargs – Options to the underlying requests

Raises:

ModelNotFound – If the model doesn’t exist

Return type:

dict

Returns:

The model data

find_model(url, token, name, auth_type=None, download_path=None, **kwargs)[source]#

Finds a model by its name.

Parameters:
  • url (str) – The URL of the server. Must be valid

  • token (str) – The token to authenticate

  • name (str) – The name of the model

  • auth_type (Optional[str]) – The type of the authentication, get_default_auth_type is used if it is not provided

  • download_path (Optional[str]) –

  • kwargs – Options to the underlying requests

Return type:

Optional[dict]

Returns:

The model data or nothing if the model doesn’t exist

add_model(url, token, name, engine, model_file, description=None, auth_type=None, force=None, **kwargs)[source]#

Adds a model.

Parameters:
  • url (str) – The URL of the server. Must be valid

  • token (str) – The token to authenticate

  • name (str) – The name of the model

  • engine (str) – The engine of the model

  • model_file (str) – The path of the file of the model

  • description (Optional[str]) – The description of the model

  • auth_type (Optional[str]) – The type of the authentication, get_default_auth_type is used if it is not provided

  • force (Optional[bool]) – Whether to override the model if already exist

  • kwargs – Options to the underlying requests

Raises:

ModelAlreadyExists – If the model already exists and not force

Return type:

None