Use variables define in Shiny webapp as DSS global variables

flo1
Level 1
Use variables define in Shiny webapp as DSS global variables

Hello,

I would like to use variables define in shiny webapp as DSS global variables.

I can't convert them into a format that can pass. I get an error every time.
I have an error every time.

Does anyone have any ideas or examples ?

thank you!

 

*****************************************************

my code

py_run_string('

 import dataiku

import pandas as pd, numpy as np

from dataiku import pandasutils as pdu

 client = dataiku.api_client().get_project("m_tgo_franceshelfpriceoptimisation_20210608")

 def update_global_var(variable_name, variable_value):

 global_variables = client.get_variables()

print(global_variables)

 global_variables["standard"][variable_name] = variable_value

client.set_variables(global_variables)

print(global_variables)

   ' )

## APPEL DE LA FONCTION PYTHON

   main <- import_main()

 main$update_global_var(variable_name = 'SELECT_31', variable_value = 'some_value')

#py_capture_output(main$update_global_var(variable_name = 'SELECT_31', variable_value = input$SELECT_31))   

df_test <- reactive({ py_capture_output(main$update_global_var(variable_name = 'SELECT_31', variable_value = input$SELECT_31))})

 py_capture_output(main$update_global_var(variable_name = 'SELECT_31', variable_value = df_test()))   

 

0 Kudos
1 Reply
AlexT
Dataiker
Dataiker

Hi,

I suspect input$SELECT_31 is an R object. 

Have you tried converting it to a string? In the server.r file add

E.g https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/toString

string_select_31 <- toString(input$SELECT_31)

 

Then use string_select_31 as the variable_value . Let me know if that helps.

 

Kind Regards,

 

0 Kudos
A banner prompting to get Dataiku DSS
Public