Repository Apply Model

A batch apply of a GitHub repository’s manifests, which a user starts from the web console’s Apply page.

The Celery task smarter.apps.account.tasks.apply_repository() clones the repository, records each manifest that it finds as a RepositoryApplyManifest, pending, then applies them one by one, as manage.py load_from_github does, and records each one’s result: applied, skipped or failed, with why. The web console polls the run, and shows each manifest’s state. See smarter.apps.account.repository_apply.

smarter.apps.account.models.repository_apply.REPOSITORY_APPLY_STALE_AFTER = datetime.timedelta(seconds=1800)

A run that has neither finished nor failed after this long is abandoned, e.g. its worker restarted.

The user may then start another.

class smarter.apps.account.models.repository_apply.RepositoryApply(*args, **kwargs)[source]

Bases: TimestampedModel

A batch apply of a GitHub repository’s manifests.

Parameters:
  • user_profile – The user who started it, as whom every manifest is applied, in their account.

  • url – The repository, e.g. https://github.com/smarter-sh/example-manifests.

  • commit – The commit that was cloned, or an empty string before then, or if git couldn’t tell.

  • status – One of RepositoryApplyStatus.

  • error – Why the run failed as a whole, e.g. the repository couldn’t be cloned. A manifest’s own failure is its RepositoryApplyManifest.message.

  • completed_at – When it finished or failed.

  • id (Unknown) – Primary key: ID

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

Reverse relationships:

Parameters:

manifests (Unknown) – All manifests of this Repository Apply (related name of repository_apply)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

commit

CharField

Commit

Type:

Type

completed_at

DateTimeField

Completed at

Type:

Type

created_at

DateTimeField

Created at

Timestamp indicating when the model instance was created.

This field is automatically set to the current date and time when the instance is first created. It is indexed in the database for efficient querying.

Type:

Type

error

TextField

Error

Type:

Type

get_status_display(*, field=<django.db.models.CharField: status>)

Shows the label of the status. See get_FOO_display() for more information.

id: int

BigAutoField

Primary key: ID

The row’s primary key, which Django adds to every concrete model. Declared, without a value, only so that type checkers know it: Django ignores a bare annotation.

Type:

Type

property is_finished: bool

Whether it finished or failed.

property is_in_progress: bool

Whether it is queued, cloning or applying, and not abandoned.

property is_stale: bool

unfinished for longer than REPOSITORY_APPLY_STALE_AFTER.

Type:

Whether it was abandoned

manifests

Reverse ForeignKey from RepositoryApplyManifest

All manifests of this Repository Apply (related name of repository_apply)

Type:

Type

objects = <django.db.models.Manager object>
status

CharField

Status

Choices:

  • queued

  • cloning

  • applying

  • finished

  • failed

Type:

Type

updated_at

DateTimeField

Updated at

Timestamp indicating when the model instance was last updated.

This field is automatically updated to the current date and time whenever the instance is saved. It is indexed in the database for efficient querying.

Type:

Type

url

URLField

Url

Type:

Type

user_profile

ForeignKey to UserProfile

User profile (related name: repository_applies)

Type:

Type

user_profile_id

Internal field, use user_profile instead.

class smarter.apps.account.models.repository_apply.RepositoryApplyManifest(*args, **kwargs)[source]

Bases: TimestampedModel

One manifest of a batch apply, in the order in which it is applied.

Parameters:
  • repository_apply – The run.

  • position – Its place in the order of application, from 0.

  • path – Its file, relative to the repository’s root, e.g. plugins/sql/stackademy-sql.yaml.

  • kind – Its kind, e.g. SqlPlugin.

  • name – Its metadata.name.

  • status – One of RepositoryApplyManifestStatus.

  • message – Why it failed or was skipped, or an empty string.

  • output – What applying it printed, for a user who investigates a failure.

  • id (Unknown) – Primary key: ID

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

created_at

DateTimeField

Created at

Timestamp indicating when the model instance was created.

This field is automatically set to the current date and time when the instance is first created. It is indexed in the database for efficient querying.

Type:

Type

get_status_display(*, field=<django.db.models.CharField: status>)

Shows the label of the status. See get_FOO_display() for more information.

id: int

BigAutoField

Primary key: ID

The row’s primary key, which Django adds to every concrete model. Declared, without a value, only so that type checkers know it: Django ignores a bare annotation.

Type:

Type

kind

CharField

Kind

Type:

Type

message

TextField

Message

Type:

Type

name

CharField

Name

Type:

Type

objects = <django.db.models.Manager object>
output

TextField

Output

Type:

Type

path

CharField

Path

Type:

Type

position

PositiveIntegerField

Position

Type:

Type

repository_apply

ForeignKey to RepositoryApply

Repository apply (related name: manifests)

Type:

Type

repository_apply_id

Internal field, use repository_apply instead.

status

CharField

Status

Choices:

  • pending

  • applied

  • skipped

  • failed

Type:

Type

updated_at

DateTimeField

Updated at

Timestamp indicating when the model instance was last updated.

This field is automatically updated to the current date and time whenever the instance is saved. It is indexed in the database for efficient querying.

Type:

Type

class smarter.apps.account.models.repository_apply.RepositoryApplyManifestStatus(*values)[source]

Bases: TextChoices

What became of one manifest of a batch apply.

APPLIED = 'applied'
FAILED = 'failed'
PENDING = 'pending'
SKIPPED = 'skipped'
class smarter.apps.account.models.repository_apply.RepositoryApplyStatus(*values)[source]

Bases: TextChoices

Where a batch apply is in its life.

APPLYING = 'applying'
CLONING = 'cloning'
FAILED = 'failed'
FINISHED = 'finished'
QUEUED = 'queued'