Projects

High level API for interacting with a Gretel Project

class gretel_client.projects.projects.Project(*, name: str, project_id: str, desc: str = None, display_name: str = None)

Represents Gretel project. In general you should not have to init this class directly, but can make use of the factory method from get_project.

Parameters
  • name – The unique name of the project. This is either set by you or auto managed by Gretel

  • project_id – The unique project id of your project. This is managed by gretel and never changes.

  • desc – A short description of the project

  • display_name – The main display name used in the Gretel Console for your project

property artifacts

Returns a list of project artifacts

property as_dict

Returns a dictionary representation of the project.

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

Creates a new model object. This will not submit the model to Gretel’s cloud API. Please refer to the Model docs for more information detailing how to submit the model.

Parameters
  • model_config – Specifies a model config. For more information about model configs, please refer to our doc site, https://docs.gretel.ai/model-configurations.

  • data_source – Defines the model data_source. If the model_config already has a data_source defined, this property will override the existing one.

delete(*args, **kwargs)

Deletes a project. After the project has been deleted, functions relying on a project will fail with a GretelProjectError exception.

Note: Deleting projects is asynchronous. It may take a few seconds for the project to be deleted by Gretel services.

delete_artifact(key: str)

Deletes a project artifact

Parameters

key – Artifact key to delete

get_console_url() → str

Returns web link to access the project from Gretel’s console.

get_model(model_id: str)gretel_client.projects.models.Model

Lookup and return a Project Model by it’s model_id.

Parameters

model_id – The model_id to lookup

info() → dict

Return details about the project.

search_models(factory: Type[MT] = <class 'gretel_client.projects.models.Model'>, limit: int = 100) → Iterator[MT]

Search for project models.

Parameters
  • limit – Limits the number of project models to return

  • factory – Determines what type of Model representation is returned. If Model is passed, a Model will be returned. If dict is passed, a dictionary representation of the search results will be returned.

upload_artifact(artifact_path: Union[pathlib.Path, str], _validate: bool = True) → str

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

Returns

A Gretel artifact key

gretel_client.projects.projects.create_project(*, name: Optional[str] = None, desc: Optional[str] = None, display_name: Optional[str] = None)gretel_client.projects.projects.Project

Excplit project creation. This function will simply call the API endpoint and will raise any HTTP exceptions upstream.

gretel_client.projects.projects.get_project(*, name: str = None, create: bool = False, desc: str = None, display_name: str = None)gretel_client.projects.projects.Project

Used to get or create a Gretel project.

Parameters
  • name – The unique name of the project. This is either set by you or auto managed by Gretel.

  • create – If create is set to True the function will create the project if it doesn’t exist.

  • project_id – The unique project id of your project. This is managed by gretel and never changes.

  • desc – A short description of the project

  • display_name – The main display name used in the Gretel Console for your project

  • client_config – An instance of a ClientConfig. This can be used to override any default connection configuration.

Returns

A project instance.

gretel_client.projects.projects.search_projects(limit: int = 200, query: str = None) → List[gretel_client.projects.projects.Project]

Searches for project

Parameters
  • limit – The max number of projects to return.

  • query – String filter applied to project names.

  • client_config – Can be used to override local Gretel config.

Returns

A list of projects.

gretel_client.projects.projects.tmp_project()

A temporary project context manager. Create a new project that can be used inside of a “with” statement for temporary purposes. The project will be deleted from Gretel Cloud when the scope is exited.

Example:

with tmp_project() as proj:
    model = proj.create_model_obj()