Uploading a Model

From Web-App

You can easily load a model using the web app.

You will first need to select a CatalogTag and Algorithm.

Use the load button in the Model section of the sidebar and the use the control panel to provide a name and file to upload.

The currently selected Algorithm and CatalogTag will be associated with the Model.

The Model pickle file metadata will be checked to ensure that the Algorithm and CatalogTag are consistent.

Note that by default an estimator with the same name and default values of the configuration parameters will be created at the same time.

From python on client side

rail_pz_service.client.load.PZRailLoadClient.model(self, **kwargs)

Load a Model into the database

Parameters:

**kwargs (Any) – Input parameter. Must match LoadModelQuery

Returns:

Newly created and loaded model

Return type:

models.Model

Example

client = RZRailClient()
new_model = client.load.model(
    name='my_gpz_com_cam_model',
    path='local_version_of_file.pkl',
    algo_name='GPZEstimator',
    catalog_tag_name='com_cam',
)

From client CLI

pz-rail-service-client load model

Load CatalogTags from RailEnv

pz-rail-service-client load model [OPTIONS]

Options

--name <name>

Name for a particular DB row

--path <path>

Name for a particular DB row

--algo-name <algo_name>

Name of associated algorithm

--catalog-tag-name <catalog_tag_name>

Name of associated catalog tag

-o, --output <output>

Output format. Summary table if not specified.

Options:

yaml | json

From python on server side

async rail_pz_service.db.cache.Cache.load_model_from_file(self, session, name, path, algo_name, catalog_tag_name)

Import a model file to the archive area and add a Model

Parameters:
  • session (async_scoped_session) – DB session manager

  • name (str) – Name for new Model

  • path (Path) – Path to input file. Note that it will be copied to DB area

  • algo_name (str) – Name of Algorithm that uses the model

  • catalog_tag_name (str) – Name of CatalogTag that described contents of file

Returns:

Newly created Model

Return type:

Model

Raises:

Example

from structlog import get_logger
logger = get_logger(__name__)
cache  = pz_rail_service.db.Cache.shared_cache(logger)
new_model = await cache.load_model_from_file(
    session,
    name='my_gpz_com_cam_model',
    path='local_version_of_file.pkl',
    algo_name='GPZEstimator',
    catalog_tag_name='com_cam',
)

From server CLI

pz-rail-service-admin load model

Load CatalogTags from RailEnv

pz-rail-service-admin load model [OPTIONS]

Options

--name <name>

Name for a particular DB row

--path <path>

Name for a particular DB row

--algo-name <algo_name>

Name of associated algorithm

--catalog-tag-name <catalog_tag_name>

Name of associated catalog tag

-o, --output <output>

Output format. Summary table if not specified.

Options:

yaml | json