citrine.resources.branch module
- class citrine.resources.branch.Branch(name: str, *, session: Session | None = None)
Bases:
Resource
[Branch
]A project branch.
A branch is a container for design workflows.
- access_control_dict() dict
Return an access control entity representation of this resource. Internal use only.
- classmethod build(data: dict) Self
Build an instance of this object from given data.
- dump() dict
Dump this instance.
- archived = None
- created_at = None
- property design_workflows: DesignWorkflowCollection
Return a resource representing all workflows contained within this branch.
- property experiment_datasource: ExperimentDataSource | None
Return this branch’s experiment data source, or None if one doesn’t exist.
- name: str = None
- project_id: UUID | None = None
- root_id = None
- uid = None
- updated_at = None
- version = None
- class citrine.resources.branch.BranchCollection(project_id: UUID, session: Session)
Bases:
Collection
[Branch
]A collection of Branches.
- archive(*, root_id: UUID | str, version: int | str | None = 'latest')
Archive a branch.
- Parameters:
root_id (Union[UUID, str]) – Unique ID of the branch root
version (Union[int, str], optional) – The version of the branch. If provided, must either be a positive integer, or “latest”. Defaults to “latest”.
- build(data: dict) Branch
Build an individual branch from a dictionary.
- Parameters:
data (dict) – A dictionary representing the branch.
- Returns:
The branch created from data.
- Return type:
- data_updates(*, root_id: UUID | str, version: int | str | None = 'latest') BranchDataUpdate
Get data updates for a branch.
- Parameters:
root_id (Union[UUID, str]) – Unique ID of the branch root
version (Union[int, str], optional) – The version of the branch. If provided, must either be a positive integer, or “latest”. Defaults to “latest”.
- Returns:
A list of data updates and compatible predictors
- Return type:
- get(*, root_id: UUID | str, version: int | str | None = 'latest') Branch
Retrieve a branch by its root ID and, optionally, its version number.
Omitting the version number will retrieve the latest version.
- Parameters:
root_id (Union[UUID, str]) – Unique identifier of the branch root
version (Union[int, str], optional) – The version of the branch to retrieve. If provided, must either be a positive integer, or “latest”. Defaults to “latest”.
- Returns:
The requested version of the branch.
- Return type:
- get_by_version_id(*, version_id: UUID | str) Branch
Given a branch version ID, retrieve the branch.
- Parameters:
version_id (Union[UUID, str]) – Unique ID of the branch version
- Returns:
The requested branch.
- Return type:
- list(*, per_page: int = 20) Iterator[Branch]
List all active branches using pagination.
Yields all active branches paginating over all available pages.
- Parameters:
per_page (int, optional) – Max number of branches to return per page. Default is 20. This parameter is used when making requests to the backend service.
- Returns:
All branches in this collection.
- Return type:
Iterator[Branch]
- list_all(*, per_page: int = 20) Iterator[Branch]
List active branches using pagination.
Yields all active branches, paginating over all available pages.
- Parameters:
per_page (int, optional) – Max number of branches to return per page. Default is 20. This parameter is used when making requests to the backend service.
- Returns:
Active branches in this collection.
- Return type:
Iterator[Branch]
- list_archived(*, per_page: int = 20) Iterator[Branch]
List archived branches using pagination.
Yields all archived branches, paginating over all available pages.
- Parameters:
per_page (int, optional) – Max number of branches to return per page. Default is 20. This parameter is used when making requests to the backend service.
- Returns:
Archived branches in this collection.
- Return type:
Iterator[Branch]
- next_version(root_id: UUID | str, *, branch_instructions: NextBranchVersionRequest, retrain_models: bool = True)
Move a branch to the next version.
- Parameters:
root_id (Union[UUID, str]) – Unique identifier of the branch root to advance to next version
branch_instructions (NextBranchVersionRequest) – Instructions for how the next version of a branch should handle its predictors when the workflows are cloned. data_updates contains the list of data source versions to upgrade (current->latest), and use_predictors will either have a <predictor_id>:latest to indicate the workflow should use a new version of the predictor. Or <predictor_id>:<version #> to indicate that the workflow should use an existing predictor version.
retrain_models (bool) – If true, when new versions of models are created, they are automatically scheduled for training
- Returns:
The new branch record after version update
- Return type:
- register(model: CreationType) CreationType
Create a new element of the collection by registering an existing resource.
- restore(*, root_id: UUID | str, version: int | str | None = 'latest')
Restore an archived branch.
- Parameters:
root_id (Union[UUID, str]) – Unique ID of the branch root
version (Union[int, str], optional) – The version of the branch. If provided, must either be a positive integer, or “latest”. Defaults to “latest”.
- update(model: CreationType) CreationType
Update a particular element of the collection.
- update_data(*, root_id: UUID | str, version: int | str | None = 'latest', use_existing: bool = True, retrain_models: bool = False) Branch | None
Automatically advance the branch to the next version.
If there are no newer versions of data sources used by this branch this method returns without doing anything
- Parameters:
root_id (Union[UUID, str]) – Unique ID of the branch root
version (Union[int, str], optional) – The version of the branch. If provided, must either be a positive integer, or “latest”. Defaults to “latest”.
use_existing (bool) – If true the workflows in this branch will use existing predictors that are using the latest versions of the data sources and are ready to use.
retrain_models (bool) – If true, when new versions of models are created, they are automatically scheduled for training.
- Returns:
The new branch record after version update or None if no update
- Return type: