Projects#
- class Projects(client, *, _guard=None)#
Bases:
objectClient for interacting with the Projects API endpoints.
This class provides synchronous methods for creating, retrieving, updating, and deleting projects.
Examples
Basic project operations:
from phoenix.client import Client client = Client() # List all projects projects = client.projects.list() for project in projects: print(f"Project: {project['name']}") # Get a specific project project = client.projects.get(project_id="UHJvamVjdDoy") print(f"Project name: {project['name']}") # Create a new project new_project = client.projects.create( name="My Project", description="A description of my project" ) # Update a project updated_project = client.projects.update( project_id=new_project["id"], description="Updated description" ) # Delete a project client.projects.delete(project_id=new_project["id"])
- create(*, name, description=None)#
Create a new project.
- Parameters:
name (str) – The name of the project.
description (Optional[str]) – An optional description of the project.
- Returns:
The newly created project.
- Raises:
httpx.HTTPError – If the request fails.
ValueError – If the response is invalid.
Example:
from phoenix.client import Client client = Client() project = client.projects.create( name="My Project", description="A description of my project", ) print(f"Created project with ID: {project['id']}")
- delete(*, project_id=None, project_name=None)#
Delete a project by ID or name.
- Parameters:
project_id (Optional[str]) – The ID of the project to delete.
project_name (Optional[str]) – The name of the project to delete.
- Raises:
httpx.HTTPError – If the request fails.
ValueError – If neither project_id nor project_name is provided.
Example:
from phoenix.client import Client client = Client() # Delete by ID client.projects.delete(project_id="UHJvamVjdDoy") # Delete by name client.projects.delete(project_name="My Project")
- get(*, project_id=None, project_name=None)#
Get a project by ID or name.
- Parameters:
project_id (Optional[str]) – The ID of the project to retrieve.
project_name (Optional[str]) – The name of the project to retrieve.
- Returns:
The project with the specified ID or name.
- Raises:
httpx.HTTPError – If the request fails.
ValueError – If the response is invalid or if neither project_id nor project_name is provided.
Example:
from phoenix.client import Client client = Client() # Get by ID project = client.projects.get(project_id="UHJvamVjdDoy") # Get by name project = client.projects.get(project_name="My Project") print(f"Project name: {project['name']}")
- list()#
List all projects.
- Returns:
A list of all projects.
- Raises:
httpx.HTTPError – If the request fails.
ValueError – If the response is invalid.
Example:
from phoenix.client import Client client = Client() projects = client.projects.list() for project in projects: print(f"Project name: {project['name']}")
- update(*, project_id=None, project_name=None, description=None)#
Update a project by ID or name.
Note
Project names cannot be changed. If a name is provided, it will be ignored.
- Parameters:
project_id (Optional[str]) – The ID of the project to update.
project_name (Optional[str]) – The name of the project to update.
description (Optional[str]) – The new description for the project.
- Returns:
The updated project.
- Raises:
httpx.HTTPError – If the request fails.
ValueError – If the response is invalid or if neither project_id nor project_name is provided.
Example:
from phoenix.client import Client client = Client() # Update by ID project = client.projects.update( project_id="UHJvamVjdDoy", description="Updated project description", ) # Update by name project = client.projects.update( project_name="My Project", description="Updated project description", ) print(f"Updated project description: {project['description']}")
- class AsyncProjects(client, *, _guard=None)#
Bases:
objectAsynchronous client for interacting with the Projects API endpoints.
This class provides asynchronous methods for creating, retrieving, updating, and deleting projects.
Examples
Basic project operations:
from phoenix.client import AsyncClient async_client = AsyncClient() # List all projects projects = await async_client.projects.list() for project in projects: print(f"Project: {project['name']}") # Get a specific project project = await async_client.projects.get(project_id="UHJvamVjdDoy") print(f"Project name: {project['name']}") # Create a new project new_project = await async_client.projects.create( name="My Project", description="A description of my project" ) # Update a project updated_project = await async_client.projects.update( project_id=new_project["id"], description="Updated description" ) # Delete a project await async_client.projects.delete(project_id=new_project["id"])
- async create(*, name, description=None)#
Create a new project.
- Parameters:
name (str) – The name of the project.
description (Optional[str]) – An optional description of the project.
- Returns:
The newly created project.
- Raises:
httpx.HTTPError – If the request fails.
ValueError – If the response is invalid.
Example:
from phoenix.client import AsyncClient async_client = AsyncClient() project = await async_client.projects.create( name="My Project", description="A description of my project", ) print(f"Created project with ID: {project['id']}")
- async delete(*, project_id=None, project_name=None)#
Delete a project by ID or name.
- Parameters:
project_id (Optional[str]) – The ID of the project to delete.
project_name (Optional[str]) – The name of the project to delete.
- Raises:
httpx.HTTPError – If the request fails.
ValueError – If neither project_id nor project_name is provided.
Example:
from phoenix.client import AsyncClient async_client = AsyncClient() # Delete by ID await async_client.projects.delete(project_id="UHJvamVjdDoy") # Delete by name await async_client.projects.delete(project_name="My Project")
- async get(*, project_id=None, project_name=None)#
Get a project by ID or name.
- Parameters:
project_id (Optional[str]) – The ID of the project to retrieve.
project_name (Optional[str]) – The name of the project to retrieve.
- Returns:
The project with the specified ID or name.
- Raises:
httpx.HTTPError – If the request fails.
ValueError – If the response is invalid or if neither project_id nor project_name is provided.
Example:
from phoenix.client import AsyncClient async_client = AsyncClient() # Get by ID project = await async_client.projects.get(project_id="UHJvamVjdDoy") print(f"Project name: {project['name']}") # Get by name project = await async_client.projects.get(project_name="My Project") print(f"Project name: {project['name']}")
- async list()#
List all projects.
- Returns:
A list of all projects.
- Raises:
httpx.HTTPError – If the request fails.
ValueError – If the response is invalid.
Example:
from phoenix.client import AsyncClient async_client = AsyncClient() projects = await async_client.projects.list() for project in projects: print(f"Project name: {project['name']}")
- async update(*, project_id=None, project_name=None, description=None)#
Update a project by ID or name.
Note
Project names cannot be changed. If a name is provided, it will be ignored.
- Parameters:
project_id (Optional[str]) – The ID of the project to update.
project_name (Optional[str]) – The name of the project to update.
description (Optional[str]) – The new description for the project.
- Returns:
The updated project.
- Raises:
httpx.HTTPError – If the request fails.
ValueError – If the response is invalid or if neither project_id nor project_name is provided.
Example:
from phoenix.client import AsyncClient async_client = AsyncClient() # Update by ID project = await async_client.projects.update( project_id="UHJvamVjdDoy", description="Updated project description", ) # Update by name project = await async_client.projects.update( project_name="My Project", description="Updated project description", ) print(f"Updated project description: {project['description']}")