Database setup

The database setup needs to happen on the server. It can either be done with the server CLI, or in python.

Intializing the database

pz-rail-service-admin init

Initialize the DB

pz-rail-service-admin init [OPTIONS]

Options

--reset

Delete all existing database data.

Loading basic content from RailEnv using the Server CLI

pz-rail-service-admin load algos-from-env

Load algorithms from RailEnv

pz-rail-service-admin load algos-from-env [OPTIONS]

Options

-o, --output <output>

Output format. Summary table if not specified.

Options:

yaml | json

pz-rail-service-admin load catalog-tags-from-env

Load CatalogTags from RailEnv

pz-rail-service-admin load catalog-tags-from-env [OPTIONS]

Options

-o, --output <output>

Output format. Summary table if not specified.

Options:

yaml | json

Loading basic content from RailEnv using python on server side

async rail_pz_service.db.cache.Cache.load_algorithms_from_rail_env(self, session)

Load all of the CatEstimator algorithsm from RailEnv

Parameters:

session (async_scoped_session) – DB session manager

Returns:

Newly created Algorithm database rows

Return type:

list[Algorithm]

Raises:

RAILIntegrityError – Rows already exist in database

Example

from structlog import get_logger
logger = get_logger(__name__)
cache = pz_rail_service.db.Cache.shared_cache(logger)
algos = await cache.load_algorithms_from_rail_env(
    session,
)
async rail_pz_service.db.cache.Cache.load_catalog_tags_from_rail_env(self, session)

Load all of the CatalogTag from RAIL classes

Parameters:

session (async_scoped_session) – DB session manager

Returns:

Newly created CatalogTag database rows

Return type:

list[CatalogTag]

Example

from structlog import get_logger
logger = get_logger(__name__)
cache = pz_rail_service.db.Cache.shared_cache(logger)
catalog_tags = await cache.load_catalog_tags_from_rail_env(
    session,
)