Skip to content

Commit

Permalink
Add build status for DELETED and ARCHIVED
Browse files Browse the repository at this point in the history
  • Loading branch information
soapy1 committed Jan 15, 2025
1 parent 42a8aae commit 4d4f939
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions conda-store-server/conda_store_server/_internal/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class BuildStatus(enum.Enum):
COMPLETED = "COMPLETED"
FAILED = "FAILED"
CANCELED = "CANCELED"
DELETED = "DELETED"
ARCHIVED = "ARCHIVED"


class BuildArtifact(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ def task_delete_build(self, build_id):

# Updates build size and marks build as deleted
build.deleted_on = datetime.datetime.utcnow()
build.status = schema.BuildStatus.DELETED
build.size = 0

db.commit()
Expand Down
1 change: 1 addition & 0 deletions conda-store-server/conda_store_server/conda_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ def delete_build(self, db: Session, build_id: int):
raise CondaStoreError("cannot delete build since not finished building")

build.deleted_on = datetime.datetime.utcnow()
build.status = schema.BuildStatus.DELETED
db.commit()

self.celery_app
Expand Down
17 changes: 17 additions & 0 deletions conda-store-server/tests/test_conda_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,20 @@ def test_conda_store_get_lock_plugin_does_not_exist(conda_store):
conda_store.config.lock_backend = lock_plugin_setting
with pytest.raises(CondaStorePluginNotFoundError):
conda_store.lock_plugin()


def test_conda_store_delete_build(seed_conda_store, conda_store):
"""Ensure conda store will delete a build and update all appropriate metadata
"""
db = seed_conda_store

# build 4 is completed, we'll use that test test deletion
build = api.get_build(db, build_id=4)
assert build.deleted_on == None
assert build.status == schema.BuildStatus.COMPLETED

conda_store.delete_build(db, 4)

build = api.get_build(db, build_id=4)
assert build.deleted_on is not None
assert build.status == schema.BuildStatus.DELETED

0 comments on commit 4d4f939

Please sign in to comment.