Skip to main content

I've written a basic script to access a knowledge model and want to edit its PQL and update it to the cloud.

 

space = celonis.studio.get_spaces().find('Value Monitoring')

package = space.get_packages().find('Value Monitoring')

knowledge_model = package.get_knowledge_models().find('Value Monitor-devFlo2')

content = knowledge_model.get_content()

kpis = knowledge_model.get_kpis()

kpiss0].pql

kpi = kpiss0]

kpi.pql = "Test"



knowledge_model.update()  # local to EMS

 

The ML Workbench has "USE" rights on the knowledge model (no other options available) and "USE and EDIT" rights in the package.

 

These are the logs:

o2025-01-09 18:38:30,804] INFO: No `base_url` given. Using environment variable 'CELONIS_URL'
r2025-01-09 18:38:30,805] INFO: No `api_token` given. Using environment variable 'CELONIS_API_TOKEN'
r2025-01-09 18:38:30,853] WARNING: Your PyCelonis Version 2.11.1 is outdated (Newest Version: 2.12.0). Please upgrade the package via: pip install --extra-index-url=https://pypi.celonis.cloud/ pycelonis pycelonis_core --upgrade
r2025-01-09 18:38:30,884] WARNING: KeyType is not set. Defaulted to 'APP_KEY'.
r2025-01-09 18:38:30,904] INFO: Initial connect successful! PyCelonis Version: 2.11.1
r2025-01-09 18:38:31,123] INFO: `package-manager` permissions: n'$ACCESS_CHILD', 'EDIT_ALL_SPACES', 'MANAGE_PERMISSIONS', 'CREATE_SPACE', 'DELETE_ALL_SPACES']
r2025-01-09 18:38:31,124] INFO: `task-mining` permissions: n]
r2025-01-09 18:38:31,125] INFO: `compute-live` permissions: n]
r2025-01-09 18:38:31,125] INFO: `action-engine` permissions: n]
r2025-01-09 18:38:31,126] INFO: `workflows` permissions: n]
r2025-01-09 18:38:31,126] INFO: `team` permissions: n]
r2025-01-09 18:38:31,127] INFO: `process-repository` permissions: n]
r2025-01-09 18:38:31,127] INFO: `transformation-center` permissions: n]
r2025-01-09 18:38:31,129] INFO: `storage-manager` permissions: n]
r2025-01-09 18:38:31,129] INFO: `event-collection` permissions: n'$ACCESS_CHILD']
r2025-01-09 18:38:31,130] INFO: `user-provisioning` permissions: n]
r2025-01-09 18:38:31,131] INFO: `ml-workbench` permissions: n'USE_ALL_APPS', 'VIEW_CONFIGURATION']



Why can't I update my changes from the python notebook into the EMS?

Depending on your version of PyCelonis, there are a couple of ways to do it. If you’re using the most recent version, here is the code chunk you’re looking for.

kpi = knowledge_model.create_kpi(
id_="TEST_KPI",
display_name="Test KPI",
pql='COUNT("BSEG"."BELNR")',
)

This is where I got it from - link


@matt.witty13 I can create new KPIs using the provided snippet, however I can’t edit old already existing ones, that is what I am having problems with.


ok I found my mistake. Instead of the knowledge model object one should apply the update function on the KPI object.

Not: knowledge_model.update()

Do: kpi.update()


Ah misunderstood your question! Yes fantastic. The PyCelonis page is very informative.


Reply