Admin API¶
This page describes the admin API, which lets you manage administrative operations in the Driverless AI Python client.
Initialize a client with your server credentials and store them in the variable client.
import driverlessai
client = driverlessai.Client(address='http://localhost:12345', username="py", password="py")
You can check whether the connected user has admin privileges as follows.
client.admin.is_admin
True
Loading all users¶
You can list all the users of Driverless AI as follows.
client.admin.list_users()
['alice', 'bob', 'charlie']
Loading all currently logged in users¶
All of the logged in users of a Driverless AI server can be listed as follows. Note that this functionality is only supported for Driverless AI server version 1.10.5 and later.
client.admin.list_current_users()
['alice', 'bob']
List the datasets of a specified user¶
You can list the datasets created by a specific user as follows.
datasets = client.admin.list_datasets(username="alice")
This returns a list of objects of DatasetProxy and it has the following properties.
dataset = datasets[0]
print("Dataset key : " , dataset.key)
print("Dataset name : " , dataset.name)
print("Dataset owner : " , dataset.owner)
Dataset key : 02fdc4d4-cc7d-11ed-ae20-ac1f6b6b4a0e Dataset name : retail-data.csv Dataset owner : alice
You can also delete a dataset as follows.
dataset.delete()
List the experiments of a specified user¶
You can list all the experiments created by a specific user as follows.
experiments = client.admin.list_experiments(username="alice")
This returns a list of objects of ExperimentProxy and it provides the following methods.
experiment = experiments[0]
print("Completed : " , experiment.is_complete())
print("Running : " , experiment.is_running())
print("Experiment status : " , experiment.status(verbose=1))
Completed : True Running : False Experiment status : Complete 100.00%
Transfer data between users¶
Here, all the data, including datasets and experiments, is transferred to the other user.
client.admin.transfer_data(from_user="alice", to_user="bob")
You can now view the datasets created by Alice under Bob's datasets.
client.admin.list_datasets(username="bob")
[<driverlessai._admin.DatasetProxy at 0x12ac98190>, <driverlessai._admin.DatasetProxy at 0x12ac989a0>]
List scheduled experiments in the DAI server and manipulate execution priorities¶
Here, you have the ability to list the scheduled experiments for a specific user on the DAI server.
scheduled_exps = client.admin.list_scheduled_experiments(user="alice")
/tmp/ipykernel_72777/528868256.py:1: UserWarning: 'Admin.list_scheduled_experiments' is a beta API that is subject to future changes. scheduled_exps = client.admin.list_scheduled_experiments(user="alice")
This API returns a list of ScheduledTask objects, each containing the following properties.
print("Task ID: ", scheduled_exps[5].key)
print("Driverless AI procedure: ", scheduled_exps[5].procedure)
print("Entity ID: ", scheduled_exps[5].entity_id)
print("Task queue: ", scheduled_exps[5].queue)
print("Timeout: ", scheduled_exps[5].timeout)
print("Username: ", scheduled_exps[5].user)
print("Queueing time: ", scheduled_exps[5].queueing_time)
Task ID: 08044682-b12e-11ef-b7d9-ac1f6b00be4b Driverless AI procedure: auto_dl_easy_api_wrapper Entity ID: 07f475a4-b12e-11ef-b7d9-ac1f6b00be4b Task queue: p:gpu Timeout: None Username: alice Queueing time: 1733199673
You are able to modify the execution priority of a specific experiment.
scheduled_exps[5].update_schedule_priority(priority=1)
As a result, this experiment will now be assigned the highest priority in the priority queue.
new_list = client.admin.list_scheduled_experiments(user="alice")
print("1st on GPU: ", new_list[0].entity_id)
/tmp/ipykernel_72777/4107197592.py:1: UserWarning: 'Admin.list_scheduled_experiments' is a beta API that is subject to future changes. new_list = client.admin.list_scheduled_experiments(user="alice")
1st on GPU: 07f475a4-b12e-11ef-b7d9-ac1f6b00be4b
Additionally, you have the capability to reorder the execution priorities of multiple scheduled experiments.
client.admin.reorder_experiment_schedule(
[
{
"username": new_list[1].user,
"key": new_list[1].entity_id
},
{
"username": new_list[0].user,
"key": new_list[0].entity_id
}
]
)