# Database models

Data models for the db application.

class debusine.db.models.Artifact(*args, **kwargs)

  Bases: `Model`

  Artifact model.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  artifact_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  can_display(user: PermissionUser) → bool

    Check if the artifact can be displayed.

  category

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  clean() → None

    Ensure that data is valid for this artifact category.

    Raises:

      ValidationError – for invalid data.

  collection_items

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  create_data() → ArtifactData

    Instantiate ArtifactData from data.

  created_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  created_by

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  created_by_id
  created_by_work_request

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  created_by_work_request_id
  data

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  effective_expiration_delay() → timedelta

    Return expiration_delay, inherited if None.

  expiration_delay

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  property expire_at: datetime | None

    Return computed expiration date.

  expired(at: datetime) → bool

    Return True if this artifact has expired at a given datetime.

    Parameters:

      at – datetime to check if the artifact is expired.

    Return bool:

      True if the artifact’s expire_at is on or earlier than the parameter at.

  fileinartifact_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  files

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  get_absolute_url() → str

    Return the canonical URL to display the artifact.

  get_absolute_url_download() → str

    Return the canonical URL to download the artifact.

  get_label(data: ArtifactData | None = None) → str

    Return a label for this artifact.

    Optionally reuse an already instantiated data model.

  get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
  get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.ArtifactManagerFromArtifactQuerySet object>
  original_artifact

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  original_artifact_id
  parent_collections

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  relations

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  save(**kwargs: Any) → None

    Wrap save with permission checks.

  targeted_by

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  ui(request: HttpRequest) → ArtifactUI

    Return a UI helper for this instance.

  workspace

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  workspace_id

class debusine.db.models.ArtifactRelation(*args, **kwargs)

  Bases: `Model`

  Model relations between artifacts.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  class Relations(*values)

    Bases: `TextChoices`

    BUILT_USING = 'built-using'
    EXTENDS = 'extends'
    RELATES_TO = 'relates-to'
  artifact

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  artifact_id
  can_display(user: PermissionUser) → bool

    Check if the artifact can be displayed.

  get_type_display(*, field=<django.db.models.fields.CharField: type>)
  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.ArtifactRelationManagerFromArtifactRelationQuerySet object>
  target

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  target_id
  type

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class debusine.db.models.Asset(*args, **kwargs)

  Bases: `Model`

  Asset model.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  Roles

    alias of `AssetRoles`

  can_create(user: PermissionUser) → bool

    Can user create this asset.

  can_edit(user: PermissionUser) → bool

    Can user edit this asset.

  category

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  clean() → None

    Ensure that data is valid for this asset category.

    Raises:

      ValidationError – for invalid data.

  created_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  created_by

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  created_by_id
  created_by_work_request

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  created_by_work_request_id
  data

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  property data_model: BaseAssetDataModel

    Instantiate AssetData from data.

  filestore_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  get_category_display(*, field=<django.db.models.fields.CharField: category>)
  get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
  get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.AssetManagerFromAssetQuerySet object>
  roles

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  save(**kwargs: Any) → None

    Wrap save with permission checks.

  property slug: str

    Return a string slug that uniquely identifies the asset.

  usage

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  workerpool_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  workspace

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  workspace_id

class debusine.db.models.AssetUsage(*args, **kwargs)

  Bases: `Model`

  Usage of an Asset within a workspace.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  Roles

    alias of `AssetUsageRoles`

  asset

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  asset_id
  can_sign_repository_with(user: PermissionUser) → bool

    Check if the user can sign a repository with this resource.

  can_sign_with(user: PermissionUser) → bool

    Check if the user can sign with this resource.

  can_use_apt_authentication_with(user: PermissionUser) → bool

    Check if the user can use APT authentication with this resource.

  has_role(user: PermissionUser, role: AssetUsageRoles) → bool

    Check if the user has the given role on this AssetUsage.

  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.AssetUsageManagerFromAssetUsageQuerySet object>
  roles

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  workspace

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  workspace_id

class debusine.db.models.Collection(*args, **kwargs)

  Bases: `Model`

  Model representing a collection.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  RetainsArtifacts

    alias of `_CollectionRetainsArtifacts`

  can_configure(user: PermissionUser) → bool

    Check if the collection can be configured.

  can_delete(user: PermissionUser) → bool

    Check if the collection can be deleted.

  can_display(user: PermissionUser) → bool

    Check if the collection can be displayed.

  category

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  child_artifacts

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  child_collections

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  child_items

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  collection_items

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  data

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  delete_collection() → None

    Delete this collection, and all its CollectionItem entries.

    Does not delete the associated Collections or Artifacts.

  full_history_retention_period

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  get_absolute_url() → str

    Return the canonical URL to display the collection.

  get_absolute_url_search() → str

    Return the canonical URL to search inside the collection.

  get_item_stats() → Generator[dict[str, Any]]

    Return a dict of item counts for each item type.

  get_retains_artifacts_display(*, field=<django.db.models.fields.CharField: retains_artifacts>)
  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  item_match_constraints

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  property manager: CollectionManagerInterface

    Get collection manager for this collection category.

  metadata_only_retention_period

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  name

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.CollectionManagerFromCollectionQuerySet object>
  parent_collections

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  retains_artifacts

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  ui(request: HttpRequest) → CollectionUI

    Return a UI helper for this instance.

  workflow

    Accessor to the related object on the reverse side of a one-to-one relation.

    In the example:

        class Restaurant(Model):
            place = OneToOneField(Place, related_name='restaurant')

    `Place.restaurant` is a `ReverseOneToOneDescriptor` instance.

  workspace

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  workspace_id

class debusine.db.models.CollectionItem(*args, **kwargs)

  Bases: `Model`

  CollectionItem model.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  Types

    alias of `_CollectionItemTypes`

  artifact

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  artifact_id
  category

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  child_type

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  collection

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  collection_id
  created_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  created_by_user

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  created_by_user_id
  created_by_workflow

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  created_by_workflow_id
  data

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  static expand_name(name_template: str, expanded_variables: dict[str, str]) → str

    Format item name following item_template.

  static expand_variables(variables: dict[str, str], reference_data: dict[Any, Any]) → dict[str, str]

    Expand JSONPath variables against some data.

    The data will normally come from an Artifact.

  get_absolute_url() → str

    Return the canonical URL to display the item.

  get_child_type_display(*, field=<django.db.models.fields.CharField: child_type>)
  get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
  get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  name

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.CollectionItemManagerFromCollectionItemQuerySet object>
  parent_category

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  parent_collection

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  parent_collection_id
  removed_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  removed_by_user

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  removed_by_user_id
  removed_by_workflow

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  removed_by_workflow_id
  save(*args: Any, **kwargs: Any) → None

    Populate parent_category on save.

  ui(request: HttpRequest) → CollectionItemUI

    Return a UI helper for this instance.

class debusine.db.models.CollectionItemMatchConstraint(*args, **kwargs)

  Bases: `Model`

  Enforce matching-value constraints on collection items.

  All instances of this model with the same `collection`, `constraint_name`, and `key` must have the same `value`.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  collection

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  collection_id
  collection_item_id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  constraint_name

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  key

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects: ClassVar[Manager] = <django.db.models.manager.Manager object>
  value

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class debusine.db.models.File(*args, **kwargs)

  Bases: `Model`

  Database model of a file.

  Model different attributes of the file.

  From outside the class use the property `hash` and do not use `sha256` field. This allows, if ever needed, to change the hash algorithm only modifying this class without changing the users of this class.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  artifact_set

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  classmethod calculate_hash(file_path: Path) → bytes

    Return hash for the file.

  current_hash_algorithm = 'sha256'
  fileinartifact_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  fileinstore_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  filestore_set

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  classmethod from_local_path(local_path: Path) → File

    Return a File with the fields.

  property hash_digest: bytes

    Return the default hash digest of the File.

    Use this property instead of the field to allow the algorithm to be changed in the future.

  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <debusine.db.models.files.FileManager object>
  sha256

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  size

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class debusine.db.models.FileInArtifact(*args, **kwargs)

  Bases: `Model`

  File in artifact.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  artifact

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  artifact_id
  complete

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  content_type

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  file

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  file_id
  fileupload

    Accessor to the related object on the reverse side of a one-to-one relation.

    In the example:

        class Restaurant(Model):
            place = OneToOneField(Place, related_name='restaurant')

    `Place.restaurant` is a `ReverseOneToOneDescriptor` instance.

  get_absolute_url() → str

    Return an absolute URL to view this file.

  get_absolute_url_download() → str

    Return an absolute URL to download this file.

  get_absolute_url_raw() → str

    Return an absolute URL to view this file as raw.

  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.Manager object>
  path

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  ui(request: HttpRequest) → FileInArtifactUI

    Return a UI helper for this instance.

class debusine.db.models.FileInStore(*args, **kwargs)

  Bases: `Model`

  Database model used as “through” from FileStore.

  Keeps the relationship between stores, files and attached data.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  data

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  file

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  file_id
  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.Manager object>
  store

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  store_id

class debusine.db.models.FileStore(*args, **kwargs)

  Bases: `Model`

  Database model of a FileStore.

  FileStore has files attached to it.

  BackendChoices

    alias of `_FileStoreBackendChoices`

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  backend

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  clean() → None

    Ensure that data is valid for this backend type.

    Raises:

      ValidationError – for invalid data.

  configuration

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  configuration_validators = {_FileStoreBackendChoices.EXTERNAL_DEBIAN_SUITE: <class 'debusine.server.file_backend.models.ExternalDebianSuiteBackendConfiguration'>, _FileStoreBackendChoices.LOCAL: <class 'debusine.server.file_backend.models.LocalFileBackendConfiguration'>, _FileStoreBackendChoices.MEMORY: <class 'debusine.server.file_backend.models.MemoryFileBackendConfiguration'>, _FileStoreBackendChoices.S3: <class 'debusine.server.file_backend.models.S3FileBackendConfiguration'>}
  static default() → FileStore

    Return the default FileStore.

  fileinstore_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  files

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  filestoreinscope_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  get_backend_display(*, field=<django.db.models.fields.CharField: backend>)
  get_backend_object() → FileBackendInterface[Any]

    Instantiate the correct FileBackend and return it.

  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  instance_wide

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  max_size

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  name

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.Manager object>
  provider_account

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  provider_account_id
  scopes

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  soft_max_size

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  total_size

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class debusine.db.models.FileStoreInScope(*args, **kwargs)

  Bases: `Model`

  Database model used for extra data on Scope/FileStore relations.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  download_priority

    The priority of this store for the purpose of serving files to clients. When downloading a file, debusine tries stores in descending order of download priority, counting null as the lowest; it breaks ties in descending order of upload priority, again counting null as the lowest. If there is still a tie, it picks one of the possibilities arbitrarily.

  drain

    If True, the storage maintenance job moves all files in this scope to some other store in the same scope, following the same rules for finding a target store as for uploads of new files. It does not move into a store if that would take its total size over soft_max_size (either for the scope or the file store), and it logs an error if it cannot find any eligible target store.

  drain_to

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  file_store

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  file_store_id
  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.Manager object>
  populate

    If True, the storage maintenance job ensures that this store has a copy of all files in the scope.

  read_only

    If True, debusine will not add new files to this store. Use this in combination with drain to prepare for removing the file store.

  scope

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  scope_id
  soft_max_size

    An integer specifying the number of bytes that the file store can hold for this scope (accounting files that are in multiple scopes to all of the scopes in question). This limit may be exceeded temporarily during uploads; the storage maintenance job will move the least-recently-used files to another file store to get back below the limit.

  upload_priority

    The priority of this store for the purpose of storing new files. When adding a new file, debusine tries stores whose policies allow adding new files in descending order of upload priority, counting null as the lowest.

  write_only

    If True, debusine will not read files from this store. This is suitable for provider storage classes that are designed for long-term archival rather than routine retrieval, such as S3 Glacier Deep Archive.

class debusine.db.models.FileUpload(*args, **kwargs)

  Bases: `Model`

  File that is being/has been uploaded.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  absolute_file_path() → Path

    Return the absolute file path of the file.

    The files are stored in settings.DEBUSINE_UPLOAD_DIRECTORY.

  classmethod current_size(artifact: Artifact, path_in_artifact: str) → int

    Return current file size.

    The current file size might be smaller than the expected size of the file if the file has not finished being uploaded.

    Raise ValueError if path_in_artifact does not exist in Artifact or if there’s no FileUpload object for the specific File.

  delete(*args: Any, **kwargs: Any) → tuple[int, dict[str, int]]

    Schedule deletion of the file in the store.

  file_in_artifact

    Accessor to the related object on the forward side of a one-to-one relation.

    In the example:

        class Restaurant(Model):
            place = OneToOneField(Place, related_name='restaurant')

    `Restaurant.place` is a `ForwardOneToOneDescriptor` instance.

  file_in_artifact_id
  get_next_by_last_activity_at(*, field=<django.db.models.fields.DateTimeField: last_activity_at>, is_next=True, **kwargs)
  get_previous_by_last_activity_at(*, field=<django.db.models.fields.DateTimeField: last_activity_at>, is_next=False, **kwargs)
  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  last_activity_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.Manager object>
  path

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class debusine.db.models.Group(*args, **kwargs)

  Bases: `Model`

  Connect users to roles.

  Group names are scoped: groups with the same name in different scopes are entirely distinct and unrelated.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  Roles

    alias of `GroupRoles`

  add_audit_log(changes: Annotated[GroupAuditLogCreated | GroupAuditLogUpdated | GroupAuditLogMemberAdded | GroupAuditLogMemberRoleChanged | GroupAuditLogMemberRemoved, FieldInfo(annotation=NoneType, required=True, discriminator='type')]) → GroupAuditLog | None

    Add an audit log entry.

  add_user(user: User, role: GroupRoles = GroupRoles.MEMBER) → GroupMembership

    Add a user to the group.

  asset_roles

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  asset_usage_roles

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  assign_role(resource: Model, role: str) → Model

    Assign a role on a resource.

  audit_log

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  can_display(user: PermissionUser) → bool

    Check if the group can be displayed.

  can_display_audit_log(user: PermissionUser) → bool

    Check if the group audit log can be displayed.

  can_manage(user: PermissionUser) → bool

    Check if the group can be managed.

  ephemeral

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  get_absolute_url() → str

    Return an absolute URL to this group.

  get_absolute_url_audit_log() → str

    Return an absolute URL to this group’s audit log.

  get_user_role(user: User) → GroupRoles

    Get the role of an existing group member.

  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  membership

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  name

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  property name_without_scope: str

    Get the qualified group name without the scope.

  objects = <django.db.models.manager.GroupManagerFromGroupQuerySet object>
  remove_user(user: User) → None

    Remove an existing member from the group.

  save(*args: Any, **kwargs: Any) → None

    Update audit log on group create/update.

  scope

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  scope_id
  scope_roles

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  set_user_role(user: User, role: GroupRoles) → GroupMembership

    Set the role of an existing group member.

  ui(request: HttpRequest) → GroupUI

    Return a UI helper for this instance.

  users

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  workspace

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  workspace_id
  workspace_roles

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

class debusine.db.models.Identity(*args, **kwargs)

  Bases: `Model`

  Identity for a user in a remote user database.

  An Identity is bound if it’s associated with a Django user, or unbound if no Django user is known for it.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  claims

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  get_next_by_last_used(*, field=<django.db.models.fields.DateTimeField: last_used>, is_next=True, **kwargs)
  get_previous_by_last_used(*, field=<django.db.models.fields.DateTimeField: last_used>, is_next=False, **kwargs)
  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  issuer

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  last_used

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.Manager object>
  subject

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  user

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  user_id

class debusine.db.models.NotificationChannel(*args, **kwargs)

  Bases: `Model`

  Model to store notification configuration.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  class Methods(*values)

    Bases: `TextChoices`

    EMAIL = 'email'
  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  clean() → None

    Ensure that data is valid for the specific method.

    Raises:

      ValidationError – for invalid data.

  data

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  data_validators = {NotificationChannel.Methods.EMAIL: <class 'debusine.tasks.models.NotificationDataEmail'>}
  get_method_display(*, field=<django.db.models.fields.CharField: method>)
  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  method

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  name

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.Manager object>
  save(*args: Any, **kwargs: Any) → None

    Run validators and save the instance.

class debusine.db.models.Scope(*args, **kwargs)

  Bases: `Model`

  Scope model.

  This is used to create different distinct sets of groups and workspaces

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  Roles

    alias of `ScopeRoles`

  can_create_workspace(user: PermissionUser) → bool

    Check if the user can create workspaces in this scope.

  can_display(user: PermissionUser) → bool

    Check if the scope can be displayed.

  download_file_backend(fileobj: File) → FileBackendInterface[Any]

    Find the best file backend for downloading fileobj.

    Raises:

      IndexError – if there is no such file backend.

  download_file_stores(fileobj: File) → QuerySet

    Find the file stores in this scope that have fileobj, if any.

    The returned query set is in descending order of download priority, breaking ties in descending order of upload priority and then by ascending file store IDs.

  file_stores

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  filestoreinscope_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  get_group_roles(user: PermissionUser) → QuerySet

    Get the roles of the user on this scope.

  group_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  has_role(user: PermissionUser, role: ScopeRoles) → bool

    Check if the user has the given role on this Scope.

  icon

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  label

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  name

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.ScopeManagerFromScopeQuerySet object>
  roles

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  scopeworkerpool_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  ui(request: HttpRequest) → ScopeUI

    Return a UI helper for this instance.

  upload_file_backend(fileobj: File) → FileBackendInterface[Any]

    Find the best file backend for uploading fileobj.

    Raises:

      IndexError – if there is no such file backend.

  upload_file_stores(fileobj: File, *, enforce_soft_limits: bool = False, include_write_only: bool = False) → QuerySet

    Find the file stores in this scope where fileobj can be uploaded.

    The returned query set is in descending order of upload priority, breaking ties by ascending file store IDs.

    Parameters:

      - enforce_soft_limits – Enforce soft_max_size policies as well as max_size.

      - include_write_only – Uploading a file to a write-only store will mean that debusine won’t download it from there again, so that only makes sense in specialized situations such as populating a backup store. Set this to True to include write-only stores in the returned query set.

  workerpooltaskexecutionstatistics_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  workspaces

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

class debusine.db.models.ScopeWorkerPool(*args, **kwargs)

  Bases: `Model`

  Through table for linking a WorkerPool to a Scope.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  limits

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  property limits_model: ScopeWorkerPoolLimits

    Return the pydantic model for limits.

  objects = <django.db.models.manager.Manager object>
  priority

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  scope

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  scope_id
  worker_pool

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  worker_pool_id

class debusine.db.models.TaskDatabase(work_request: WorkRequest)

  Bases: `TaskDatabaseInterface`

  Implementation of database interaction in worker tasks.

  __init__(work_request: WorkRequest) → None

    Construct a `TaskDatabase`.

  export_suite_signing_keys(suite_id: int) → str | None

    Export signing keys for a suite as an ASCII-armored keyring.

  find_related_artifacts(artifact_ids: Collection[int], target_category: ArtifactCategory, relation_type: RelationType = RelationType.RELATES_TO) → MultipleArtifactInfo

    Find artifacts via relations.

    For each of the artifacts in `artifact_ids`, find all artifacts of `target_category` that are related to the initial artifacts with a relation of type `relation_type`.

    Parameters:

      - artifact_ids – The IDs of artifacts to start from.

      - target_category – The category of artifacts to find.

      - relation_type – The type of relation to follow.

    Returns:

      Information about each artifact.

  get_server_setting(setting: str) → str

    Look up a Django setting (strings only).

  lookup_multiple_artifacts(lookup: LookupMultiple | None, default_category: CollectionCategory | None = None) → MultipleArtifactInfo

    Look up multiple artifacts.

    Parameters:

      - lookup – A Multiple lookup.

      - default_category – If the first segment of a string lookup (which normally identifies a collection) does not specify a category, use this as the default category.

    Returns:

      Information about each artifact.

    Raises:

      - KeyError – if any of the lookups does not resolve to an item.

      - LookupError – if any of the lookups is invalid in some way, or does not resolve to an artifact.

  lookup_single_artifact(lookup: int | str | None, default_category: CollectionCategory | None = None) → ArtifactInfo | None

    Look up a single artifact.

    Parameters:

      - lookup – A Single lookup.

      - default_category – If the first segment of a string lookup (which normally identifies a collection) does not specify a category, use this as the default category.

    Returns:

      Information about the artifact, or None if the provided lookup is None (for convenience in some call sites).

    Raises:

      - KeyError – if the lookup does not resolve to an item.

      - LookupError – if the lookup is invalid in some way, or does not resolve to an artifact.

  lookup_single_collection(lookup: int | str | None, default_category: CollectionCategory | None = None) → CollectionInfo | None

    Look up a single collection.

    Parameters:

      - lookup – A Single lookup.

      - default_category – If the first segment of a string lookup (which normally identifies a collection) does not specify a category, use this as the default category.

    Returns:

      Information about the collection, or None if the provided lookup is None (for convenience in some call sites).

    Raises:

      - KeyError – if the lookup does not resolve to an item.

      - LookupError – if the lookup is invalid in some way, or does not resolve to a collection.

class debusine.db.models.Token(*args, **kwargs)

  Bases: `Model`

  Database model of a token.

  A token contains a key and other related data. It’s used as a shared key between debusine server and clients (workers).

  This token model is very similar to rest_framework.authtoken.models.Token. The bigger difference is that debusine’s token’s owner is a CharField, the rest_framework owner is a OneToOne foreign key to a user.

  Database-wise we don’t store the token itself, but a hash of the token. `TokenManager.get_token_or_none()` can be used to check a provided token key against the database.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  activating_worker

    Accessor to the related object on the reverse side of a one-to-one relation.

    In the example:

        class Restaurant(Model):
            place = OneToOneField(Place, related_name='restaurant')

    `Place.restaurant` is a `ReverseOneToOneDescriptor` instance.

  comment

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  created_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  disable() → None

    Disable the token and save it.

  enable() → None

    Enable the token and save it.

  enabled

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  expire_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
  get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
  hash

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  key: str
  last_seen_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <debusine.db.models.auth.TokenManager object>
  save(*args: Any, **kwargs: Any) → None

    Save the token. If it’s a new token it generates a key.

  user

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  user_id
  worker

    Accessor to the related object on the reverse side of a one-to-one relation.

    In the example:

        class Restaurant(Model):
            place = OneToOneField(Place, related_name='restaurant')

    `Place.restaurant` is a `ReverseOneToOneDescriptor` instance.

class debusine.db.models.User(*args, **kwargs)

  Bases: `AbstractUser`

  Debusine user.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  aborted_work_requests

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  artifact_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  asset_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  can_display(user: PermissionUser) → bool

    Check if the user can be displayed.

  can_manage(user: PermissionUser) → bool

    Check if the user can manage this user.

  completed_work_requests

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  date_joined

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  debusine_groups

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  email

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  first_name

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  get_absolute_url() → str

    Return an absolute URL to this user.

  get_next_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=True, **kwargs)
  get_previous_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=False, **kwargs)
  group_memberships

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  groupauditlog_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  groups

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  identities

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  is_active

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  is_staff

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  is_superuser

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  is_system

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  last_login

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  last_name

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  logentry_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  objects = <debusine.db.models.auth.UserManager object>
  password

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  token_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  ui(request: HttpRequest) → UserUI

    Return a UI helper for this instance.

  user_created_collectionitem

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  user_permissions

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  user_removed_collectionitem

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  username

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  workrequest_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

class debusine.db.models.WellKnownWorkflowTemplate(*values)

  Bases: `StrEnum`

  Track well-known workflow template names for use by Debusine itself.

  Enumeration member names should be upper-cased versions of the corresponding workflow task names.

  UPDATE_SUITES = 'update-suites'

class debusine.db.models.WorkRequest(*args, **kwargs)

  Bases: `Model`

  Database model of a request to execute a task.

  Time-consuming operations offloaded to Workers and using Artifacts (and associated Files) as input and output.

  Submission API needs to check if the request is valid using ontological rules - e.g. whether the specified distribution for a build task exists.

  Avoid exposing the status of tasks to the admin interface to avoid runaway changes whilst the scheduler process is running.

  The WorkRequest uses the non-Django tasks module to do the checks on whether a task can run on a particular worker.

  ## WorkRequest State Machine

  New WorkRequest database entries default to `WorkRequest.Statuses.BLOCKED`.

  Once the WorkRequest is unblocked (which may happen almost immediately if it has no dependencies), the status is changed to `WorkRequest.Statuses.PENDING`.

  Once the WorkRequest is assigned to a worker and is running, the status is changed to `WorkRequest.Statuses.RUNNING`.

  If the WorkRequest is aborted, the status is `WorkRequest.Statuses.ABORTED`.

  If the task finishes on the Worker, the WorkRequest status will be `WorkRequest.Statuses.COMPLETED` and a WorkRequest.Result is then set, `WorkRequest.Results.SUCCESS` or `WorkRequest.Results.FAILURE`.

  `WorkRequest.pending_at` is set when the WorkRequest moves from `WorkRequest.Statuses.BLOCKED` to `WorkRequest.Statuses.PENDING`. `WorkRequest.started_at` is set when the WorkRequest moves from `WorkRequest.Statuses.PENDING` to `WorkRequest.Statuses.RUNNING`. `WorkRequest.completed_at` is set when the Task moves from `WorkRequest.Statuses.RUNNING` to `WorkRequest.Statuses.COMPLETED` or `WorkRequest.Statuses.ABORTED`.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  Results

    alias of `WorkRequestResults`

  Roles

    alias of `WorkRequestRoles`

  RuntimeStatuses

    alias of `_RuntimeStatuses`

  Statuses

    alias of `_WorkRequestStatuses`

  UnblockStrategy

    alias of `_UnblockStrategy`

  abort(*, output_data: OutputData | None = None) → None

    Abort a work request.

    If the work request is a workflow, then recursively abort its child work requests too.

  aborted_by

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  aborted_by_id
  add_dependency(dependency: WorkRequest, *, skip_same_workflow_check: bool = False) → None

    Make this work request depend on another one.

    Parameters:

      - dependency – the work request to add as a new dependency; if this work request is part of a workflow, then the new dependency must be part of the same workflow.

      - skip_same_workflow_check – when adding a large number of dependencies, checking that they are all part of the same workflow may be slow; if this is True, the caller promises that it has already ensured that.

  add_event_reaction(event_name: Literal['on_creation', 'on_unblock', 'on_assignment', 'on_success', 'on_failure'], action: Annotated[ActionSkipIfLookupResultChanged | ActionSendNotification | ActionUpdateCollectionWithArtifacts | ActionUpdateCollectionWithData | ActionRetryWithDelays | ActionRecordInTaskHistory, FieldInfo(annotation=NoneType, required=True, discriminator='action')]) → None

    Add an event reaction.

  apply_task_configuration(worker: Worker | None = None) → None

    Apply task configuration, filling configured_task_data.

  artifact_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  asset_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  assign_worker(worker: Worker) → None

    Assign worker and save it.

  can_abort(user: PermissionUser) → bool

    Check if the work request can be aborted.

  can_be_automatically_unblocked() → bool

    Return True iff this work request can be automatically unblocked.

  can_be_unblocked() → bool

    Return True iff this work request can be unblocked at all.

  can_confirm(user: PermissionUser) → bool

    Check if the work request can be confirmed.

  can_display(user: PermissionUser) → bool

    Check if the work request can be displayed.

  can_retry(user: PermissionUser) → bool

    Check if the work request can be retried.

  can_satisfy_dynamic_data() → bool

    Check if dynamic data can still be looked up.

  can_unblock(user: PermissionUser) → bool

    Check if the work request can be unblocked.

  children

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  clean() → None

    Ensure that task data is valid for this task name.

    Raises:

      ValidationError – for invalid data.

  completed_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  completed_by

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  completed_by_id
  configure_for_worker(worker: Worker) → None

    Populate configured and dynamic task_data for this worker.

  configured_task_data

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  create_child_internal(task_name: str, workflow_data: WorkRequestWorkflowData | None = None, relative_priority: int = 0) → WorkRequest

    Create a child INTERNAL WorkRequest.

  create_child_server(task_name: str, task_data: BaseTaskData | None = None, workflow_data: WorkRequestWorkflowData | None = None) → WorkRequest

    Create a child SERVER WorkRequest.

  create_child_signing(task_name: str, task_data: BaseTaskData | None = None, workflow_data: WorkRequestWorkflowData | None = None) → WorkRequest

    Create a child SIGNING WorkRequest.

  create_child_wait(task_name: str, workflow_data: WorkRequestWorkflowData, task_data: BaseTaskData | None = None) → WorkRequest

    Create a child WAIT WorkRequest.

  create_child_worker(task_name: str, task_data: BaseTaskData | None = None, workflow_data: WorkRequestWorkflowData | None = None, event_reactions: EventReactions | None = None, relative_priority: int = 0) → WorkRequest

    Create a child WORKER WorkRequest.

  create_child_workflow(task_name: str, task_data: BaseTaskData | None = None, workflow_data: WorkRequestWorkflowData | None = None, event_reactions: EventReactions | None = None, relative_priority: int = 0) → WorkRequest

    Create a child WORKFLOW WorkRequest.

  created_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  created_by

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  created_by_id
  de_assign_worker() → bool

    De-assign a worker from this work request.

    Only allowed if the status is RUNNING or PENDING.

  dependencies

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  descendants

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  property duration: float | None

    Return duration in seconds between started_at and completed_at.

  dynamic_task_data

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  effective_expiration_delay() → timedelta

    Return expiration_delay, inherited if None.

  property event_reactions: EventReactions

    Access event_reactions_json as a pydantic structure.

  event_reactions_json

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  expiration_delay

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  property expire_at: datetime | None

    Return computed expiration date.

  get_absolute_url() → str

    Return an absolute URL to this work request.

  get_absolute_url_abort() → str

    Return an absolute URL to abort this work request.

  get_absolute_url_confirm() → str

    Return an absolute URL to confirm this work request.

  get_absolute_url_retry() → str

    Return an absolute URL to retry this work request.

  get_absolute_url_unblock() → str

    Return an absolute URL to unblock this work request.

  get_label() → str

    Return a label for this work request: “{name}: {parameter_summary}”.

    Where “parameter_summary” is optional.

    - “name”: * workflow: workflow_template_name else task_name * task: task_name

  get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
  get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
  get_result_display(*, field=<django.db.models.fields.CharField: result>)
  get_roles(user: PermissionUser) → frozenset[WorkRequestRoles]

    Get the effective roles of the user on this workspace.

    If you invoke this method on a whole queryset, you greatly reduce the number of queries by annotating the queryset using `with_role_annotations`.

  get_status_display(*, field=<django.db.models.fields.CharField: status>)
  get_task(worker: Worker | None = None) → DBTask[Any, Any]

    Instantiate the Task for this work request.

    Parameters:

      worker – if set, the worker that this work request is intended to run on; worker_native_architecture will be set to its native architecture

    Raises:

      InternalTaskError – if the work request is for an internal task other than a workflow callback

  get_task_type_display(*, field=<django.db.models.fields.CharField: task_type>)
  get_triggered_actions(event_name: Literal['on_creation', 'on_unblock', 'on_assignment', 'on_success', 'on_failure']) → dict[str, list[Annotated[ActionSkipIfLookupResultChanged | ActionSendNotification | ActionUpdateCollectionWithArtifacts | ActionUpdateCollectionWithData | ActionRetryWithDelays | ActionRecordInTaskHistory, FieldInfo(annotation=NoneType, required=True, discriminator='action')]]]

    Filter events to trigger, grouped by type.

    Parameters:

      event_name – the name of the event being triggered.

  get_unblock_strategy_display(*, field=<django.db.models.fields.CharField: unblock_strategy>)
  get_workflow_runtime_status_display(*, field=<django.db.models.fields.CharField: workflow_runtime_status>)
  property has_children_in_progress: bool

    Return whether child work requests are still in progress.

  has_role(user: PermissionUser, role: WorkRequestRoles) → bool

    Check if the user has the given role on this Workspace.

  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  internal_collection

    Accessor to the related object on the forward side of a one-to-one relation.

    In the example:

        class Restaurant(Model):
            place = OneToOneField(Place, related_name='restaurant')

    `Restaurant.place` is a `ForwardOneToOneDescriptor` instance.

  internal_collection_id
  is_aborted_failed() → bool

    Check if the work request was aborted or failed.

  property is_part_of_workflow: bool

    Return whether this work request is part of a workflow.

  property is_workflow: bool

    Return whether this work request is a workflow.

  property is_workflow_root: bool

    Return whether this work request is a root workflow.

  lookup_multiple(lookup: LookupMultiple, *, workspace: Workspace | None = None, default_category: CollectionCategory | None = None, expect_type: LookupChildType = LookupChildType.ANY) → Sequence[LookupResult]

    Look up collection items for this work request using a multiple lookup.

    See Multiple lookup.

    Raises:

      - KeyError – if any of the lookups does not resolve to an item.

      - LookupError – if any of the lookups is invalid in some way, or does not resolve to the expected collection item type.

  lookup_single(lookup: LookupSingle, *, workspace: Workspace | None = None, default_category: CollectionCategory | None = None, expect_type: LookupChildType = LookupChildType.ANY) → LookupResult

    Look up a collection item for this work request using a single lookup.

    See Single lookup.

    Raises:

      - KeyError – if the lookup does not resolve to an item.

      - LookupError – if the lookup is invalid in some way, or does not resolve to the expected collection item type.

  mark_aborted(*, user: User | None = None, output_data: OutputData | None = None) → None

    Worker has aborted the task after request from UI.

    Task will typically be in CREATED or RUNNING status.

  mark_completed(result: WorkRequest.Results, *, user: User | None = None, output_data: OutputData | None = None) → None

    Mark the task as completed.

    This is normally because a worker has finished executing it, though some `WAIT` tasks may also be completed by the scheduler or by a user action.

  mark_pending() → None

    Worker is ready for execution.

  mark_running() → None

    Worker has begun executing the task.

  maybe_finish_workflow() → bool

    Update workflow status if its children are no longer in progress.

  objects = <django.db.models.manager.WorkRequestManagerFromWorkRequestQuerySet object>
  property output_data: OutputData | None

    Access output_data_json as a pydantic structure.

  output_data_json

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  parent

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  parent_id
  pending_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  priority_adjustment

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  priority_base

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  property priority_effective: int

    The effective priority of this work request.

  property priority_for_metrics: str

    A low-cardinality label for the effective priority.

  process_event_reactions(event_name: Literal['on_creation', 'on_unblock', 'on_assignment', 'on_success', 'on_failure']) → None

    Process list of actions to perform.

  process_record_in_task_history(actions: list[Annotated[ActionSkipIfLookupResultChanged | ActionSendNotification | ActionUpdateCollectionWithArtifacts | ActionUpdateCollectionWithData | ActionRetryWithDelays | ActionRecordInTaskHistory, FieldInfo(annotation=NoneType, required=True, discriminator='action')]]) → None

    Record a task run in a task-history collection.

  process_retry_with_delays(actions: list[Annotated[ActionSkipIfLookupResultChanged | ActionSendNotification | ActionUpdateCollectionWithArtifacts | ActionUpdateCollectionWithData | ActionRetryWithDelays | ActionRecordInTaskHistory, FieldInfo(annotation=NoneType, required=True, discriminator='action')]]) → None

    Retry a work request with delays.

  process_skip_if_lookup_result_changed(actions: list[Annotated[ActionSkipIfLookupResultChanged | ActionSendNotification | ActionUpdateCollectionWithArtifacts | ActionUpdateCollectionWithData | ActionRetryWithDelays | ActionRecordInTaskHistory, FieldInfo(annotation=NoneType, required=True, discriminator='action')]]) → None

    Skip this work request if the result of a lookup has changed.

  process_update_collection_with_artifacts(actions: list[Annotated[ActionSkipIfLookupResultChanged | ActionSendNotification | ActionUpdateCollectionWithArtifacts | ActionUpdateCollectionWithData | ActionRetryWithDelays | ActionRecordInTaskHistory, FieldInfo(annotation=NoneType, required=True, discriminator='action')]]) → None

    Update collection with artifacts following event_reactions.

  process_update_collection_with_data(actions: list[Annotated[ActionSkipIfLookupResultChanged | ActionSendNotification | ActionUpdateCollectionWithArtifacts | ActionUpdateCollectionWithData | ActionRetryWithDelays | ActionRecordInTaskHistory, FieldInfo(annotation=NoneType, required=True, discriminator='action')]]) → None

    Update collection with bare data following event_reactions.

  property requires_confirmation: bool

    True if this task is blocked on user confirmation.

  property requires_signature: bool

    True if this task is blocked on debusine provide-signature.

  result

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  retry(reason: WorkRequestRetryReason = WorkRequestRetryReason.MANUAL) → WorkRequest

    Create a WorkRequest that supersedes this one.

    Parameters:

      reason – The reason for retrying this work request. If it is `WORKER_FAILED`, then only allow the retry if the retry count is less than `MAX_AUTOMATIC_RETRIES`. If it is either `WORKER_FAILED` or `DELAY`, then increment the work request’s `retry_count`; otherwise, set it back to 0.

  reverse_dependencies

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  review_manual_unblock(*, user: User, notes: str, action: WorkRequestManualUnblockAction | None) → None

    Review a work request awaiting manual unblocking.

  running_workflow_orchestrator() → Generator[None]

    Temporarily indicate that we are running this workflow’s orchestrator.

    `maybe_finish_workflow()` does nothing while this is the case, since the workflow may not yet have been completely populated.

  save(*args: Any, **kwargs: Any) → None

    Save the current instance.

  schedule_workflow_update() → None

    Schedule updates of expensive properties of containing workflows.

    The `workflow_last_activity_at` and `workflow_runtime_status` fields of workflows are used in the web UI and need to be kept up to date, but updating them requires scanning the workflow graph and can be expensive. When making changes to a large workflow graph, much of this work can be amortized: for example, we only need to update the root workflow once even if many work requests under it have changed. We therefore defer that work until the end of the transaction and run it in a Celery task.

  scheduler_tags_provided

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  scheduler_tags_required

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  scheduling_disabled() → Generator[None]

    Temporarily disable scheduling on changes to this work request.

  set_current() → None

    Set the execution context to this scope/user/workspace.

  started_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  status

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  superseded

    Accessor to the related object on the reverse side of a one-to-one relation.

    In the example:

        class Restaurant(Model):
            place = OneToOneField(Place, related_name='restaurant')

    `Place.restaurant` is a `ReverseOneToOneDescriptor` instance.

  supersedes

    Accessor to the related object on the forward side of a one-to-one relation.

    In the example:

        class Restaurant(Model):
            place = OneToOneField(Place, related_name='restaurant')

    `Restaurant.place` is a `ForwardOneToOneDescriptor` instance.

  supersedes_id
  task_data

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  task_name

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  task_type

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  ui(request: HttpRequest) → WorkRequestUI

    Return a UI helper for this instance.

  unblock_reverse_dependencies() → None

    Unblock reverse dependencies.

  unblock_strategy

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  unblock_workflow_children() → None

    Unblock children of a workflow that has just started running.

  property used_task_data: Any

    Return the task data used to run this task.

  verify_abort() → bool

    Check if this work request can be aborted.

  verify_retry() → bool

    Check if this work request can be retried.

  version

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  worker

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  worker_id
  workflow_created_collectionitem

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  property workflow_data: WorkRequestWorkflowData

    Access workflow_data_json as a python structure.

  workflow_data_json

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  property workflow_display_name: str

    Return this work request’s name for display in a workflow.

  property workflow_display_name_parameters: str | None

    Return this workflow template name with useful information.

  workflow_last_activity_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  workflow_removed_collectionitem

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  workflow_root

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  workflow_root_id
  workflow_runtime_status

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  workflow_template

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  workflow_template_id
  workflows_need_update

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  workspace

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  workspace_id

class debusine.db.models.Worker(*args, **kwargs)

  Bases: `Model`

  Database model of a worker.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  activation_token

    Accessor to the related object on the forward side of a one-to-one relation.

    In the example:

        class Restaurant(Model):
            place = OneToOneField(Place, related_name='restaurant')

    `Restaurant.place` is a `ForwardOneToOneDescriptor` instance.

  activation_token_id
  assigned_work_requests

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  concurrency

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  connected() → bool

    Return True if the Worker is connected.

  connected_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  dynamic_metadata

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  dynamic_metadata_updated_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  get_absolute_url() → str

    Return an absolute URL to view this worker.

  get_next_by_registered_at(*, field=<django.db.models.fields.DateTimeField: registered_at>, is_next=True, **kwargs)
  get_previous_by_registered_at(*, field=<django.db.models.fields.DateTimeField: registered_at>, is_next=False, **kwargs)
  get_worker_type_display(*, field=<django.db.models.fields.CharField: worker_type>)
  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  instance_created_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  is_at_capacity() → bool

    Return True if the Worker is busy with work requests.

    A Worker is at capacity if it has as many running or pending work requests as its concurrency level.

  is_busy() → bool

    Return True if the Worker has any active work requests.

  mark_connected() → None

    Update and save relevant Worker fields after connecting.

  mark_disconnected() → None

    Update and save relevant Worker fields after disconnecting.

  metadata() → dict[str, Any]

    Return all metadata with static_metadata and dynamic_metadata merged.

    If the same key is in static_metadata and dynamic_metadata: static_metadata takes priority.

  name

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.WorkerManagerFromWorkerQuerySet object>
  registered_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  running_work_requests() → QuerySet

    Return queryset of work requests running on this worker.

  set_dynamic_metadata(metadata: dict[str, Any]) → None

    Save metadata and update dynamic_metadata_updated_at.

  static_metadata

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  token

    Accessor to the related object on the forward side of a one-to-one relation.

    In the example:

        class Restaurant(Model):
            place = OneToOneField(Place, related_name='restaurant')

    `Restaurant.place` is a `ForwardOneToOneDescriptor` instance.

  token_id
  ui(request: HttpRequest) → WorkerUI

    Return a UI helper for this instance.

  worker_pool

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  worker_pool_data

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  worker_pool_id
  worker_type

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  workerpoolstatistics_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  workerpooltaskexecutionstatistics_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

class debusine.db.models.WorkerPool(*args, **kwargs)

  Bases: `Model`

  Database model of a worker pool.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  architectures

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  clean() → None

    Ensure that data is valid for this worker pool.

    Raises:

      ValidationError – for invalid data.

  enabled

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  ephemeral

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  get_absolute_url() → str

    Return an absolute URL to view this WorkerPool.

  get_next_by_registered_at(*, field=<django.db.models.fields.DateTimeField: registered_at>, is_next=True, **kwargs)
  get_previous_by_registered_at(*, field=<django.db.models.fields.DateTimeField: registered_at>, is_next=False, **kwargs)
  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  instance_wide

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  launch_workers(count: int, override_disabled: bool = False) → None

    Launch count additional worker instances.

  limits

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  property limits_model: WorkerPoolLimits

    Return the pydantic model for limits.

  name

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <debusine.db.models.worker_pools.WorkerPoolManager object>
  provider_account

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  provider_account_id
  property provider_interface: WorkerPoolInterface

    Return a WorkerPoolInterface instance for this pool.

  registered_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  scopeworkerpool_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  specifications

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  property specifications_model: WorkerPoolSpecifications

    Return the pydantic model for specifications.

  tags

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  terminate_worker(worker: Worker) → None

    Terminate the specified worker instance.

  ui(request: HttpRequest) → WorkerPoolUI

    Return a UI helper for this instance.

  worker_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  workerpoolstatistics_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  workerpooltaskexecutionstatistics_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  property workers_running: QuerySet

    Return the Worker instances that are currently running.

  property workers_stopped: QuerySet

    Return the Worker instances that are currently stopped.

class debusine.db.models.WorkerPoolStatistics(*args, **kwargs)

  Bases: `Model`

  Running time for historical worker instances, stored at shutdown.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  get_next_by_timestamp(*, field=<django.db.models.fields.DateTimeField: timestamp>, is_next=True, **kwargs)
  get_previous_by_timestamp(*, field=<django.db.models.fields.DateTimeField: timestamp>, is_next=False, **kwargs)
  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.Manager object>
  runtime

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  timestamp

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  worker

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  worker_id
  worker_pool

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  worker_pool_id

class debusine.db.models.WorkerPoolTaskExecutionStatistics(*args, **kwargs)

  Bases: `Model`

  Time spent executing tasks in a scope, stored at completion.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  get_next_by_timestamp(*, field=<django.db.models.fields.DateTimeField: timestamp>, is_next=True, **kwargs)
  get_previous_by_timestamp(*, field=<django.db.models.fields.DateTimeField: timestamp>, is_next=False, **kwargs)
  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.Manager object>
  runtime

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  scope

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  scope_id
  timestamp

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  worker

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  worker_id
  worker_pool

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  worker_pool_id

class debusine.db.models.WorkflowTemplate(*args, **kwargs)

  Bases: `Model`

  Database model for Workflow templates.

  Workflow templates contain the information needed to instantiate a workflow, with a Workflow orchestrator and mandatory parameters.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  can_configure(user: PermissionUser) → bool

    Check if the workflow template can be configured.

  can_display(user: PermissionUser) → bool

    Check if the workflow template can be displayed.

  can_run(user: PermissionUser) → bool

    Check if the workflow template can be run.

  clean() → None

    Ensure that task_name, static & runtime parameters are valid.

    Raises:

      ValidationError – for invalid data.

  completed_workflows() → int

    Count completed workflows for this template in context.workspace.

  get_absolute_url() → str

    Return the canonical display URL.

  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  name

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  needs_input_workflows() → int

    Count completed workflows for this template in context.workspace.

  objects = <django.db.models.manager.WorkflowTemplateManagerFromWorkflowTemplateQuerySet object>
  priority

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  running_workflows() → int

    Count completed workflows for this template in context.workspace.

  runtime_parameters

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  static_parameters

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  task_name

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  ui(request: HttpRequest) → WorkflowTemplateUI

    Return a UI helper for this instance.

  workrequest_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  workspace

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  workspace_id

class debusine.db.models.Workspace(*args, **kwargs)

  Bases: `Model`

  Workspace model.

  exception DoesNotExist

    Bases: `ObjectDoesNotExist`

  exception MultipleObjectsReturned

    Bases: `MultipleObjectsReturned`

  Roles

    alias of `WorkspaceRoles`

  artifact_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  asset_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  asset_usage

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  can_configure(user: PermissionUser) → bool

    Check if the workspace can be configured.

  can_create_artifacts(user: PermissionUser) → bool

    Check if the user can create artifacts.

  can_create_child_workspace(user: PermissionUser) → bool

    Check if the user can create a child workspace from this.

  can_create_collections(user: PermissionUser) → bool

    Check if the user can create collections.

  can_create_work_requests(user: PermissionUser) → bool

    Check if the user can create work requests.

  can_display(user: PermissionUser) → bool

    Check if the workspace can be displayed.

  can_edit_task_configuration(user: PermissionUser) → bool

    Check if the user can edit task configuration.

  chain_children

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  chain_parents

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  collections

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  created_at

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  default_expiration_delay

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  expiration_delay

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  property expire_at: datetime | None

    Return computed expiration date.

  file_needs_upload(fileobj: File) → bool

    Return True if fileobj needs to be uploaded to this workspace.

    Before an artifact can be considered complete, all its files must be part of the artifact’s workspace. This requires each file to be in one of its stores, and also to be in some artifact in the workspace. Otherwise, the file must be uploaded, even if it already exists somewhere else in debusine; this prevents users obtaining unauthorized access to existing file contents.

  get_absolute_url() → str

    Return an absolute URL to this workspace.

  get_absolute_url_configure() → str

    Return an absolute URL to configure this workspace.

  get_absolute_url_configure_inheritance() → str

    Return an absolute URL to configure the inheritance chain.

  get_collection(*, user: PermissionUser, category: str, name: str) → Collection

    Look up a collection by category and name.

    If the collection is not found in this workspace, it follows the workspace inheritance chain using a depth-first search.

    Parameters:

      - user – user to use for permission checking

      - category – collection category

      - name – collection name

    Raises:

      Collection.DoesNotExist – if the collection was not found

  get_group_roles(user: PermissionUser) → QuerySet

    Get the roles of the user on this workspace.

  get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
  get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
  get_roles(user: PermissionUser) → frozenset[WorkspaceRoles]

    Get the effective roles of the user on this workspace.

    If you invoke this method on each result of a whole queryset, you should annotate the queryset using `with_role_annotations` to greatly reduce the number of queries.

  get_singleton_collection(*, user: User | AnonymousUser, category: str) → Collection

    Lookup a singleton collection by category.

    If the collection is not found in this workspace, it follows the workspace inheritance chain using a depth-first search.

    Parameters:

      - user – user to use for permission checking

      - category – collection category

    Raises:

      Collection.DoesNotExist – if the collection was not found

  group_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  has_role(user: PermissionUser, role: WorkspaceRoles) → bool

    Check if the user has the given role on this Workspace.

  id

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  inherited_by

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  inherits

    Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

    In the example:

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    `Pizza.toppings` and `Topping.pizzas` are `ManyToManyDescriptor` instances.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  list_accessible_collections(user: User | AnonymousUser, category: CollectionCategory, *, ws_seen: tuple[int, ...] = (), coll_seen: set[int] | None = None) → Generator[Collection]

    List all collections of a given category accessible from a workspace.

    It recurses up the workspace inheritance chain, breaking loops.

    Parameters:

      - user – user to use for accessibility checks

      - category – the category of collections to list

      - ws_seen – IDs of workspaces already visited during recursion, used to break loops

      - coll_seen – IDs of collections already produced, to remove duplicates when workspaces appear multiple times in the inheritance tree

  make_inheritance_chain_cte(visible: With) → Callable[[With], WorkspaceQuerySet]

    Make a recursive CTE factory to follow a workspace’s inheritance chain.

    Parameters:

      visible – A Common Table Expression with the results of `Workspace.objects.can_display(user)`, which will be used by this CTE.

    Returns:

      a function that can be passed as the first argument to `With.recursive`. The `path_order` field in the `QuerySet` it returns allows ordering the results as for a depth-first search.

  name

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  objects = <django.db.models.manager.WorkspaceManagerFromWorkspaceQuerySet object>
  public

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

  roles

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  save(**kwargs: Any) → None

    Wrap save with permission checks.

  scope

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Child.parent` is a `ForwardManyToOneDescriptor` instance.

  scope_id
  set_current() → None

    Set this as the current workspace.

    This needs to be called after `context.set_scope` and `context.set_user`.

  set_inheritance(chain: Sequence[Workspace]) → None

    Set the inheritance chain for this workspace.

  ui(request: HttpRequest) → WorkspaceUI

    Return a UI helper for this instance.

  workflowtemplate_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

  workrequest_set

    Accessor to the related objects manager on the reverse side of a many-to-one relation.

    In the example:

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    `Parent.children` is a `ReverseManyToOneDescriptor` instance.

    Most of the implementation is delegated to a dynamically defined manager class built by `create_forward_many_to_many_manager()` defined below.

debusine.db.models.default_file_store() → FileStore

  Return the default file store.

debusine.db.models.default_workspace() → Workspace

  Return the default Workspace.

debusine.db.models.system_user() → User

  Return the _system user.

Signing service data models.

class debusine.signing.models.AvailableKeyFileSystem(*, temp_dir: Path, certificate: ReadableBuffer, key: ReadableBuffer)

  Bases: `BaseAvailableKey`

  An available private key on the file system.

  __init__(*, temp_dir: Path, certificate: ReadableBuffer, key: ReadableBuffer) → None

    Construct an `AvailableKeyFileSystem`.

  property sbsign_args: list[str]

    Arguments for sbsign.

class debusine.signing.models.AvailableKeyPKCS11(*, temp_dir: Path, certificate: ReadableBuffer, pkcs11_uri: str)

  Bases: `BaseAvailableKey`

  An available private key on a PKCS#11 token.

  __init__(*, temp_dir: Path, certificate: ReadableBuffer, pkcs11_uri: str) → None

    Construct an `AvailableKeyPKCS11`.

  property sbsign_args: list[str]

    Arguments for sbsign.

class debusine.signing.models.BaseAvailableKey(*, temp_dir: Path, certificate: ReadableBuffer)

  Bases: `ABC`

  A protected key that has temporarily been made available.

  __init__(*, temp_dir: Path, certificate: ReadableBuffer) → None

    Construct a `BaseAvailableKey`.

  abstract property sbsign_args: list[str]

    Arguments for sbsign.

class debusine.signing.models.BaseProtectedKey(*, storage: ProtectedKeyStorage)

  Bases: `BaseModel`, `ABC`

  Base class for protected private keys.

  abstractmethod available(public_key: ReadableBuffer) → Generator[BaseAvailableKey]

    Make a protected key temporarily available.

    Controls on the available key may vary depending on the type of protection used, but they should at least ensure that private keys do not end up on a persistent file system.

  model_config: ClassVar[ConfigDict] = {}

    Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

  storage: ProtectedKeyStorage

class debusine.signing.models.ProtectedKey(root: RootModelRootType = PydanticUndefined)

  Bases: `RootModel[Annotated[Union[ProtectedKeyNaCl, ProtectedKeyPKCS11Static], FieldInfo(annotation=NoneType, required=True, discriminator='storage')]]`

  A protected private key.

  available(public_key: ReadableBuffer) → Generator[BaseAvailableKey]

    Make a protected key temporarily available.

    Controls on the available key may vary depending on the type of protection used, but they should at least ensure that private keys do not end up on a persistent file system.

  model_config: ClassVar[ConfigDict] = {}

    Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

exception debusine.signing.models.ProtectedKeyError

  Bases: `Exception`

  An error handling a protected key.

class debusine.signing.models.ProtectedKeyNaCl(*, storage: ~typing.Literal[ProtectedKeyStorage.NACL], public_key: ~typing.Annotated[bytes, ~pydantic.types.EncodedBytes(encoder=~pydantic.types.Base64Encoder), ~pydantic.functional_validators.BeforeValidator(func=~debusine.utils.<lambda>, json_schema_input_type=str), ~pydantic.functional_serializers.WrapSerializer(func=~debusine.utils.<lambda>, return_type=str, when_used=always)], encrypted: ~typing.Annotated[bytes, ~pydantic.types.EncodedBytes(encoder=~pydantic.types.Base64Encoder), ~pydantic.functional_validators.BeforeValidator(func=~debusine.utils.<lambda>, json_schema_input_type=str), ~pydantic.functional_serializers.WrapSerializer(func=~debusine.utils.<lambda>, return_type=str, when_used=always)])

  Bases: `BaseProtectedKey`

  Data for a private key encrypted in software using NaCl.

  available(public_key: ReadableBuffer) → Generator[BaseAvailableKey]

    Make this protected key temporarily available.

  classmethod create(*, public_key: ReadableBuffer, encrypted: ReadableBuffer) → Self

    Create a new `ProtectedKeyNaCl`.

  decrypt(private_keys: Iterable[PrivateKey]) → bytes

    Decrypt data using any of an iterable of NaCl private keys.

    This uses the private key that matches the stored public key, if one exists. This allows for key rotation.

    Raises:

      ProtectedKeyError – if none of the given private keys match the stored public key.

  classmethod encrypt(public_key: PublicKey, data: bytes) → Self

    Encrypt data using a NaCl public key.

  encrypted: <lambda>, return_type=str, when_used=always)]
  model_config: ClassVar[ConfigDict] = {}

    Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

  public_key: <lambda>, return_type=str, when_used=always)]
  storage: Literal[ProtectedKeyStorage.NACL]

class debusine.signing.models.ProtectedKeyPKCS11Static(*, storage: Literal[ProtectedKeyStorage.PKCS11_STATIC], pkcs11_uri: str)

  Bases: `BaseProtectedKey`

  Data for a private key held on a PKCS#11 token.

  This key is not extracted under wrap; it only ever lives on the token.

  available(public_key: ReadableBuffer) → Generator[BaseAvailableKey]

    Make this protected key temporarily available.

  classmethod create(*, pkcs11_uri: str) → Self

    Create a new `ProtectedKeyPKCS11Static`.

  model_config: ClassVar[ConfigDict] = {}

    Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

  pkcs11_uri: str
  storage: Literal[ProtectedKeyStorage.PKCS11_STATIC]

class debusine.signing.models.ProtectedKeyStorage(*values)

  Bases: `StrEnum`

  Possible values for ProtectedKey.storage.

  NACL = 'nacl'
  PKCS11_STATIC = 'pkcs11-static'

class debusine.signing.models.SigningMode(*values)

  Bases: `StrEnum`

  The kind of signing to perform.

  Only some combinations of key purpose and signing mode are valid.

  ATTACHED = 'attached'
  CLEAR = 'clear'
  DEBSIGN = 'debsign'
  DETACHED = 'detached'