Project Administration
Project administration in flyte-sdk is managed through the Project class in the flyte.remote module. This class provides high-level methods to create, retrieve, update, and list projects within your organization.
Creating a Project
To create a new project, use the Project.create method. You must provide a unique id and a display name. You can also optionally include a description and a dictionary of labels.
from flyte.remote import Project
# Create a new project with metadata
project = Project.create(
id="ml-platform",
name="Machine Learning Platform",
description="Centralized project for ML workflows",
labels={"team": "ml-ops", "environment": "production"}
)
print(f"Created project: {project.pb2.id}")
Retrieving and Listing Projects
You can retrieve a single project by its ID or list all projects available in your organization.
Fetching a Single Project
Use Project.get to retrieve an existing project by its unique identifier.
from flyte.remote import Project
project = Project.get("ml-platform")
print(f"Project Name: {project.pb2.name}")
print(f"Current State: {project.pb2.state}")
Listing All Projects
The Project.listall method returns an iterator of projects. By default, it only returns active (unarchived) projects. To include archived projects, set the archived parameter to True.
from flyte.remote import Project
# List active projects
print("Active Projects:")
for project in Project.listall():
print(f"- {project.pb2.id}")
# List archived projects
print("\nArchived Projects:")
for project in Project.listall(archived=True):
print(f"- {project.pb2.id}")
You can also apply filters and sorting to the list:
# List projects sorted by creation date in descending order
projects = Project.listall(sort_by=("created_at", "desc"))
Updating Project Metadata
The Project.update method allows you to modify the display name, description, labels, or state of an existing project. This method performs a "get" operation first to preserve any fields that are not explicitly provided in the update call.
from flyte.remote import Project
# Update the description and labels of an existing project
Project.update(
id="ml-platform",
description="Updated description for the ML platform",
labels={"team": "data-science"}
)
Archiving and Unarchiving
Projects can be toggled between active and archived states. You can use the state parameter in Project.update or use the convenience instance methods archive() and unarchive().
from flyte.remote import Project
project = Project.get("ml-platform")
# Archive the project
project.archive()
# Unarchive (activate) the project
project.unarchive()
Troubleshooting
Backend Rejection of Domains
When updating a project, the Flyte backend rejects requests that include domain information in the project object. The flyte-sdk Project.update implementation handles this automatically by clearing the domains list from the underlying protobuf before sending the update request:
# Internal implementation detail in src/flyte/remote/_project.py
# Clear domains — the backend rejects update requests that include them
del project_pb.domains[:]
Default Visibility in Lists
If you cannot find a project using Project.listall(), ensure it has not been archived. The listall method defaults to archived=False. To see all projects regardless of state, you must iterate through both active and archived lists separately or specifically request archived ones.
Configuration Requirements
Project administration requires a configured Flyte client. Ensure your environment is configured with FLYTE_PLATFORM_URL and FLYTE_PLATFORM_INSECURE (if applicable). The Project methods internally call ensure_client() to verify the connection before executing requests.