Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Added on March 26, 2025 3:43PM
Likes: 0
Replies: 3
Hi there,
I am trying to set some project variable using set_variable() method of Dataiku API. But it somehow only runs once. Below is my DASH webapp code snippet for reference -
import threading import dataiku import time def start_execution_publish_to_pbi(config_id):
try:
project = dataiku.Project()
variables = project.get_variables()
variables['standard']['projection_publish_to_pbi_running_process'] = config_id
project.set_variables(variables)
time.sleep(10)
project = dataiku.Project() #Does not update the project variable
variables = project.get_variables()
variables['standard']['projection_publish_to_pbi_running_process'] = ''
project.set_variables(variables)
except Exception as e:
project = dataiku.Project()
variables = project.get_variables()
variables['standard']['projection_publish_to_pbi_running_process'] = ''
project.set_variables(variables) thread = threading.Thread(target=start_execution_publish_to_pbi, args=('101',))
thread.daemon = True # To ensure threads don't block app shutdown
thread.start()
Can some one please assist here why the set_variable() does not works second time?
P.S. - I am trying to implement a task queue which will not trigger the start_execution_publish_to_pbi() if there is already some process running.
Operating system used: Windows
Operating system used: Windows
What's the point of the Try/Except. Doesn't seem to make any sense to me. You trap the exception and do nothing with it. I would remove the Try/Except first and understand why is the code failing.
The code is not throwing any exception. The set_variables(variables) called second time at the end of function does not update the Project Variables.
I understand the code is not throwing any exceptions but that's because you are traping the exception with Try/Except and not even printing it. So remove the Try/Except and see whether the code really works or not. And if it doesn't what's the error.