API Reference

afs.models module

class afs.models.models(target_endpoint=None, instance_id=None, auth_code=None, token=None)[source]

Bases: afs.get_env.AfsEnv

create_model_repo(model_repository_name)[source]

Create a new model repository. (Support v2 API)

Parameters:model_repository_name (str) – (optional)The name of model repository.
Returns:the new uuid of the repository
decrypt_model(model, decrypt_key)[source]

Decrypt model.

Parameters:
  • model (object) – the object of model
  • decrypt_key (str) – use decrypt_key to decrypt the model
Returns:

object

delete_model(model_name, model_repository_name=None)[source]

Delete model.

Parameters:
  • model_name – model name.
  • model_repository_name – model repository name.
Returns:

bool

delete_model_repository(model_repository_name)[source]

Delete model repository.

Parameters:model_repository_name – model repository name.
Returns:bool
download_model(save_path, model_repository_name=None, model_name=None, last_one=False)[source]

Download model from model repository to a file.

Parameters:
  • model_repository_name (str) – The model name exists in the model repository
  • save_path (str) – The path exist in the file system
  • model_name (str) – Get the specific model file from the model reposiotry, if getting last one value for None.
  • last_one (str) – Get the last uploading model from the model repository.
get_latest_model_info(model_repository_name=None)[source]

Get the latest model info, including created_at, tags, evaluation_result. (Support v2 API)

Parameters:model_repository_name – (optional)The name of model repository.
Returns:dict. the latest of model info in model repository.
get_model_id(model_name=None, model_repository_name=None, last_one=True)[source]

Get model id by model name.

Parameters:
  • model_name (str) – model name. No need if last_one is true.
  • model_repository_name (str) – model respository name where the model is.
  • last_one (bool) – auto get the model_repository last one model
Returns:

str model id

get_model_info(model_name, model_repository_name=None)[source]

Get model info, including created_at, tags, evaluation_result. (V2 API)

Parameters:
  • model_name – model name
  • model_repository_name – The name of model repository.
Returns:

dict model info

get_model_repo_id(model_repository_name=None)[source]

Get model repository by name.

Parameters:model_repository_name (str) –
Returns:str model repository id
set_blob_credential(blob_endpoint, encode_blob_accessKey, encode_blob_secretKey, blob_record_id, bucket_name)[source]

Set blob credential when upload the big model.

Parameters:
  • blob_endpoint (str) – blob endpoint
  • encode_blob_accessKey (str) – blob accessKey encode with base64
  • encode_blob_secretKey (str) – blob secretKey encode with base64
  • blob_record_id (str) – MD5 with instance_id + ‘_’ + accessKey
  • bucket_name (str) – blob bucket name
upload_model(model_path, accuracy=None, loss=None, tags={}, extra_evaluation={}, feature_importance=None, coefficient=None, model_repository_name=None, model_name=None, encrypt_key='')[source]

Upload model to model repository. (Support v2 API)

Parameters:
  • model_path (str) – (required) model filepath
  • accuracy (float) – (optional) model accuracy value, between 0-1
  • loss (float) – (optional) model loss value
  • tags (dict) – (optional) tag from model
  • extra_evaluation (dict) – (optional) other evaluation from model
  • model_name (str) – (optional) Give model a name or a default name
  • model_repository_name (str) – (optional) model_repository_name
  • feature_importance (list) – (optional) feature_importance is the record how the features important in the model
  • coefficient (list) – (optional) coefficient indicates the direction of the relationship between a predictor variable and the response
  • encrypt_key (str) – (optional) If there is a encrypt_key, use the encrypt_key to encrypt the model
Returns:

dict. the information of the upload model.