Job
- class datarobot.models.Job
Tracks asynchronous work being done within a project.
- Variables:
id (
int) – The ID of the job.project_id (
str) – The ID of the project the job belongs to.status (
str) – The status of the job - will be one ofdatarobot.enums.QUEUE_STATUS.job_type (
str) – What kind of work the job is doing - will be one ofdatarobot.enums.JOB_TYPE.is_blocked (
bool) – If true, the job is blocked (cannot be executed) until its dependencies are resolved.
- classmethod get(project_id, job_id)
Fetches one job.
- Parameters:
project_id (
str) – The identifier of the project in which the job resides.job_id (
str) – The job ID.
- Returns:
job – The job.
- Return type:
- Raises:
AsyncFailureError – Querying this resource gave a status code other than 200 or 303.
- cancel()
Cancel this job. If this job has not finished running, it will be removed and canceled.
- Return type:
None
- get_result(params=None)
- Parameters:
params (
dictorNone) – Query parameters to be added to request to get results.
Notes
For
featureEffectsjobs, thesourceparam is required to define source, otherwise the default is training.- Returns:
result –
- The return type depends on the job type:
for model jobs, a Model is returned
for predict jobs, a pandas.DataFrame (with predictions) is returned
for
featureImpactjobs, a list of dicts by default (seewith_metadataparameter of theFeatureImpactJobclass and itsget()method).for
primeRulesetsjobs, a list of Rulesetsfor
primeModeljobs, a PrimeModelfor primeDownloadValidation jobs, a PrimeFile
for predictionExplanationInitialization jobs, a PredictionExplanationsInitialization
for
predictionExplanationsjobs, a PredictionExplanationsfor
featureEffectsjobs, a FeatureEffects.
- Return type:
object- Raises:
JobNotFinished – If the job is not finished, the result is not available.
AsyncProcessUnsuccessfulError – If the job errored or was aborted.
- get_result_when_complete(max_wait=600, params=None)
- Parameters:
max_wait (
Optional[int]) – How long to wait for the job to finish.params (
dict, optional) – Query parameters to be added to the request.
- Returns:
result – The return type is the same as would be returned by Job.get_result.
- Return type:
object- Raises:
AsyncTimeoutError – If the job does not finish in time.
AsyncProcessUnsuccessfulError – If the job errored or was aborted.
- refresh()
Updates the job object with the latest job data from the server.
- Return type:
None
- wait_for_completion(max_wait=600)
Waits for job to complete.
- Parameters:
max_wait (
Optional[int]) – How long to wait for the job to finish.- Return type:
None
- class datarobot.models.TrainingPredictionsJob
- classmethod get(project_id, job_id, model_id=None, data_subset=None)
Fetches one training predictions job.
The resulting
TrainingPredictionsobject will be annotated with model_id and data_subset.- Parameters:
project_id (
str) – The identifier of the project in which the job resides.job_id (
str) – The job ID.model_id (
str) – The identifier of the model used for computing training predictions.data_subset (
dr.enums.DATA_SUBSET, optional) – Data subset used for computing training predictions.
- Returns:
job – The job.
- Return type:
- refresh()
Updates the job object with the latest job data from the server.
- Return type:
None
- cancel()
Cancel this job. If this job has not finished running, it will be removed and canceled.
- Return type:
None
- get_result(params=None)
- Parameters:
params (
dictorNone) – Query parameters to be added to request to get results.
Notes
For
featureEffectsjobs, thesourceparam is required to define source, otherwise the default is training.- Returns:
result –
- The return type depends on the job type:
for model jobs, a Model is returned
for predict jobs, a pandas.DataFrame (with predictions) is returned
for
featureImpactjobs, a list of dicts by default (seewith_metadataparameter of theFeatureImpactJobclass and itsget()method).for
primeRulesetsjobs, a list of Rulesetsfor
primeModeljobs, a PrimeModelfor primeDownloadValidation jobs, a PrimeFile
for predictionExplanationInitialization jobs, a PredictionExplanationsInitialization
for
predictionExplanationsjobs, a PredictionExplanationsfor
featureEffectsjobs, a FeatureEffects.
- Return type:
object- Raises:
JobNotFinished – If the job is not finished, the result is not available.
AsyncProcessUnsuccessfulError – If the job errored or was aborted.
- get_result_when_complete(max_wait=600, params=None)
- Parameters:
max_wait (
Optional[int]) – How long to wait for the job to finish.params (
dict, optional) – Query parameters to be added to the request.
- Returns:
result – The return type is the same as would be returned by Job.get_result.
- Return type:
object- Raises:
AsyncTimeoutError – If the job does not finish in time.
AsyncProcessUnsuccessfulError – If the job errored or was aborted.
- wait_for_completion(max_wait=600)
Waits for job to complete.
- Parameters:
max_wait (
Optional[int]) – How long to wait for the job to finish.- Return type:
None
- class datarobot.models.ShapMatrixJob
- classmethod get(project_id, job_id, model_id=None, dataset_id=None)
Fetches one SHAP matrix job.
- Parameters:
project_id (
str) – The identifier of the project in which the job resides.job_id (
str) – The job identifier.model_id (
str) – The identifier of the model used for computing prediction explanations.dataset_id (
str) – The identifier of the dataset against which prediction explanations should be computed.
- Returns:
job – The job.
- Return type:
- Raises:
AsyncFailureError – Querying this resource gave a status code other than 200 or 303.
- refresh()
Update the object with the latest job data from the server.
- Return type:
None
- cancel()
Cancel this job. If this job has not finished running, it will be removed and canceled.
- Return type:
None
- get_result(params=None)
- Parameters:
params (
dictorNone) – Query parameters to be added to request to get results.
Notes
For
featureEffectsjobs, thesourceparam is required to define source, otherwise the default is training.- Returns:
result –
- The return type depends on the job type:
for model jobs, a Model is returned
for predict jobs, a pandas.DataFrame (with predictions) is returned
for
featureImpactjobs, a list of dicts by default (seewith_metadataparameter of theFeatureImpactJobclass and itsget()method).for
primeRulesetsjobs, a list of Rulesetsfor
primeModeljobs, a PrimeModelfor primeDownloadValidation jobs, a PrimeFile
for predictionExplanationInitialization jobs, a PredictionExplanationsInitialization
for
predictionExplanationsjobs, a PredictionExplanationsfor
featureEffectsjobs, a FeatureEffects.
- Return type:
object- Raises:
JobNotFinished – If the job is not finished, the result is not available.
AsyncProcessUnsuccessfulError – If the job errored or was aborted.
- get_result_when_complete(max_wait=600, params=None)
- Parameters:
max_wait (
Optional[int]) – How long to wait for the job to finish.params (
dict, optional) – Query parameters to be added to the request.
- Returns:
result – The return type is the same as would be returned by Job.get_result.
- Return type:
object- Raises:
AsyncTimeoutError – If the job does not finish in time.
AsyncProcessUnsuccessfulError – If the job errored or was aborted.
- wait_for_completion(max_wait=600)
Waits for job to complete.
- Parameters:
max_wait (
Optional[int]) – How long to wait for the job to finish.- Return type:
None
- class datarobot.models.FeatureImpactJob
Custom Feature Impact job to handle different return value structures.
The original implementation had just the the data and the new one also includes some metadata.
In general, we aim to keep the number of Job classes low by just utilizing the job_type attribute to control any specific formatting; however in this case when we needed to support a new representation with the _same_ job_type, customizing the behavior of _make_result_from_location allowed us to achieve our ends without complicating the _make_result_from_json method.
- classmethod get(project_id, job_id, with_metadata=False)
Fetches one job.
- Parameters:
project_id (
str) – The identifier of the project in which the job resides.job_id (
str) – The job ID.with_metadata (
bool) – To make this job return the metadata (i.e., the full object of the completed resource), set the with_metadata flag to True.
- Returns:
job – The job.
- Return type:
- Raises:
AsyncFailureError – Querying this resource gave a status code other than 200 or 303.
- cancel()
Cancel this job. If this job has not finished running, it will be removed and canceled.
- Return type:
None
- get_result(params=None)
- Parameters:
params (
dictorNone) – Query parameters to be added to request to get results.
Notes
For
featureEffectsjobs, thesourceparam is required to define source, otherwise the default is training.- Returns:
result –
- The return type depends on the job type:
for model jobs, a Model is returned
for predict jobs, a pandas.DataFrame (with predictions) is returned
for
featureImpactjobs, a list of dicts by default (seewith_metadataparameter of theFeatureImpactJobclass and itsget()method).for
primeRulesetsjobs, a list of Rulesetsfor
primeModeljobs, a PrimeModelfor primeDownloadValidation jobs, a PrimeFile
for predictionExplanationInitialization jobs, a PredictionExplanationsInitialization
for
predictionExplanationsjobs, a PredictionExplanationsfor
featureEffectsjobs, a FeatureEffects.
- Return type:
object- Raises:
JobNotFinished – If the job is not finished, the result is not available.
AsyncProcessUnsuccessfulError – If the job errored or was aborted.
- get_result_when_complete(max_wait=600, params=None)
- Parameters:
max_wait (
Optional[int]) – How long to wait for the job to finish.params (
dict, optional) – Query parameters to be added to the request.
- Returns:
result – The return type is the same as would be returned by Job.get_result.
- Return type:
object- Raises:
AsyncTimeoutError – If the job does not finish in time.
AsyncProcessUnsuccessfulError – If the job errored or was aborted.
- refresh()
Updates the job object with the latest job data from the server.
- Return type:
None
- wait_for_completion(max_wait=600)
Waits for job to complete.
- Parameters:
max_wait (
Optional[int]) – How long to wait for the job to finish.- Return type:
None