Classes and methods for working with Gretel Models

class gretel_client.projects.models.Model(project: None, model_config: Union[str, pathlib.Path, dict, None] = None, model_id: Optional[str] = None)

Represents a Gretel Model. This class can be used to train new models or run and lookup existing ones.

property artifact_types

Returns a list of artifact types associated with the model.

property billing_details

Get billing details for the current Job


Cancels the active job

property container_image

Return the container image for the job

create_record_handler_obj(data_source: Optional[str] = None, params: Optional[dict] = None, ref_data: Union[str, Dict[str, str], List[str], Tuple[str], None] = None)gretel_client.projects.records.RecordHandler

Creates a new record handler for the model.

  • data_source – A data source to upload to the record handler.

  • params – Any custom params for the record handler. These params are specific to the upstream model.

property data_source

Retrieves the configured data source from the model config.

If the model config has a local data_source we’ll try and resolve that path relative to the location of the model config.

delete() → Optional[dict]

Deletes the remote model.

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.


artifact_type – Artifact type to download

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

List artifact links for all known artifact types.

get_record_handlers() → Iterator[gretel_client.projects.records.RecordHandler]

Returns a list of record handlers associated with the model.

property instance_type

Returns CPU or GPU based on the model being trained.

property is_cloud_model

Returns True if the model was created to run in Gretel’s Cloud. False otherwise.

property logs

Returns run logs for the job.

property model_config

Returns the model config used to create the model.

property model_type

Returns the type of model. Eg synthetics, transforms or classify.

property name

Get the name of the model. If no name is specified, a random name will be selected when the model is submitted to the backend.


Returns the model name


Sets the model name

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

Return a summary of the job results


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.

poll_logs_status(wait: int = - 1, callback: Optional[Callable] = None) → Iterator[]

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

  • 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

Retrieves configured ref data from the model config. If there are local ref data sources we will try and resolve that path relative to the location of the model config.

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

submit_cloud() →

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


The response from the Gretel API.

submit_manual() →

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.


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.


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.


A RefData instance that contains the new Gretel artifact values


Test that the attached data source is a valid Csv or Json file. If the data source is a Gretel cloud artifact data validation will be skipped.