Python API: Error when running queries on 4.5

#1

Hi all,

We just upgraded one of our environments to 4.5 and now, when retrieving table information from the datamodel we get an error. Basic API interaction works, running queries and obtaining data does not.

Exception:
Traceback (most recent call last):

  File "<ipython-input-4-ef39afedecef>", line 16, in <module>
    print("Table: {} with {} records".format(table.name, table.count_table()))

  File "C:\dev\Anaconda\lib\site-packages\celonis_tools\model\folder.py", line 2320, in count_table
    df = self.parent.query(query)

  File "C:\dev\Anaconda\lib\site-packages\celonis_tools\model\folder.py", line 1838, in query
    status, message = execution.wait_for_final_status()

  File "C:\dev\Anaconda\lib\site-packages\celonis_tools\model\folder.py", line 1513, in wait_for_final_status
    status, message = self.get_status()

  File "C:\dev\Anaconda\lib\site-packages\celonis_tools\model\folder.py", line 1529, in get_status
    ret = self.api.get(self.id, "status")

  File "C:\dev\Anaconda\lib\site-packages\celonis_tools\model\folder.py", line 1493, in id
    return self.data["result"]["id"]

KeyError: 'result'

Code:
with CelonisSession(URL, localconfig.username, api_token=localconfig.token,api_secret=localconfig.secret, verify=use_tls) as session:
#And work with the connection/session

    analyses = pd.DataFrame()
    for a in Analysis.load_all():
        f = a.folder.parent    
        print("%i: %s in %s"%(a.id,a.name, f.path))
#        analyses.append()

    analysis = Analysis(244) #VoorbereidenNP Fundamentals op ACC
    datamodel=analysis.datamodel #get the corresponding data model
    
#    A data model can have multiple tables, loop through them like this, in this case to show the row counts
    for table in datamodel.tables:
        print("Table: {} with {} records".format(table.name, table.count_table()))

Code runs fine until the last loop, where looping over the tables and getting table.name still works, but count_table() doesn’t.
I also tested other queries or downloading the data from the table, both fail, causing me to believe there is an issues with the packages. I installed pyarrow as per the manual, but could it be I’m still missing something?

0 Likes

#2

Hi Joos,

which version of the celonis_tools are you using? For CPM4.5, a new version (version 1.0.0) is required. It can be downloaded from “System Settings”->“celonis tools” from your CPM4.5 instance.

Let me know if this solves the problem!

David

0 Likes

#3

Ok, I have asked the sys admin to send me the file, as I’m currently using 0.6.1.

Just checking: the file I can download via my.celonis.de is not v1.0.0 and/or recently updated?

0 Likes

#4

For 4.5, it will not be available on my.celonis.de

However, we just pushed it to our pypi repo, such that you also can install the package using
pip install --extra-index-url https://pypi.celonis.cloud -U celonis_tools

The documentation on everything will be available soon.

David

1 Like

#5

Hi David,

Thanks for publishing this to the pypi Celonis repro.

I had a small (local) issue with self-signed certificates, but downloading the .whl file directly worked.
I can now indeed fetch data from the Celonis 4.5 instance so thanks a lot!

0 Likes