Database models

Data models for the db application.

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

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: Optional[Union[User, AnonymousUser]]) bool[source]

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()[source]

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[source]

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()[source]

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.datetime | None

Return computed expiration date.

expired(at: datetime) bool[source]

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[source]

Return the canonical URL to display the artifact.

get_absolute_url_download() str[source]

Return the canonical URL to download the artifact.

get_label(data: debusine.artifacts.models.ArtifactData | None = None) str[source]

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.

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.

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)[source]

Bases: Model

Model relations between artifacts.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

class Relations(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

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
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.Manager 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.Collection(*args, **kwargs)[source]

Bases: Model

Model representing a collection.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

RetainsArtifacts

alias of _CollectionRetainsArtifacts

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.

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[source]

Return the canonical URL to display the item.

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 = <debusine.db.models.collections.CollectionManager 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.

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)[source]

Bases: Model

CollectionItem model.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

Types

alias of _CollectionItemTypes

active_objects = <debusine.db.models.collections.CollectionItemActiveManager object>
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[source]

Format item name following item_template.

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

Expand JSONPath variables against some data.

The data will normally come from an Artifact.

get_absolute_url() str[source]

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 = <debusine.db.models.collections.CollectionItemManager 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[source]

Populate parent_category on save.

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

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)[source]

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[source]

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[source]

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)[source]

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.

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[source]

Return an absolute URL to view this file.

get_absolute_url_raw() str[source]

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.

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

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)[source]

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()[source]

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'>}
static default() FileStore[source]

Return the default FileStore.

default_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.

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.

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

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.

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>
other_workspaces

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.

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

Bases: Model

File that is being/has been uploaded.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

absolute_file_path() Path[source]

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[source]

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, **kwargs)[source]

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)[source]

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

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 = <debusine.db.models.auth.GroupManager object>
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.

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_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)[source]

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)[source]

Bases: Model

Model to store notification configuration.

exception DoesNotExist

Bases: ObjectDoesNotExist

class Methods(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: TextChoices

EMAIL = 'email'
exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

clean()[source]

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 = {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, **kwargs)[source]

Run validators and save the instance.

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

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

assign_role(role: ScopeRole.Roles, group: Group) ScopeRole[source]

Assign a role to a group.

can_create_workspace(user: Optional[Union[User, AnonymousUser]]) bool[source]

Check if the scope can be displayed.

can_display(user: Optional[Union[User, AnonymousUser]]) bool[source]

Check if the scope can be displayed.

get_roles(user: Union[User, AnonymousUser]) QuerySet[source]

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.

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.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.

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.TaskDatabase(work_request: WorkRequest)[source]

Bases: TaskDatabaseInterface

Implementation of database interaction in worker tasks.

__init__(work_request: WorkRequest) None[source]

Construct a TaskDatabase.

get_server_setting(setting: str) str[source]

Look up a Django setting (strings only).

lookup_multiple_artifacts(lookup: debusine.tasks.models.LookupMultiple | None, default_category: debusine.artifacts.models.CollectionCategory | None = None) list[int][source]

Look up multiple artifacts using Multiple lookup.

lookup_single_artifact(lookup: int | str, default_category: debusine.artifacts.models.CollectionCategory | None = None) int[source]
lookup_single_artifact(lookup: None, default_category: debusine.artifacts.models.CollectionCategory | None = None) None

Look up a single artifact using Single lookup.

lookup_single_collection(lookup: int | str, default_category: debusine.artifacts.models.CollectionCategory | None = None) int[source]
lookup_single_collection(lookup: None, default_category: debusine.artifacts.models.CollectionCategory | None = None) None

Look up a single collection using Single lookup.

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

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

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[source]

Disable the token and save it.

enable() None[source]

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.

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, **kwargs) None[source]

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)[source]

Bases: AbstractUser

Debusine user.

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.

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_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)
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.

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.

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.WorkRequest(*args, **kwargs)[source]

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.PENDING.

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

If the WorkRequest is aborted, the Scheduled.Task status is WorkRequest.Statuses.ABORTED.

If the task finish on the Worker the WorkRequest status will be WorkRequest.Statuses.COMPLETED and a WorkRequest.Result is then set, WorkRequest.Results.PASSED or WorkRequest.Results.FAILED.

digraph {
   Statuses_PENDING -> Statuses_RUNNING -> Statuses_COMPLETED;
   Statuses_PENDING -> Statuses_COMPLETED;
   Statuses_PENDING -> Statuses_ABORTED;
   Statuses_PENDING -> Statuses_RUNNING -> Statuses_ABORTED;
}

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.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

class Results(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: TextChoices

ERROR = 'error'
FAILURE = 'failure'
NONE = ''
SUCCESS = 'success'
Statuses

alias of _WorkRequestStatuses

class UnblockStrategy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: TextChoices

DEPS = 'deps'
MANUAL = 'manual'
add_dependency(dependency: WorkRequest) None[source]

Make this work request depend on another one.

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.

assign_worker(worker: Worker) None[source]

Assign worker and save it.

can_be_automatically_unblocked() bool[source]

Return True iff this work request can be automatically unblocked.

can_be_unblocked() bool[source]

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

can_retry() bool[source]

Check if this work request can be retried.

can_satisfy_dynamic_data() bool[source]

Check if dynamic data can still be looked up.

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()[source]

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.

create_child(task_name: str, status: _WorkRequestStatuses = _WorkRequestStatuses.BLOCKED, task_type: TaskTypes = TaskTypes.WORKER, task_data: dict[str, Any] | None = None, workflow_data: Optional[WorkRequestWorkflowData] = None, event_reactions: debusine.tasks.models.EventReactions | None = None) WorkRequest[source]

Create a child 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[source]

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.

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()[source]

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.datetime | None

Return computed expiration date.

get_absolute_url() str[source]

Return an absolute URL to this work request.

get_absolute_url_retry() str[source]

Return an absolute URL to retry this work request.

get_absolute_url_unblock() str[source]

Return an absolute URL to unblock this work request.

get_label(task: Optional[BaseTask[Any, Any]] = None) str[source]

Return a label for this work request.

Optionally reuse an already instantiated task.

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_status_display(*, field=<django.db.models.fields.CharField: status>)
get_task(worker: Worker | None = None) BaseTask[Any, Any][source]

Instantiate the Task for this work request.

Parameters:

worker – if set, the worker that this work request is intended to run on; worker_host_architecture will be set to its host 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_success', 'on_failure']) dict[str, list[Union[debusine.tasks.models.ActionSendNotification, debusine.tasks.models.ActionUpdateCollectionWithArtifacts, debusine.tasks.models.ActionUpdateCollectionWithData, debusine.tasks.models.ActionRetryWithDelays]]][source]

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_root() Optional[WorkRequest][source]

Return the root of this work request’s workflow, if any.

property has_children_in_progress: bool

Return whether child work requests are still in progress.

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[source]

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.

mark_aborted() bool[source]

Worker has aborted the task after request from UI.

Task will typically be in CREATED or RUNNING status.

mark_completed(result: Results) bool[source]

Worker has finished executing the task.

mark_pending() bool[source]

Worker is ready for execution.

mark_running() bool[source]

Worker has begun executing the task.

maybe_finish_workflow() bool[source]

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

objects = <debusine.db.models.work_requests.WorkRequestManager object>
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
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.

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

Process list of actions to perform.

process_retry_with_delays(actions: list[Union[debusine.tasks.models.ActionSendNotification, debusine.tasks.models.ActionUpdateCollectionWithArtifacts, debusine.tasks.models.ActionUpdateCollectionWithData, debusine.tasks.models.ActionRetryWithDelays]]) None[source]

Retry a work request with delays.

process_update_collection_with_artifacts(actions: list[Union[debusine.tasks.models.ActionSendNotification, debusine.tasks.models.ActionUpdateCollectionWithArtifacts, debusine.tasks.models.ActionUpdateCollectionWithData, debusine.tasks.models.ActionRetryWithDelays]]) None[source]

Update collection with artifacts following event_reactions.

process_update_collection_with_data(actions: list[Union[debusine.tasks.models.ActionSendNotification, debusine.tasks.models.ActionUpdateCollectionWithArtifacts, debusine.tasks.models.ActionUpdateCollectionWithData, debusine.tasks.models.ActionRetryWithDelays]]) None[source]

Update collection with bare data following event_reactions.

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() WorkRequest[source]

Create a WorkRequest that supersedes this one.

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[source]

Review a work request awaiting manual unblocking.

save(*args: Any, **kwargs: Any) None[source]

Save the current instance.

scheduling_disabled() Generator[None, None, None][source]

Temporarily disable scheduling on changes to this work request.

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.

unblock_reverse_dependencies()[source]

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[source]

Unblock children of a workflow that has just started running.

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: Optional[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.

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.

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)[source]

Bases: Model

Database model of a worker.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

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[source]

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_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.

is_busy() bool[source]

Return True if the Worker is busy with work requests.

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

mark_connected() None[source]

Update and save relevant Worker fields after connecting.

mark_disconnected() None[source]

Update and save relevant Worker fields after disconnecting.

metadata() dict[str, Any][source]

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 = <debusine.db.models.workers.WorkerManager 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[source]

Return queryset of work requests running on this worker.

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

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
worker_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.WorkflowTemplate(*args, **kwargs)[source]

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

clean()[source]

Ensure that task_name and task data are valid.

Raises:

ValidationError – for invalid data.

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.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.

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.

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)[source]

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.

assign_role(role: WorkspaceRoles, group: Group) WorkspaceRole[source]

Assign a role to a group.

can_create_artifacts(user: Optional[Union[User, AnonymousUser]]) bool[source]

Check if the user can create artifacts.

