Meanings¶
The API offers methods to retrieve the list of meanings and their definition, to create a new meaning or update an existing one.
Listing meanings¶
The list of all user-defined meanings can be fetched with the list_meanings() method of the DSSClient.
client.list_meanings()
Creating a meaning¶
The create_meaning() method of the DSSClient can be used to create new meanings.
# Creating a declarative meaning
client.create_meaning("meaning_1", "Test meaning", "DECLARATIVE",
description="Test meaning description"
)
# Creating a value list meaning
client.create_meaning("meaning_2", "Test meaning", "VALUES_LIST",
description="Test meaning",
values=["mercury","venus","earth","mars","jupiter","saturn","uranus","neptune"],
normalizationMode="LOWERCASE"
)
# Creating a value mapping meaning
client.create_meaning("meaning_3", "Test meaning", "VALUES_MAPPING",
mappings=[
{"from": "0", "to": "no" },
{"from": "1", "to": "yes" },
{"from": "2", "to": "maybe"}
]
)
# Creating a pattern meaning
client.create_meaning("meaning_4", "Test meaning", "PATTERN", pattern="[A-Z]+")
Editing a meaning¶
Existing meanings can be fetched by calling the get_meaning() method of the DSSClient with the meaning ID. It returns a meaning handle that can be used to get or set the meaning’s definition with get_definition() and set_definition(), as follows:
meaning = client.get_meaning("meaning_1")
definition = meaning.get_definition()
definition['label'] = "New label"
definition['description'] = "New description"
meaning.set_definition(definition)
Assigning a meaning to a column¶
Meanings can be assigned to columns by editing the schema of their dataset and setting the ‘meaning’ field of the column to the ID of the desired meaning.
dataset = client.get_project("TEST_PROJECT").get_dataset("TEST_DATASET")
schema = dataset.get_schema()
schema['columns'][2]['meaning'] = "meaning_1"
dataset.set_schema(schema)
Reference documentation¶
-
class
dataikuapi.dss.meaning.DSSMeaning(client, id)¶ A user-defined meaning on the DSS instance
-
get_definition()¶ Get the meaning’s definition.
Note: this call requires an API key with admin rights
- Returns
the meaning definition, as a dict. The precise structure of the dict depends on the meaning type and is not documented.
-
set_definition(definition)¶ Set the meaning’s definition.
Note: this call requires an API key with admin rights
- Parameters
definition (dict) – the definition for the meaning, as a dict. You should only
set_definitionon a modified version of a dict you retrieved viaget_definition()
-