Models

Managing model objects

class ModelMixin

This class defines all functions related to BlueConic models.

create_model(model)

Creates a new model in BlueConic and returns it as a BlueConic model.

Parameters:

model (Model) – The model to create

Raises:

HTTPError: Request fails

Raises:

ValueError: If the provided model is invalid

Returns:

A model object

Return type:

Model

Usage:
>>> import blueconic
>>> bc = blueconic.Client()
>>> my_model = blueconic.domain.Model("My model", "My model description", blueconic.domain.ModelType.GENERAL)
>>> my_model = bc.create_model(my_model)
>>> print(my_model.id)
f5f54878-8afa-4217-8166-48400ca99ad1
delete_model(id)

Deletes the model with the model ID and returns it as a BlueConic model.

Parameters:

id (str) – The ID of the model

Raises:

HTTPError: Request fails

Returns:

A model object or None if the model does not exist

Return type:

Model

Usage:
>>> import blueconic
>>> bc = blueconic.Client()
>>> model_id = "f5f54878-8afa-4217-8166-48400ca99ad1"
>>> my_model = bc.delete_model(model_id)
>>> print(my_model.name)
My model
get_model(id)

Gets the model with the model ID and returns it as a BlueConic model.

Parameters:

id (str) – The ID of the model

Raises:

HTTPError: Request fails

Returns:

A model object or None if the model does not exist

Return type:

Model

Usage:
>>> import blueconic
>>> bc = blueconic.Client()
>>> model_id = "f5f54878-8afa-4217-8166-48400ca99ad1"
>>> my_model = bc.get_model(model_id)
>>> print(my_model.name)
My model
get_models(start=0, count=10000000)

Gets all models in the system

Raises:

HTTPError: Request fails

Parameters:
  • start (int, optional) – The model to start from. Defaults to 0.

  • count (int, optional) – The number of models to retrieve. Defaults to 10000000.

Returns:

Iterator with Model

Return type:

Iterator[Model]

Usage:
>>> import blueconic
>>> bc = blueconic.Client()
>>> bc.get_models()
<generator object Model.get_models>
update_model(model)

Updates the model with the model ID and returns it as a BlueConic model.

Parameters:

model (Model) – The model to update

Raises:

HTTPError: Request fails

Raises:

ValueError: If the provided model is invalid

Returns:

A model object or None if the model does not exist

Return type:

Model

Usage:
>>> import blueconic
>>> bc = blueconic.Client()
>>> model_id = "f5f54878-8afa-4217-8166-48400ca99ad1"
>>> my_model = bc.get_model(model_id)
>>> my_model.description = "My updated model description"
>>> my_model = bc.update_model(my_model)
>>> print(my_model.description)
My updated model description

Using model objects

class Model
__init__(name, description=None, type=ModelType.GENERAL, labels=None, parameters=None, id=None, model=None, creation_date=None, creator_username=None, last_modified_date=None, last_modified_username=None, model_supplier=None)

This class represents a BlueConic Model.

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

  • description (str, optional) – The description of the model. Defaults to None.

  • type (ModelType) – The type of the model. Defaults to ModelType.GENERAL.

  • labels (Sequence[str], optional) – The labels of the model. Defaults to None.

  • parameters (Parameters, optional) – The parameters of the model. Defaults to None.

  • id (str, optional) – The ID of the model. Defaults to None.

  • model (bytes, optional) – The binary model. Defaults to None.

property creation_date
Returns:

The creation date of this model.

Return type:

Optional[datetime]

property creator_username
Returns:

The username that created this model.

Return type:

Optional[str]

property description
Returns:

Description of this model.

Return type:

Optional[str]

property id
Returns:

ID of this model.

Return type:

Optional[str]

property labels
Returns:

The labels this model.

Return type:

Optional[Sequence[str]

property last_modified_date
Returns:

The last modified date of this model.

Return type:

Optional[datetime]

property last_modified_username
Returns:

The last modified username of this model.

Return type:

Optional[str]

property model
Returns:

The binary model.

Return type:

Optional[bytes]

property name
Returns:

Name of this model.

Return type:

Optional[str]

property parameters
Returns:

The parameters of the model.

Return type:

Optional[Parameters]

property type
Returns:

The type of the model.

Return type:

ModelType

Model types

class ModelType(value)

The supported model types.

GENERAL = 'GENERAL'