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.
parent_node_key
class-attribute
instance-attribute
ΒΆ
parent_node_id
class-attribute
instance-attribute
ΒΆ
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
ΒΆ
created_by_id
class-attribute
instance-attribute
ΒΆ
creation_date
class-attribute
instance-attribute
ΒΆ
created_by_name
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.
copy_to ΒΆ
copy_to(
destination_package,
destination_team_domain,
overwrite=False,
delete_source=False,
**kwargs
)
Copies a content node to the specified domain and package in the same realm (ex. eu-1).
Parameters:
-
destination_package
(Package
) βThe Package object to copy the asset to.
-
destination_team_domain
(str
) βThe
of the destination team url: https:// . .celonis.cloud/ -
overwrite
(bool
, default:False
) βIf true, any node with the same key will be overwritten. If false, a PyCelonisNodeAlreadyExistsError will be raised.
-
delete_source
(bool
, default:False
) βIf true, deletes the node from the source. If false, keeps the source node.
-
**kwargs
(Any
, default:{}
) βAdditional parameters set for ContentNodeCopyTransport
Returns:
-
ContentNodeTransport
βA read-only content node transport object of the copied asset.
Examples:
Copy a package:
package = space.get_package(<package_id>)
new_package = space.create_package("NEW_PACKAGE")
new_package.publish()
copied_package_transport = package.copy_to(new_package, <destination_team_domain>)
Copy a package asset:
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.
update ΒΆ
Pushes local changes of knowledge model serialized_content
attribute to EMS.
This only pushes changes made to serialized_content
. Other attributes of the knowledge model will not be
updated. Therefore, any changes have to be made by adjusting serialized_content
.
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,
)