Records

class gretel_client.projects.records.RecordHandler(model: Model, *, record_id: str = None, data_source: Optional[DataSourceTypes] = None, params: Optional[dict] = None, ref_data: Optional[RefDataTypes] = None)

Manages a model’s record handler. After a model has been created and trained, a record handler may be used to “run” the model.

Parameters
  • model – The model to generate a record handler for

  • record_id – The id of an existing record handler.

property artifact_types

Returns a list of valid artifacts for the record handler.

property billing_details

Get billing details for the current job.

cancel()

Cancels the active job.

property container_image

Return the container image for the job.

property data_source

Returns the data source with which the record handler was configured, if any.

If the record handler has been submitted, returns the resolved artifact ID. Otherwise, returns the originally-supplied data_source argument.

delete()

Deletes the record handler.

download_artifacts(target_dir: Union[str, pathlib.Path])

Given a target directory, either as a string or a Path object, attempt to enumerate and download all artifacts associated with this Job

Parameters

target_dir – The target directory to store artifacts in. If the directory does not exist, it will be created for you.

property errors

Return any errors associated with the model.

property external_data_source

Returns True if the data source is external to Gretel Cloud. If the data source is a Gretel Artifact, returns False.

property external_ref_data

Returns True if the data refs are external to Gretel Cloud. If the data refs are Gretel Artifacts, returns False.

Retrieves a signed S3 link that will download the specified artifact type.

Parameters

artifact_type – Artifact type to download.

get_artifacts() → Iterator[Tuple[str, str]]

List artifact links for all known artifact types.

get_report_summary(report_path: Optional[str] = None) → Optional[dict]

Return a summary of the job results :param report_path: If a report_path is passed, that report

will be used for the summary. If no report path is passed, the function will check for a cloud report artifact.

property instance_type

Return CPU or GPU based on the record handler’s run requirements.

property logs

Returns run logs for the job.

property model_type

Returns the parent model type of the record handler.

property params

Returns the params with which the record handler was configured, if any.

peek_report(report_path: Optional[str] = None) → Optional[dict]

Return a summary of the job results.

Parameters

report_path – If a report_path is passed, that report will be used for the summary. If no report path is passed, the function will check for a cloud based artifact.

poll_logs_status(wait: int = - 1, callback: Optional[Callable] = None) → Iterator[gretel_client.projects.jobs.LogStatus]

Returns an iterator that may be used to tail the logs of a running Model.

Parameters
  • wait – The time in seconds to wait before closing the iterator. If wait is -1 (WAIT_UNTIL_DONE), the iterator will run until the model has reached a “completed” or “error” state.

  • callback – This function will be executed on every polling loop. A callback is useful for checking some external state that is working on a Job.

property print_obj

Returns a printable object representation of the job.

property ref_data

Returns the ref_data with which the record handler was configured, if any.

refresh()

Update internal state of the job by making an API call to Gretel Cloud.

property runner_mode

Returns the runner_mode of the job. May be one of manual or cloud.

property status

The status of the job. Is one of gretel_client.projects.jobs.Status.

submit_cloud() → gretel_client.projects.jobs.Job

Submit this model to be scheduled for runing in Gretel Cloud.

Returns

The response from the Gretel API.

submit_manual() → gretel_client.projects.jobs.Job

Submit this Job to the Gretel Cloud API, which will create the job metadata but no runner will be started. The Model instance can now be passed into a dedicated runner.

Returns

The response from the Gretel API.

property traceback

Returns the traceback associated with any job errors.

upload_data_source(_validate: bool = True) → Optional[str]

Resolves and uploads the data source specified in the model config.

If the data source is already a Gretel artifact, the artifact will not be uploaded.

Returns

A Gretel artifact key.

upload_ref_data(_validate: bool = True) → gretel_client.cli.utils.parser_utils.RefData

Resolves and uploads ref data sources specificed in the model config.

If the ref data are already Gretel artifacts, we’ll return the ref data as-is.

Returns

A RefData instance that contains the new Gretel artifact values.