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.0and above.- __init__(url, auth, *, downloader=None, **kwargs)[source]#
Creates a
Client.- Parameters:
url (
str) – The URL of the server. Must be validauth (
Callable[[PreparedRequest],PreparedRequest]) – The authentication to usedownloader (
Optional[Callable[[dict],str]]) – The downloader to usekwargs – Options to the underlying requests
- add_model(name, engine, model_file, description=None, force=None)#
Adds a model.
- Parameters:
- Raises:
ModelAlreadyExists – If the model already exists and not force
- Return type:
- find_model(name, download_file=None)#
Finds a model by its name.
- get_model(name, download_file=None)#
Gets a model by its name.
- Parameters:
- Raises:
ModelNotFound – If the model doesn’t exist
- Return type:
- Returns:
The model data
- get_models()#
Gets the list of the models in the system.
- 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.
- add_model(name, engine, model_file, description=None, force=None)#
Adds a model.
- Parameters:
- Raises:
ModelAlreadyExists – If the model already exists and not force
- Return type:
- find_model(name, download_file=None)#
Finds a model by its name.
- get_model(name, download_file=None)#
Gets a model by its name.
- Parameters:
- Raises:
ModelNotFound – If the model doesn’t exist
- Return type:
- Returns:
The model data
- get_models()#
Gets the list of the models in the system.
- create_client_from_token(url, token, auth_type=None, download_path=None, **kwargs)[source]#
Creates an ML Model Manager
Clientwith token authentication.- Parameters:
url (
str) – The URL of the servertoken (
str) – The token to authenticateauth_type (
Optional[str]) – The type of authentication to use;STANDALONEorBEARER.get_default_auth_type()is used if is not provideddownload_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
requestslibrary can manage
- Return type:
- Returns:
A ready to use Client object
- create_client_from_profile(profile, path=None, **kwargs)[source]#
Creates an ML Model Manager
Clientfrom 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:
- Return type:
- 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 validtoken (
str) – The token to authenticateauth_type (
Optional[str]) – The type of the authentication,get_default_auth_typeis used if it is not providedkwargs – Options to the underlying requests
- Return type:
- 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:
- Raises:
ModelNotFound – If the model doesn’t exist
- Return type:
- Returns:
The model data
- find_model(url, token, name, auth_type=None, download_path=None, **kwargs)[source]#
Finds a model by its name.
- Parameters:
- Return type:
- 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 validtoken (
str) – The token to authenticatename (
str) – The name of the modelengine (
str) – The engine of the modelmodel_file (
str) – The path of the file of the modelauth_type (
Optional[str]) – The type of the authentication,get_default_auth_typeis used if it is not providedforce (
Optional[bool]) – Whether to override the model if already existkwargs – Options to the underlying requests
- Raises:
ModelAlreadyExists – If the model already exists and not force
- Return type: