update_projects_from_config
Script to update projects from a configuration file.
This script reads a config file containing project IDs, task template slugs, and variables, then ensures each project is updated with the correct task template version and configurable variables.
Example usage: python -m bitfount.runners.update_projects_from_config \ task_templates/project-config-production-public.yaml --username myuser \ --password mypass
Module
Functions
get_latest_task_definition_for_project
def get_latest_task_definition_for_project( project_id: str, hub: BitfountHub, hub_url: str,) ‑> Optional[dict[str, typing.Any]]:Gets the latest task definition for a project from the hub.
Returns None if there is no task definition.
get_or_update_latest_task_template
def get_or_update_latest_task_template( project_config: ProjectConfig, username: str, jwt: ExternallyManagedJWT, hub: BitfountHub, hub_url: str,) ‑> str:Check if task template on hub is the latest version and update if necessary.
Arguments
project_config: The project configuration.username: The authenticated username.jwt: The JWT token.hub: The hub connection object.hub_url: The hub URL.
Returns The task template ID to use, corresponding to the latest version of the task template.
Raises
SkipProjectException: If project should be skipped.FailProjectException: If project update should be failed.
get_project_info
def get_project_info( project_id: str, hub: BitfountHub, hub_url: str,) ‑> dict[str, typing.Any]:Get current project information from the hub.
Arguments
project_id: The project ID to retrieve.hub: The hub connection object.hub_url: The hub URL.
Returns Project information dictionary or None if not found.
Raises
FailProjectException: If the project could not be found or accessed.
get_project_task_definitions
def get_project_task_definitions( project_id: str, hub: BitfountHub, hub_url: str,) ‑> dict[str, typing.Any]:Get task definitions for a project from the hub.
Arguments
project_id: The project ID.hub: The hub connection object.hub_url: The hub URL.
Returns Task definitions response dictionary or None if not found.
Raises
FailProjectException: If the task definitions could not be found or accessed.
get_task_template_info
def get_task_template_info( owner_or_id: str, slug: Optional[str], hub: BitfountHub, hub_url: str,) ‑> dict[str, typing.Any]:Get task template information from the hub by owner/slug or by ID.
Gets the latest task template for a given owner/slug, gets the specific version if provided with ID.
Arguments
owner_or_id: Either the task template owner (if slug provided) or template ID.slug: The task template slug (if getting by owner/slug), None if getting by ID.hub: The hub connection object.hub_url: The hub URL.
Returns Task template information dictionary or None if not found.
load_config
def load_config( config_file: str,) ‑> list[ProjectConfig]:Load and parse the project configuration file.
Arguments
config_file: Path to the YAML configuration file.
Returns List of ProjectConfig objects.
main
def main(config_file: str, username: str, password: str) ‑> None:Main function to update projects from configuration file.
Arguments
config_file: Path to the YAML configuration file.username: The username for authentication.password: The password for authentication.
process_project
def process_project( project_config: ProjectConfig, username: str, jwt: ExternallyManagedJWT, hub: BitfountHub, hub_url: str,) ‑> ProcessResult:Process a single project configuration.
Arguments
project_config: The project configuration to process.username: The authenticated username.jwt: The JWT token.hub: The hub connection object.hub_url: The hub URL.
Returns ProcessResult enum value.
update_project_config
def update_project_config( target_project_config: ProjectConfig, target_task_template_id: str, current_project_info: dict[str, typing.Any], latest_task_definition: Optional[dict[str, typing.Any]], hub: BitfountHub, hub_url: str,) ‑> None:Update a project as needed, considering both task template and variables.
Arguments
target_project_config: The project configuration as we want to end up using.target_task_template_id: The task template ID we want to end up using.current_project_info: Project information for its current state.latest_task_definition: The latest task definition for that project or None if there is no latest task definition.hub: The hub connection object.hub_url: The hub URL.
Returns None if update was successful.
Raises
FailProjectException: If the project update fails.
Classes
FailProjectException
class FailProjectException(*args, **kwargs):Fail updating this project.
Ancestors
- builtins.Exception
- builtins.BaseException
ProcessResult
class ProcessResult(value, names=None, *, module=None, qualname=None, type=None, start=1):Enum representing the result of processing a project.
ProjectConfig
class ProjectConfig(project_id: str, config_data: dict[str, typing.Any]):Class to represent a project configuration.
SkipProjectException
class SkipProjectException(*args, **kwargs):Skip updating this project.
Ancestors
- builtins.Exception
- builtins.BaseException