Skip to main content

Project Administration

Manage the lifecycle of projects in Flyte to organize your tasks, workflows, and resources. Projects serve as the top-level container for all entities in a Flyte deployment.

Initialize the Flyte Client

Before performing any project administration tasks, you must initialize the Flyte client to establish a connection with the backend.

import flyte

# Initialize connection to the Flyte backend
flyte.init(endpoint="localhost:30080")

Create a New Project

Use the Project.create method to define a new project. You must provide a unique identifier and a display name.

from flyte.remote import Project

# Create a project with metadata and labels
new_project = Project.create(
id="ml-research",
name="Machine Learning Research",
description="Project for tracking experimental ML models",
labels={"team": "data-science", "priority": "high"}
)

print(f"Created project: {new_project.pb2.id}")

Retrieve and List Projects

You can retrieve a specific project by its ID or iterate through all existing projects.

from flyte.remote import Project

# Get a single project by ID
project = Project.get(name="ml-research")
print(f"Project Name: {project.pb2.name}")

# List all active projects
print("Active Projects:")
for p in Project.listall():
print(f"- {p.pb2.id}: {p.pb2.name}")

# List archived projects
print("Archived Projects:")
for p in Project.listall(archived=True):
print(f"- {p.pb2.id}")

Update Project Metadata

The Project.update method allows you to modify the display name, description, labels, or state of an existing project.

from flyte.remote import Project

# Update project description and labels
Project.update(
id="ml-research",
description="Updated description for the research project",
labels={"team": "data-science", "status": "active"}
)

Archive and Unarchive Projects

Archiving a project hides it from the default list and prevents new resources from being created within it. You can use the dedicated instance methods or the state parameter in update.

from flyte.remote import Project

project = Project.get(name="ml-research")

# Archive the project
project.archive()

# Alternatively, archive via the class method
Project.update(id="ml-research", state="archived")

# Unarchive (activate) the project
project.unarchive()

Troubleshooting and Best Practices

Client Initialization

All Project methods require the Flyte client to be initialized. If you encounter errors related to missing clients, ensure flyte.init() or flyte.init_from_config() has been called at the start of your script.

Domain Rejection

When updating a project, the backend explicitly rejects requests that include domain information. The Project.update implementation in this SDK automatically handles this by clearing the domains field from the underlying protobuf before sending the update request.

Listing Defaults

By default, Project.listall() only returns active projects. To see projects that have been archived, you must explicitly pass archived=True.

Label Replacement

When updating labels via Project.update(labels={...}), the provided dictionary replaces all existing labels for that project rather than merging with them.