How to clear remote dss with Python API?

yashpuranik
yashpuranik Partner, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2022, Neuron 2023 Posts: 69 Neuron

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)

Tagged:

Best Answer

  • Shashank
    Shashank Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 27 Dataiker
    Answer ✓
    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 dataikuimport dataikuapihost = "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 nodeusers = 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 nodeusers_dataset = dataiku.Dataset("users")users_dataset.write_with_schema(users_df)
    Much easier, simple to read, and no worries about versions

Answers

  • Shashank
    Shashank Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 27 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.

  • yashpuranik
    yashpuranik Partner, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2022, Neuron 2023 Posts: 69 Neuron

    Thank you, I can confirm this works!

Setup Info
    Tags
      Help me…