Index
Module to interact with Knowledge Models.
This module contains class to interact with Knowledge Models in Studio.
Typical usage example:
```python
knowledge_model = package.get_knowledge_model(ANALYSIS_ID)
knowledge_model = package.create_knowledge_model(content)
knowledge_model.delete()
```
KnowledgeModel ¶
Bases: ContentNode
Knowledge model object to interact with knowledge model specific studio endpoints.
invalid_content
class-attribute
instance-attribute
¶
serialization_type
class-attribute
instance-attribute
¶
working_draft_id
class-attribute
instance-attribute
¶
activated_draft_id
class-attribute
instance-attribute
¶
show_in_viewer_mode
class-attribute
instance-attribute
¶
public_available
class-attribute
instance-attribute
¶
asset_metadata_transport
class-attribute
instance-attribute
¶
from_transport
classmethod
¶
Creates high-level content node object from given ContentNodeTransport.
Parameters:
-
client
(Client
) –Client to use to make API calls for given content node.
-
content_node_transport
(ContentNodeTransport
) –ContentNodeTransport object containing properties of content node.
Returns:
-
ContentNode
–A ContentNode object with properties from transport and given client.
update ¶
Pushes local changes of content node to EMS and updates properties with response from EMS.
is_package
staticmethod
¶
Returns whether content node transport is package.
Parameters:
-
content_node_transport
(ContentNodeTransport
) –Content node transport to check.
Returns:
-
bool
–Boolean if transport is package.
is_folder
staticmethod
¶
Returns whether content node transport is package.
Parameters:
-
content_node_transport
(ContentNodeTransport
) –Content node transport to check.
Returns:
-
bool
–Boolean if transport is folder.
is_analysis
staticmethod
¶
Returns whether content node transport is analysis.
Parameters:
-
content_node_transport
(ContentNodeTransport
) –Content node transport to check.
Returns:
-
bool
–Boolean if transport is analysis.
is_knowledge_model
staticmethod
¶
Returns whether content node transport is knowledge model.
Parameters:
-
content_node_transport
(ContentNodeTransport
) –Content node transport to check.
Returns:
-
bool
–Boolean if transport is knowledge model.
is_action_flow
staticmethod
¶
Returns whether content node transport is action flow.
Parameters:
-
content_node_transport
(ContentNodeTransport
) –Content node transport to check.
Returns:
-
bool
–Boolean if transport is action flow.
is_view
staticmethod
¶
Returns whether content node transport is view.
Parameters:
-
content_node_transport
(ContentNodeTransport
) –Content node transport to check.
Returns:
-
bool
–Boolean if transport is view.
is_simulation
staticmethod
¶
Returns whether content node transport is simulation.
Parameters:
-
content_node_transport
(ContentNodeTransport
) –Content node transport to check.
Returns:
-
bool
–Boolean if transport is simulation.
is_skill
staticmethod
¶
Returns whether content node transport is skill.
Parameters:
-
content_node_transport
(ContentNodeTransport
) –Content node transport to check.
Returns:
-
bool
–Boolean if transport is skill.
create_kpi ¶
Creates new kpi with id, display name, and pql in given knowledge model.
Parameters:
-
id_
(str
) –Id of new kpi.
-
display_name
(str
) –Display name of new kpi.
-
pql
(str
) –PQL query of new kpi.
-
**kwargs
(Any
, default:{}
) –Additional parameters set for KpiMetadata object.
Returns:
-
Kpi
–A Kpi object for newly created kpi.
Examples:
Create a kpi:
get_kpi ¶
Gets kpi with given id.
Parameters:
-
id_
(str
) –Id of kpi.
Returns:
-
Kpi
–A Kpi object for kpi with given id.
get_kpis ¶
create_variable ¶
Creates new variable with id, display name, and pql in given knowledge model.
Parameters:
-
id_
(str
) –Id of new variable.
-
display_name
(str
) –Display name of new variable.
-
value
(str
) –Value of new variable.
-
**kwargs
(Any
, default:{}
) –Additional parameters set for VariableMetadata object.
Returns:
-
Variable
–A Variable object for newly created variable.
Examples:
Create a variable:
get_variable ¶
Gets variable with given id.
Parameters:
-
id_
(str
) –Id of variable.
Returns:
-
Variable
–A Variable object for variable with given id.
get_variables ¶
Gets all variables of knowledge model.
Returns:
-
CelonisCollection[Variable]
–A list containing all variables.
create_filter ¶
Creates new filter with id, display name, and pql in given knowledge model.
Parameters:
-
id_
(str
) –Id of new filter.
-
display_name
(str
) –Display name of new filter.
-
pql
(str
) –PQL query of new filter.
-
**kwargs
(Any
, default:{}
) –Additional parameters set for FilterMetadata object.
Returns:
-
Filter
–A Filter object for newly created filter.
Examples:
Create a filter:
get_filter ¶
Gets filter with given id.
Parameters:
-
id_
(str
) –Id of filter.
Returns:
-
Filter
–A Filter object for filter with given id.
get_filters ¶
Gets all filters of knowledge model.
Returns:
-
CelonisCollection[Filter]
–A list containing all filters.
get_content ¶
get_content(
with_variable_replacement=True,
with_autogenerated_data_model_data=True,
with_default_values=True,
validate_pql=True,
with_unknown_variables_validation=True,
)
Returns final read only content of knowledge model (including inherited properties).
Parameters:
-
with_variable_replacement
(bool
, default:True
) –Specifies if variables are replaced by their values in knowledge model.
-
with_autogenerated_data_model_data
(bool
, default:True
) –Specifies whether auto generated KPIs and records for data model should be added to content.
-
with_default_values
(bool
, default:True
) –Specifies if default values are added to content.
-
validate_pql
(bool
, default:True
) –Specifies if PQLs in knowledge model are validated.
-
with_unknown_variables_validation
(bool
, default:True
) –Specifies if unknown variables are validated.
Returns:
-
Optional[FinalKnowledgeModelContent]
–Knowledge model content.
Examples:
Extract data based on PQLs from knowledge model:
from pycelonis.pql import PQL, PQLColumn
record = knowledge_model.get_content().records.find_by_id('ACTIVITIES')
attribute = record.attributes.find_by_id('ACTIVITY_EN')
query = PQL() + attribute.get_column()
data_query, query_environment = knowledge_model.resolve_query(query)
df = data_model.export_data_frame(data_query, query_environment)
resolve_query ¶
Returns Data Query and Query environment for a knowledge model.
Warning
The method knowledge_model.resolve_query
has been deprecated and will be removed in future
versions. Please use SaolaPy from now on to export PQL queries:
Use this method to resolve queries that are based on Knowledge Model content. The returned DataQuery and QueryEnvironment can than be used to query data via DataModel.export_data_frame.
Parameters:
-
query
(PQL
) –PQL query to be resolved.
-
draft
(bool
, default:True
) –If true, uses draft of knowledge model, if false uses published version.
-
**kwargs
(Any
, default:{}
) –Key word arguments are passed to
get_content
function.
Returns:
-
Tuple[DataQuery, Optional[QueryEnvironment]]
–Returns Data Query and Query environment.
Examples:
Extract data based on PQLs from knowledge model:
from pycelonis.pql import PQL, PQLColumn
record = knowledge_model.get_content().records.find_by_id('ACTIVITIES')
attribute = record.attributes.find_by_id('ACTIVITY_EN')
query = PQL() + attribute.get_column()
data_query, query_environment = knowledge_model.resolve_query(query)
df = data_model.export_data_frame(data_query, query_environment)