Projects¶
High level API for interacting with a Gretel Project
-
exception
gretel_client.projects.projects.
ManifestNotFoundException
¶
-
exception
gretel_client.projects.projects.
ManifestPendingException
(msg: Optional[str] = None, manifest: dict = {})¶
-
class
gretel_client.projects.projects.
Project
(*, name: str, project_id: str, project_guid: Optional[str] = None, desc: Optional[str] = None, display_name: Optional[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: Union[str, gretel_client.cli.utils.parser_utils._DataFrameT, None] = None, ref_data: Union[str, Dict[str, str], List[str], Tuple[str], gretel_client.cli.utils.parser_utils._DataFrameT, List[gretel_client.cli.utils.parser_utils._DataFrameT], None] = 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/reference/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.
ref_data – An Optional str, dict, dataframe or list of reference data sources to upload for the job.
-
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_artifact_link
(key: str) → str¶ Returns a link to download a project artifact.
- Parameters
key – Project artifact key to generate download url for.
- Returns
A signed URL that may be used to download the given project artifact.
-
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’smodel_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, aModel
will be returned. Ifdict
is passed, a dictionary representation of the search results will be returned.
-
upload_artifact
(artifact_path: Union[pathlib.Path, str, gretel_client.projects.common._DataFrameT], _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_or_get_unique_project
(*, name: str, desc: Optional[str] = None, display_name: Optional[str] = None) → gretel_client.projects.projects.Project¶ Helper function that provides a consistent experience for creating and fetching a project with the same name. Given a name of a project, this helper will fetch the current user’s ID and use that as a suffix in order to create a project name unique to that user. Once the project is created, if it can be fetched, it will not be re-created over and over again.
- Parameters
name – The name of the project, which will have the User’s ID appended to it automatically.
desc – Description of the project.
display_name – If None, the display name will be set equal to the value of
name
_before_ the user ID is appended.
Note
The
desc
anddisplay_name
parameters will only be used when the project is first created. If the project already exists, these params will have no affect.
-
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: Optional[str] = None, create: bool = False, desc: Optional[str] = None, display_name: Optional[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: Optional[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()