How to run a DSS scenario via Endpoint? Error while creating 'client' object

nmadhu20
How to run a DSS scenario via Endpoint? Error while creating 'client' object

Hi Team,

I have a requirement where I need to run a DSS scenario via Endpoint url and I have tried multiple ways to approach this but the issue seems to be while creating a client object.

  1. Tested client = dataiku.api_client() - This gives 'No DSS url or API found'
  2. Tested client = dataikuapi.DSSClient("http://http(s)://IP:16000", "personal_api_secret_key") - generated a personal API Key from profile-> API keys -> New API key. 
  3. Tested dataiku.set_remote_dss("http://http(s)://IP:16000/", "personal_api_secret_key")

Received the following error for point 2 and 3:

 

image.png

 

 

 

It would be really helpful if you can provide a solution for this. Any help is appreciated, Thankyou.

Code for your reference:

import dataiku
import dataikuapi
import pandas as pd, numpy as np

#dataiku.set_remote_dss("http://http(s)://IP:16000/", "personal_api_secret_key")

def do_something(param):
try:

client = dataikuapi.DSSClient("http://http(s)://IP:16000", "personal_api_secret_key")
#client = dataiku.api_client()
project = client.get_project('project_name')

variables = project.get_variables()

variables["standard"]["param"] = param
project.set_variables(variables)


scenario = project.get_scenario('scenario_name')
trigger_fire = scenario.run()
scenario_run = trigger_fire.wait_for_scenario_run()
scenario_run.wait_for_completion()

if not scenario_run.running:
last_runs = scenario.get_last_runs(only_finished_runs=True)
if last_runs[0].outcome == 'SUCCESS':
val = 'SUCESS'
except Exception as e:
val = str(e)
finally:
return val

0 Kudos
3 Replies
HarizoR
Developer Advocate

Hi,

The URL you passed to instantiate the client object seems to be malformed. For example, if your instance lives at https://example.com, the client object should be created as follows:

client = dataikuapi.DSSClient("https://example.com", "personal_api_secret_key")

 If you usually access your instance directly via its IPv4 public address, then you should specify which port you are targeting, for example if the IP is 1.2.3.4 and the port is 16000:

client = dataikuapi.DSSClient("http://1.2.3.4:16000", "personal_api_secret_key")

 

Hope this helps.

Best,

Harizo

0 Kudos
nmadhu20
Author

Hi @HarizoR ,

Thankyou for you reply.

I tried both the URLs (http and http(s)) but got error in both:

  1. client = dataikuapi.DSSClient("http://1.2.3.4:16000", "API_KEY") - This gives the following error

image.png

 

 

 

  1. client = dataikuapi.DSSClient("http(s)://1.2.3.4:16000", "API_KEY") - This gives the following error

Result: Invalid URL 'http(s)://1.2.3.4:16000/dip/publicapi/projects/PROJECT_NAME/variables/': No schema supplied. Perhaps you meant http://http(s)://1.2.3.4:16000/dip/publicapi/projects/PROJECT_NAME/variables/?

 

Could you please tell me if I am missing any step here?

Also, Is the method of generating API Id and secret key correct? Profile -> APIKey -> New Key -> id & secret key.

Thankyou

0 Kudos
HarizoR
Developer Advocate

Hi,

In a standard URL you specify either http or https, you can't have both at the same time. In practice, it means that a URL beginning with http://http(s):// is not valid. To make sure that you are using the correct URL to reach your DSS instance, please refer to the content of your browser's navigation bar when you visit it. Don't hesitate to ask the administrator of your DSS instance if you have further doubts.

As for the key generation process, I confirm that it is the correct one to create personal API keys.

Best,

Harizo

0 Kudos