Projects
Learn to use and manage projects that allow you to store and collaborate on data.
Projects Overview
Gretel Projects can be thought of as repositories that hold models. Projects are created by single users and can be shared with various permissions:
Read: Users may access data artifacts (such as synthetic data and reports)
Write: Users may create and run models.
Administrator: Users may add other users to a project.
Owner: Full control.
The most important thing to note about Projects is that the name
attribute of a project is globally unique. If you are familiar with services like Simple Storage Service (S3), then Project naming will feel very similar since S3 bucket names are also globally unique within a specific service provider (such as AWS).
Projects have the following attributes you should be familiar with:
name
: A globally unique name for the project. When you create a project without specifying a specific name, Gretel will generate one for you. This will be a randomized name based on yourusername
and a unique hash slug. If you specify aname
that is already used, Project creation will fail.display_name
: This can be any descriptive name for the Project that will control how the Project is listed and displayed in the Gretel Console. It is non-unique.description
: This optional field can be provided to provide a user-friendly description of the Project.
SDK Project Management
The Gretel Python SDK gives more flexibility and control around Project management. Within the SDK, the Projects module and class should be the primary orientation point for doing most of your work with Gretel.
The SDK differs in that when creating or accessing Projects, you will be given an instance of a Project class that you can interact with. Let's take a look.
Creating Projects
You can create a project with no input attributes:
from gretel_client import create_project
proj = create_project()
proj.name
# 'john-a6cbf'
proj.get_console_url()
# 'https://console.gretel.cloud/john-a6cbf'
Alternatively, you can provide Project attributes to the create_project()
method:
from gretel_client import create_project
proj = create_project(name="my-awesome-project", display_name="Projects 101")
proj.name
# 'my-awesome-project'
proj.get_console_url()
# 'https://console-dev.gretel.cloud/my-awesome-project'
Unique Project Name Helper
As mentioned earlier, Project names are globally unique. However, we have created a utility in the SDK that allows users to "share" identical project names such that any user could have their own version of a project called "test" or "foo".
This helper will either create a new project or fetch an existing one, giving you back a Project instance. Additionally, the display name of the project will automatically be set for you based on the name you provide. Let's take a look:
from gretel_client import create_or_get_unique_project
proj = create_or_get_unique_project(name="my-new-awesome-project")
proj.name
# 'my-new-awesome-project-92fbf5bd55d2472'
# NOTE: The slug at the end is automatically handled by the SDK
proj.display_name
# 'my-new-awesome-project'
# NOTE: This will be the display name in the console
In this mode, every user could use the exact my-new-awesome-project
string and a unique slug for that user will be appended to the Project name. This may be especially useful if you are re-running Notebooks or routines and do not want to use a combination of create_project()
and get_project()
to determine if a project already exists or not.
Temporary Projects
In certain occasions, you may want to create a Project only for the purposes of creating a model and extracting the specific outputs (Synthetic Data, Synthetic Quality Report, etc). Once you have extracted the data you need, you can delete the Project, which will then delete all of the models and artifacts related to those models.
For this use case, there is a temporary project context manager you can use. Once the context handler exits, the Project will be deleted:
# NOTE: This import is one package down in the `projects` package
from gretel_client.projects import tmp_project
with tmp_project() as my_tmp_project:
print(my_tmp_project.name)
# 'john-3a8ae'
# At this point, our project has been deleted.
Accessing Projects
If you already have a Gretel Project, in order to run model operations, you will need to load an instance of the Project class in the SDK. We'll use our example Project from above: my-awesome-project
to show how to do this.
from gretel_client import get_project
proj = get_project(name="my-awesome-project")
proj.name
# 'my-awesome-project'
Deleting Projects
To delete a project from the SDK, you utilize the delete()
method on a Project instance:
from gretel_client import create_project
proj = create_project()
proj.delete()
Once you delete a project, the class instance is not usable anymore. If you try and do any meaningful operation with it, you'll receive a GretelProjectError
such as:
GretelProjectError: Cannot call method. The project has been marked for deletion.
Last updated
Was this helpful?