キー値¶
Key values associated with a DataRobot model, deployment, job, or other DataRobot entities are key-value pairs containing information about the related entity. キーと値の各ペアの内容は次のとおりです。
- Name: The unique and descriptive name of the key (for the model package or version).
- Value type: The data type of the value associated with the key. 使用可能なタイプは、文字列、数値、ブール値、URL、画像、データセット、Pickle、バイナリ値、JSON、またはYAMLです。
- Category: The type of model information provided by the key value. The possible types are training parameter, metric, tag, artifact, and runtime parameter.
- Value: The stored data or file.
カスタムコンプライアンスドキュメントのテンプレートには、文字列、数値、ブール値、画像、データセットのキー値を含めることができます。
In addition, with key values for registered models, when you generate compliance documentation for a model package and reference a supported key value in the template, DataRobot inserts the matching values from the associated model package.
キー値の管理¶
Use the following commands to manage key values.
Create a key value¶
To create a key value, use dr.KeyValue.create:
import datarobot as dr
registered_model_id = "65ccb597732422fa2297199e"
key_value = dr.KeyValue.create(
registered_model_id,
dr.KeyValueEntityType.REGISTERED_MODEL,
"my-kv-name",
dr.KeyValueCategory.TAG,
dr.KeyValueType.STRING,
"tag-name",
)
key_value.id
>>> '65f32822be17d11dec9ebdfb'
List key values¶
To list all key values available to the current user, use dr.KeyValue.list:
import datarobot as dr
registered_model_id = "65ccb597732422fa2297199e"
key_values = dr.KeyValue.list(registered_model_id, dr.KeyValueEntityType.REGISTERED_MODEL)
key_values
>>> [KeyValue('my-kv-name')]
Retrieve a key value¶
To get a key value by unique identifier, use dr.KeyValue.get:
import datarobot as dr
key_value = dr.KeyValue.get("65f32822be17d11dec9ebdfb")
key_value
>>> KeyValue('my-kv-name')
Find key values by name¶
To find a key value by name, use dr.KeyValue.find. Provide the entity ID, entity type, and key value name:
import datarobot as dr
key_value = dr.KeyValue.find("65f32822be17d11dec9ebdfb", dr.KeyValueEntityType.REGISTERED_MODEL, "my-kv-name")
key_value
>>> KeyValue('my-kv-name')
Update key values¶
To get a key value by unique identifier and update it, use dr.KeyValue.get() and then update():
import datarobot as dr
key_value = dr.KeyValue.get("65f32822be17d11dec9ebdfb")
key_value.update(value=4.7)
key_value.update(value_type=dr.KeyValueType.STRING, value="abc")
key_value.update(name="new-kv-name")
Get key value data¶
To get the value from a key value, use dr.KeyValue.get_value(). Provide the key value ID:
import datarobot as dr
key_value = dr.KeyValue.get("65f32822be17d11dec9ebdfb")
key_value.update(value=4.7)
key_value.get_value()
>>> 4.7
key_value.update(value_type=dr.KeyValueType.STRING, value="abc")
key_value.get_value()
>>> "abc"
key_value.update(value_type=dr.KeyValueType.BOOLEAN, value=True)
key_value.get_value()
>>> True
Delete key values¶
To get a key value by unique identifier and delete it, use dr.KeyValue.get() and then delete():
import datarobot as dr
key_value = dr.KeyValue.get("65f32822be17d11dec9ebdfb")
key_value.delete()