Vault#
lit.sdk.vault
#
This module provides functionality for interacting with the Lit vault, including managing and retrieving items stored in the vault.
VaultItem
#
Represents a single item in the Lit vault.
canvas
property
#
Retrieves design canvas for the vaulted model.
Returns:
| Type | Description |
|---|---|
dict | None
|
The design canvas. |
details
property
#
Retrieves detailed information about this vault item from the Lit vault.
Returns:
| Type | Description |
|---|---|
dict | None
|
A dictionary containing detailed information about this vault item, or None if it does not exist in the vault. |
Examples:
Getting the details of a vault item
>>> item = VaultItem("contoso", "my_model1")
>>> item.details
{'host': 'bogdan', 'project': 'my_project', 'runid': 3, 'epoch': 1, 'model': 'model.1.keras', 'name': 'my_model1', 'value': None, 'notes': None, 'color': None, 'dateAdded': '2024-07-12 19:40:19.783233+00:00', 'workers': []}
Getting a non-existent vault item
name = name
instance-attribute
#
The name of this item.
team = team
instance-attribute
#
The name of the team that this item belongs to.
__init__(team, name)
#
Initializes a new instance of VaultItem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team
|
str
|
The team which owns the VaultItem. |
required |
name
|
str
|
The name of the VaultItem. |
required |
get_data_from_path(path, start=None, stop=None, step=1)
#
Retrieve input data from a given asset path and format it for model prediction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The path of the asset |
required |
start
|
number
|
Start index [optional] |
None
|
stop
|
number
|
Stop index [optional] |
None
|
Returns:
| Type | Description |
|---|---|
[ndarray]
|
List of numpy arrays filled with data retrieved from the asset. |
Examples:
Load the model, prepare input from a random index into the first datafile of the first asset used to train the model, make a prediction.
load_model()
#
Loads the model.
Returns:
| Type | Description |
|---|---|
Model
|
A model grouping layers into an object with training/inference features. |
Examples:
Load a model.
>>> model = vault_item.load_model()
>>> model.layers
[<InputLayer name=input_1, built=True>,
<Lambda name=lambda, built=True>,
<Lambda name=lambda_1, built=True>,
<Flatten name=flatten, built=True>,
<Flatten name=flatten_1, built=True>,
<Concatenate name=dense_40c93684-299b-41df-b233-912a47954a84_concatenate, built=True>,
<Dropout name=dropout, built=True>,
<Dense name=dense_40c93684-299b-41df-b233-912a47954a84_0, built=True>,
<GaussianNoise name=gaussian_noise, built=True>,
<Dropout name=dropout_1, built=True>,
<Dense name=end_d1657694-e01d-409b-aec8-15b33a9aefbc, built=True>]
rename(new_name)
#
Renames this vault item to the specified name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_name
|
str
|
The desired new name for this vault item. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary containing the status and message of the rename operation. |
Examples:
Renaming a vault item
>>> item = VaultItem("contoso", "my_model1")
>>> item.rename("my_model2")
{'status': 'SUCCESS', 'message': 'Vault item my_model1 has been renamed my_model2.'}
>>> item.name
'my_model2'
Renaming a non-existent vault item
>>> item = VaultItem("contoso", "my_model0")
>>> item.rename("new_name")
{'status: 'ERROR', 'message': 'item my_model0 not found'}
>>> item.name
'my_model0'
Renaming a vault item to the name of another vault item
zeros()
#
Creates a single batch of initialized inputs for the underlying model. This can be passed directly into predict.
Returns:
| Type | Description |
|---|---|
[ndarray]
|
List of numpy arrays of zero-values that match the expected shape of inputs to the neural network. |
Examples:
Get model, get zeros, make a prediction.
get_vault_items(team)
#
Retrieves a list of vault items for the specified team from the Lit vault.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team
|
str
|
The name of the team to retrieve vault items for. |
required |
Returns:
| Type | Description |
|---|---|
list[VaultItem]
|
list[VaultItem]: A list of VaultItem objects representing the vault items for the specified team. |
Examples:
import_model(team, path, features=[], name=None)
#
Import a Tensorflow model into the Lit vault.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team
|
str
|
The name of the team to retrieve vault items for. |
required |
path
|
str
|
The path to the saved model. |
required |
name
|
str
|
The name of the new model (optional). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
VaultItem |
VaultItem
|
A VaultItem objects representing the vault item for the imported model. |
Examples: