Skip to main content

compatibility

Utilities for handling task compatibility with different SDK versions.

Module

Functions

check_task_compatibility

def check_task_compatibility(    task_data: dict[str, typing.Any],    config_class: type,    context: dict[str, typing.Any] | None = None,)> tuple[bool, typing.Any | None, str | None, TaskCompatibilityIssue]:

Check if a task is compatible with the current SDK version.

Arguments

  • task_data: The task data to check
  • config_class: The dataclass to use for validation
  • context: Optional context to pass to the schema

Returns Tuple of (is_compatible, parsed_task, error_message, issue), where issue categorises any failure as a version mismatch or a validation error (TaskCompatibilityIssue.NONE when compatible).

create_error_message

def create_error_message(    message: str, validation_error: marshmallow.exceptions.ValidationError | None = None,)> str:

Create an error message, logging the validation error if provided.

Arguments

  • message: The main error message
  • validation_error: Optional validation error to log

Returns The formatted error message

extract_version_changes

def extract_version_changes(from_version: str, to_version: str)> tuple[list[str], bool]:

Extract changes between two versions from the version.py file.

Arguments

  • from_version: The source version
  • to_version: The target version

Returns Tuple of (list of change descriptions, is_complete_history): is_complete_history is False if the from_version is older than the oldest version in the changelog

get_compatible_versions_for_modeller

def get_compatible_versions_for_modeller()> list[str]:

Get compatible versions for the modeller role.

Returns List of compatible versions

parse_semver

def parse_semver(version: str)> semver.version.Version | None:

Parse a semantic version string.

Arguments

  • version: The version string to parse

Returns Parsed VersionInfo object or None if parsing fails

validate_task_compatibility

def validate_task_compatibility(    task_data: dict[str, typing.Any],    config_class: type,    context: dict[str, typing.Any] | None = None,)> Any:

Validate task compatibility and return parsed task or raise informative error.

Arguments

  • task_data: The task data to validate
  • config_class: The dataclass to use for validation
  • context: Optional context to pass to the schema

Returns The parsed task if compatible

Raises

  • BitfountVersionError: If the task targets an incompatible version.
  • TaskValidationError: If the task fails schema/content validation.

Classes

TaskCompatibilityIssue

class TaskCompatibilityIssue(*args, **kwds):

Why a task failed the compatibility check.

Lets callers distinguish a genuine schema/content validation failure from a version incompatibility so they can raise the appropriate error type and show an actionable message.

Ancestors

Variables

  • static NONE
  • static VALIDATION_ERROR
  • static VERSION_MISMATCH