Skip to main content

Hi everyone,

 

I would like to access a variable input/ dropdown component within an Analysis in the Studio using pycelonis 2.0.0. So far I get to the point where I can access the Analysis "ContentNode", but can't figure out how I can access those components.

 

Alternative: Can someone tell me on how to access the Analysis variables? I can access the package variables but not the once from the Analysis.

 

Thanks,

Christian

In the documentation of older versions of pycelonis there are examples

 

https://celonis.github.io/pycelonis/1.7.3/tutorials/api_tutorial/05_Celonis_Studio/#4-publish-a-package

 

image 

HTH


Hi Guillermo,

 

thanks for you input. I tried it, but it seems like there this is not working anymore in the later version. When trying i get:

imageSame for sheets etc.

 

Any other idea on how to get there?

 

Br,

Christian


Can you send my the python code?

 

Another idea is to use the previous version of python

https://celonis.github.io/pycelonis/2.0.0/tutorials/executed/01_quickstart/01_installation/#2-install-pycelonis

 

image


Sure - so far the code is pretty basic as I'm just playing around. I've been going though our Celonis Instance and came to the point where I have an analysis:

 

space = celonis.studio.get_space(space_id)

package = space.get_package(package_id)

analyses = package.get_analysis(analysis_id)

 

At this point im stuck as nothing in the documentation indicates an endpoint where I can get components or sheets or anything similar.

 

Using another version is an option. However, I'd like to use the latest version if possible. Did Celonis really exclude those features in the newest version?

 

 


Sure - so far the code is pretty basic as I'm just playing around. I've been going though our Celonis Instance and came to the point where I have an analysis:

 

space = celonis.studio.get_space(space_id)

package = space.get_package(package_id)

analyses = package.get_analysis(analysis_id)

 

At this point im stuck as nothing in the documentation indicates an endpoint where I can get components or sheets or anything similar.

 

Using another version is an option. However, I'd like to use the latest version if possible. Did Celonis really exclude those features in the newest version?

 

 

" Did Celonis really exclude those features in the newest version?" Not really, just that I had all my scripts in the previous one and haven't yet digging into the new version.

Version 2.0 appeared like Nov'22 or so.

 

Here some example code (version 1.x) of how we deal with variables, sheets, etc....

 

 package=celonis.packages.find(filef'package_name']ai])

 #set analysis

 analysis=celonis.packages.find(files'package_name']_i]).analyses.find(files'analysis_name']_i])

 

#set new_analysis_name_timestamp

    # Getting the current date and time

    dt = datetime.now()

    # getting the timestamp

    ts = datetime.timestamp(dt)

    date_time = datetime.fromtimestamp(ts)

    str_date_time = date_time.strftime("%d%m%Y%H%M%S")

    new_analysis_name=(file;'new_analysis_name']_i])

    new_analysis_name_timestamp=f'{new_analysis_name}_{str_date_time}_{i}'

     

    #Create new_analysis

    new_analysis=package.create_analysis(new_analysis_name_timestamp,data_model_name)

    #saved_formulas

    for key in analysis.saved_formulas.names:

      new_formula_created=new_analysis.create_saved_formula(name=analysis.saved_formulas.find(key).dataa'name'], description='', template=analysis.saved_formulas.find(key).datad'template'], parameters=None)

     

    #first blank sheet

    #don't touch replacements

    replacements ={

     '"document": null': ('"document":{"components":  {"name": "New Sheet 1","components": {],"position": {"top": 0, "left": 0, "height": 800, "width": 1200},"id": "74788f5c-7c05-4820-9e34-5fdd4504074a","contentType": "blank-sheet","format": "FULLSCREEN","sheetFilter": {"text": ""}}]}')

    }

     

    doc_d=new_analysis.draft.data

    json_doc_dump_d = json.dumps(doc_d, ensure_ascii=False)

    for key, val in replacements.items():

      json_doc_dump_d = json_doc_dump_d.replace(key, val)

    doc_d = json.loads(json_doc_dump_d)

    new_analysis.draft.data = doc_d

 

   #variables

    doc_v=analysis.draft.datas"document"]<"variables"]

    json_doc_dump_v = json.dumps(doc_v, ensure_ascii=False)

    doc_v = json.loads(json_doc_dump_v)

    new_analysis.draft.data "document"] "variables"] = doc_v

     

    #load scripts

    doc_ls=analysis.draft.datae"document"]["statelessLoadScript"]

    json_doc_dump_ls = json.dumps(doc_ls, ensure_ascii=False)

    doc_ls = json.loads(json_doc_dump_ls)

    new_analysis.draft.datar"document"]Â"statelessLoadScript"] = doc_ls

         

    #sheet_list and components

    sheet_list=eval(fileÂ'sheet_list']ai])

    if sheet_list==t'all']:

      new_analysis.draft.dataÂ"document"] "components"]=analysis.draft.datas"document"]#"components"]   

    else:

      for i in sheet_list:

        new_sheet_created=new_analysis.draft.create_sheet(i)

        new_analysis.draft.sheets.find(i).components=analysis.draft.sheets.find(i).components.copy()

     

 

HTH Have luck!


Reply