can_display(user: Optional[Union[User, AnonymousUser]]) bool[source]

Check if the workspace can be displayed.

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.

collection_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.

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.

default_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.

default_file_store_id
file_stores(fileobj: File) QuerySet[source]

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

The returned query set is ordered so that the workspace’s default file store comes first if it has the file, followed by any of the workspace’s other file stores that have it.

get_absolute_url() str[source]

Return an absolute URL to this workspace.

get_collection(*, user: Union[User, AnonymousUser], category: str, name: str, visited: set[int] | None = None) Collection[source]

Lookup 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

  • visited – for internal use only: state used during graph traversal

Raises:

Collection.DoesNotExist – if the collection was not found

get_roles(user: Union[User, AnonymousUser]) QuerySet[source]

Get the roles of the user on this workspace.

get_singleton_collection(*, user: Union[User, AnonymousUser], category: str) Collection[source]

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

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.

is_file_in_workspace(fileobj: File) bool[source]

Return True if fileobj is part of this workspace.

To be considered part of a workspace, a file must be in one of its stores, and must also be in an artifact which is in the workspace.

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>
other_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.

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[source]

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[source]

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[source]

Set the inheritance chain for this workspace.

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[source]

Return the default file store.

debusine.db.models.default_workspace() Workspace[source]

Return the default Workspace.

debusine.db.models.system_user() User[source]

Return the _system user.

Signing service data models.

class debusine.signing.models.AvailableKeyFileSystem(*, temp_dir: Path, certificate: bytes, key: bytes)[source]

Bases: BaseAvailableKey

An available private key on the file system.

__init__(*, temp_dir: Path, certificate: bytes, key: bytes) None[source]

Construct an AvailableKeyFileSystem.

property sbsign_args: list[str]

Arguments for sbsign.

class debusine.signing.models.AvailableKeyPKCS11(*, temp_dir: Path, certificate: bytes, pkcs11_uri: str)[source]

Bases: BaseAvailableKey

An available private key on a PKCS#11 token.

__init__(*, temp_dir: Path, certificate: bytes, pkcs11_uri: str) None[source]

Construct an AvailableKeyPKCS11.

property sbsign_args: list[str]

Arguments for sbsign.

class debusine.signing.models.BaseAvailableKey(*, temp_dir: Path, certificate: bytes)[source]

Bases: ABC

A protected key that has temporarily been made available.

__init__(*, temp_dir: Path, certificate: bytes) None[source]

Construct a BaseAvailableKey.

abstract property sbsign_args: list[str]

Arguments for sbsign.

class debusine.signing.models.BaseProtectedKey(*, storage: ProtectedKeyStorage)[source]

Bases: BaseModel, ABC

Base class for protected private keys.

abstract available(public_key: bytes) Generator[BaseAvailableKey, None, None][source]

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.

storage: ProtectedKeyStorage
class debusine.signing.models.ProtectedKey(*, __root__: debusine.signing.models.ProtectedKeyNaCl | debusine.signing.models.ProtectedKeyPKCS11Static)[source]

Bases: BaseModel

A protected private key.

available(public_key: bytes) Generator[BaseAvailableKey, None, None][source]

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.

exception debusine.signing.models.ProtectedKeyError[source]

Bases: Exception

An error handling a protected key.

class debusine.signing.models.ProtectedKeyNaCl(*, storage: ~typing.Literal[<ProtectedKeyStorage.NACL: 'nacl'>], public_key: str, encrypted: str)[source]

Bases: BaseProtectedKey

Data for a private key encrypted in software using NaCl.

available(public_key: bytes) Generator[BaseAvailableKey, None, None][source]

Make this protected key temporarily available.

classmethod create(*, public_key: str | bytes, encrypted: str | bytes) Self[source]

Create a new ProtectedKeyNaCl.

decrypt(private_keys: Iterable[PrivateKey]) bytes[source]

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[source]

Encrypt data using a NaCl public key.

encrypted: str
property encrypted_bytes: bytes

Return the base64-decoded encrypted data.

public_key: str
property public_key_bytes: bytes

Return the base64-decoded public key.

storage: NACL: 'nacl'>]
class debusine.signing.models.ProtectedKeyPKCS11Static(*, storage: ~typing.Literal[<ProtectedKeyStorage.PKCS11_STATIC: 'pkcs11-static'>], pkcs11_uri: str)[source]

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: bytes) Generator[BaseAvailableKey, None, None][source]

Make this protected key temporarily available.

classmethod create(*, pkcs11_uri: str) Self[source]

Create a new ProtectedKeyPKCS11Static.

pkcs11_uri: str
storage: PKCS11_STATIC: 'pkcs11-static'>]
class debusine.signing.models.ProtectedKeyStorage(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Possible values for ProtectedKey.storage.

NACL = 'nacl'
PKCS11_STATIC = 'pkcs11-static'
class debusine.signing.models.SigningMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

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'