Dataiku scenario

Solved!
mahesh_s
Level 1
Dataiku scenario

Hi everyone,

I created a scenario that runs on hourly basis. Now if scenarios fails for any reason I want to deactivate auto trigger so it won't run until I troubleshoot the failure.

Is there any easy way of doing this through the visual interface?

0 Kudos
1 Solution
AgatheG
Dataiker

Hi mahesh_s,

I think a good way to handle your use case would be to add a custom Python step (in the Add step dropdown, Code > Execute Python code) at the end of your scenario, with Run this step set on the If a prior step failed option.

To unset the auto-trigger field of your scenario, you could for instance use the snippet below, filling YOUR_PROJECT_KEY and YOUR_SCENARIO_ID with the proper values:

from dataiku import api_client
project = api_client().get_project(YOUR_PROJECT_KEY)
scenario_settings = project.get_scenario(YOUR_SCENARIO_ID).get_settings()

scenario_settings.active = False
scenario_settings.save()

 

 

Hope this helps,

 

Agathe

View solution in original post

0 Kudos
5 Replies
AgatheG
Dataiker

Hi mahesh_s,

I think a good way to handle your use case would be to add a custom Python step (in the Add step dropdown, Code > Execute Python code) at the end of your scenario, with Run this step set on the If a prior step failed option.

To unset the auto-trigger field of your scenario, you could for instance use the snippet below, filling YOUR_PROJECT_KEY and YOUR_SCENARIO_ID with the proper values:

from dataiku import api_client
project = api_client().get_project(YOUR_PROJECT_KEY)
scenario_settings = project.get_scenario(YOUR_SCENARIO_ID).get_settings()

scenario_settings.active = False
scenario_settings.save()

 

 

Hope this helps,

 

Agathe

0 Kudos
mahesh_s
Level 1
Author

Hi Agathe, Thanks. Your solution has worked for me.

cbimou
Level 2

Hi @AgatheG ,

How can i process if i want to use multiple host in my code please? 

Here is the context: I used a python script that runs a scenario on a single dataiku instance and it works.
I would now like to use the same scenario pointing to two dataiku differents instances at the same time.
To do this, I have added the info of both instances (see the code) but the code returns only the results of the first instance. I would like it to go around the instances and give me the results.

Here is the code I use. Could you please help me to solve this problem?

 

import sys
import ConfigParser
import logging
import dataikuapi
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

# Define the connections
# get project host and api key

# Designer node of dev
designer_host = "host a"
designer_api_key = "key a"

# Designer node of qualif
designer_q_host = "host b"
designer_q_api_key = "key b"

# initializing client
client = dataikuapi.DSSClient(host=['designer_host','designer_q_host'], api_key=['designer_q_host','designer_q_api_key'])

client._session.verify = False

# get all project keys
project_keys = client.list_project_keys()
print(project_keys)

# iterating through all the projects keys
for p in project_keys:
# getting the project as the object type
project = client.get_project(p)

# iterating through all the scenarios within the project
for scenario in project.list_scenarios(as_type="objects"๐Ÿ˜ž
print("In %s project, running a scenario %s..." % (p, scenario.id))
try:
scenario.run_and_wait()
print("...finished successfully")
print("--------------------------------------")
except:
print("...finished with errors. Check the logs for more details")
print("--------------------------------------")

Thanks in advance

0 Kudos
AgatheG
Dataiker

Hi cbimou,

I think your problem comes from this line:

# initializing client
client = dataikuapi.DSSClient(host=['designer_host','designer_q_host'], api_key=['designer_q_host','designer_q_api_key'])

 

If I remember correctly, the parameters host and api_key should be strings, not lists. You should have one DSSClient per instance.

 

That being said, if this does not answer your issue and we need to elaborate further, please create a new post. This post is quite older and has been answered, and your current issue is not directly related.

 

Hope that helps!

 

 

Agathe

cbimou
Level 2

Thanks @AgatheG, i used a factorization method and it works for me