So in the UI you can see the prediction jobs that list all various batch production jobs made whether from the REST API code itself, or via our DataRobot python API client or via the Job definitions. Here's the screenshot of the said UI that i'm referring too
# Importing the libraries
import datarobot as dr
import pandas as pd
import os
import requests
import getpass
print(os.getcwd())
token = getpass.getpass() # use your own token
dr.Client(token = token, endpoint= "https://app.datarobot.com/api/v2" )<p> </p><p><span>Then run this code below to pull the equivalent of the UI I showed earlier. <li-code lang="python">API_ENDPOINT = "https://app.datarobot.com/api/v2/batchPredictions"
# your API key here
API_KEY = token
session = requests.Session()
session.headers = {
'Authorization': 'Bearer {}'.format(API_KEY),
}
# get all the infor
resp = session.get(API_ENDPOINT)
print(resp.status_code)
df = pd.json_normalize(resp.json()["data"])
df.head()
log1 = pd.DataFrame(df.iloc[1,])
with pd.option_context('display.max_rows', 1000, 'display.max_columns', 1000): # more options can be specified also
display(log1)
Unlike the UI, the REST API can give me up to 73 datapoints about the prediction job.
So I'm going to inform this person about this failed job plus a few other handy information above for him to quickly resolve the problem:
datasetid = "5ebc89d21b7b850de6ab9a36"
dataset = dr.Dataset.get(datasetid)
print(dataset)
print('https://app.datarobot.com/ai-catalog/'+datasetid)
Dataset(name='DEMO_LOCATION_AI_Melbourne_House_Prices ', id='5ebc89d21b7b850de6ab9a36')
https://app.datarobot.com/ai-catalog/5ebc89d21b7b850de6ab9a36
Just to check the url works, I click on URL from the output above and this is what I see in the UI:
deploymentid = "6290a642f2d99680864daad8"
deployment = dr.Deployment.get(deploymentid)
print(deployment)
print('https://app.datarobot.com/deployments/'+deploymentid)
Deployment(DEMO_MEL_House_prices) https://app.datarobot.com/deployments/6290a642f2d99680864daad8
Click the link brings us to this:
# The deployment ID
deploymentid = "6290a642f2d99680864daad8"
# defining the api-endpoint
API_ENDPOINT = "https://app.datarobot.com/api/v2/deployments/"
# your API key here
API_KEY = token
session = requests.Session()
session.headers = {
'Authorization': 'Bearer {}'.format(API_KEY),
}
# get all the infor
resp = session.get(API_ENDPOINT+deploymentid)
df = pd.json_normalize(resp.json())
df.T.head(15)
Now I have the project ID (62908fa8929e0d7ef66e388e) I can now provide the Project URL like this:
projectid = "62908fa8929e0d7ef66e388e"
project = dr.Project.get(projectid)
print(project)
print('https://app.datarobot.com/projects/'+projectid)
Project(DEMO_Melbourne_house_prices_NoGIS) https://app.datarobot.com/projects/62908fa8929e0d7ef66e388e
# The deployment ID
projectid = "62908fa8929e0d7ef66e388e"
# defining the api-endpoint
API_ENDPOINT = "https://app.datarobot.com/api/v2/projects/"
# your API key here
API_KEY = token
session = requests.Session()
session.headers = {
'Authorization': 'Bearer {}'.format(API_KEY),
}
# get all the infor
resp = session.get(API_ENDPOINT+'?projectId='+projectid)
df = pd.json_normalize(resp.json())
df.T
I get this below:
So there's a Catalog ID which tells me the project was first created using a dataset in the AI Catalog. So lets go find it:
datasetid = "629086ace265bd23ab9c1de7"
print('https://app.datarobot.com/ai-catalog/'+datasetid)
https://app.datarobot.com/ai-catalog/629086ace265bd23ab9c1de7
Finally, clicking on the link brings me to this:
So in summary I've obtained the reason for the failed prediction job (ie. Incorrect prediction dataset provided to the deployment) and the respective URL links to the project, deployment, training and prediction dataset to check out and compare the differences. All of this is done by calling the REST API itself. The DataRobot Python API client can do most of this too but the REST API will give you a lot more! 😃