How to clear remote dss with Python API?

Solved!
yashpuranik
How to clear remote dss with Python API?

The link https://doc.dataiku.com/dss/latest/python-api/outside-usage.html suggests that we can use

dataiku.clear_remote_dss() to clear remote configuration.

picture1.png

However, I see the following error. What is the correct approach here?

picture2.png

The use case I am working on is creating a dataset with the list of users on a different DSS instance for user management purposes. The python recipe is running into issues:

import dataiku

# Authenticate with other node

dataiku.set_remote_dss("OTHER_NODE", "KEY")
client = dataiku.api_client()

# Get list of users on the other node
users = client.list_users()
users = [(user["displayName"], user["login"], user["email"], user["enabled"]) for user in users]
users_df = pd.DataFrame(users, columns=["Display Name", "username", "email", "is_active"])

# Write list of users on other node in a dataset on current node

dataiku.clear_remote_dss()
users_dataset = dataiku.Dataset("users")
users_dataset.write_with_schema(users_df)

yashpuranik
0 Kudos
1 Solution
shashank
Dataiker
You don’t have to (and should not) do a set_remote_dss just in order to do a dataiku.api_client(). You should rather instantiate a client for your remote DSS this way:
import dataiku
import dataikuapi

host = "OTHER_NODE"
apiKey = "KEY"
client = dataikuapi.DSSClient(host, apiKey)

# And then the code does not need to change at all:


# Get list of users on the other node
users = client.list_users()
users = [(user["displayName"], user["login"], user["email"], user["enabled"]) for user in users]
users_df = pd.DataFrame(users, columns=["Display Name", "username", "email", "is_active"])
# Write list of users on other node in a dataset on current node
users_dataset = dataiku.Dataset("users")
users_dataset.write_with_schema(users_df)
Much easier, simple to read, and no worries about versions

View solution in original post

0 Kudos
3 Replies
shashank
Dataiker

Try this: dataiku.clear_remote_dss_config()

This function is renamed in v11 as "dataiku.clear_remote_dss", since you're using v10 the above statement should work.

 

0 Kudos
shashank
Dataiker
You don’t have to (and should not) do a set_remote_dss just in order to do a dataiku.api_client(). You should rather instantiate a client for your remote DSS this way:
import dataiku
import dataikuapi

host = "OTHER_NODE"
apiKey = "KEY"
client = dataikuapi.DSSClient(host, apiKey)

# And then the code does not need to change at all:


# Get list of users on the other node
users = client.list_users()
users = [(user["displayName"], user["login"], user["email"], user["enabled"]) for user in users]
users_df = pd.DataFrame(users, columns=["Display Name", "username", "email", "is_active"])
# Write list of users on other node in a dataset on current node
users_dataset = dataiku.Dataset("users")
users_dataset.write_with_schema(users_df)
Much easier, simple to read, and no worries about versions
0 Kudos
yashpuranik
Author

Thank you, I can confirm this works!

yashpuranik
0 Kudos

Labels

?

Setup info

?
A banner prompting to get Dataiku