webknossos.administration.project
¶
Project
¶
Data class containing information about a WEBKNOSSOS project
create
classmethod
¶
create(name: str, team: str | Team, expected_time: int | None, priority: int = 100, paused: bool = False, is_blacklisted_from_report: bool = False, owner: str | User | None = None) -> Project
Creates a new project and returns it. Note: The project will be created with the current user as owner.
Parameters:
-
name
(str
) –The name of the project.
-
priority
(int
, default:100
) –The priority of the project.
-
paused
(bool
, default:False
) –Whether the project is paused or not.
-
expected_time
(int | None
) –The expected time for the project in minutes.
-
team_id
(str
) –The ID of the team to which the project belongs.
-
owner_id
–(str | None): The ID of the owner user of the project. If None, the current user will be used.
Returns:
-
Project
(Project
) –The created project.
get_by_id
classmethod
¶
get_by_id(project_id: str) -> Project
Retrieve a project by its unique identifier.
Fetches the project with the specified project_id
from the backend, provided the current
user can access the project. This method requires valid authentication.
Parameters:
-
project_id
(str
) –The unique identifier of the project to retrieve.
Returns:
-
Project
(Project
) –An instance of the Project class corresponding to the specified ID.
Raises:
-
UnexpectedStatusError
–If the project does not exist or the user is not authorized to access it.
Examples:
Retrieve a project by ID:
project = Project.get_by_id("project_12345")
print(project.name)
get_by_name
classmethod
¶
get_by_name(name: str) -> Project
Retrieve a project by its unique name.
Fetches the project with the specified name
from the backend, provided the current
user can access the project. This method requires valid authentication.
Parameters:
-
name
(str
) –The unique name of the project to retrieve.
Returns:
-
Project
(Project
) –An instance of the Project class corresponding to the specified name.
Raises:
-
UnexpectedStatusError
–If the project does not exist or the user is not authorized to access it.
Examples:
Retrieve a project by name:
project = Project.get_by_name("my_project")
print(project.project_id)
get_tasks
¶
get_tasks(fetch_all: bool = False) -> list[Task]
Retrieve the list of tasks associated with this project.
By default, this method fetches up to the first 1000 tasks for the project. If the project contains more than 1000 tasks,
a warning is issued unless fetch_all=True
is passed, in which case all tasks are fetched using pagination.
Parameters:
-
fetch_all
(bool
, default:False
) –If True, fetches all tasks for the project using pagination. If False (default), only the first 1000 tasks are returned and a warning is issued if more tasks exist.
Returns:
-
list[Task]
–list[Task]: A list of Task objects associated with this project.
Examples:
Fetch up to 1000 tasks:
tasks = project.get_tasks()
print(f"Fetched {len(tasks)} tasks")
Fetch all tasks, regardless of count:
all_tasks = project.get_tasks(fetch_all=True)
print(f"Total tasks: {len(all_tasks)}")
update
¶
update(priority: int | None = None, expected_time: int | None = None, is_blacklisted_from_report: bool | None = None) -> Project
Update the project's properties and return the updated Project instance.
This method updates the project's priority, expected time, and blacklist status for reporting. Only the parameters provided (not None) will be updated; others remain unchanged.
Parameters:
-
priority
(int | None
, default:None
) –Optional new priority for the project. If not provided, the current priority is kept.
-
expected_time
(int | None
, default:None
) –Optional new expected time (in minutes or relevant unit) for the project. If not provided, the current expected time is kept.
-
is_blacklisted_from_report
(bool | None
, default:None
) –Optional flag to set whether the project should be excluded from reports. If not provided, the current blacklist status is kept.
Returns:
-
Project
(Project
) –The updated Project instance reflecting the new properties.
Examples:
Update only the priority:
project = project.update(priority=5)
Update expected time and blacklist status:
project = project.update(expected_time=120, is_blacklisted_from_report=True)
- Get Help
- Community Forums
- Email Support