Skip to content

Commit e5fa526

Browse files
Merge branch 'feat/apply-default-filters' of https://github.com/RolnickLab/antenna into feat/apply-default-filters
2 parents e6eb067 + b4761bb commit e5fa526

File tree

5 files changed

+75
-7
lines changed

5 files changed

+75
-7
lines changed

ami/jobs/models.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ def add_stage(self, name: str, key: str | None = None) -> JobProgressStageDetail
131131
def get_stage(self, stage_key: str) -> JobProgressStageDetail:
132132
for stage in self.stages:
133133
if stage.key == stage_key:
134-
if stage.name == stage.key:
135-
raise ValueError(f"Job stage with key '{stage_key}' has no name")
136134
return stage
137135
raise ValueError(f"Job stage with key '{stage_key}' not found in progress")
138136

@@ -211,6 +209,12 @@ def default_job_progress() -> JobProgress:
211209

212210

213211
def default_ml_job_progress() -> JobProgress:
212+
"""
213+
Default stages for an ML Job.
214+
215+
@TODO add this to the get_default_progress() method of the
216+
MLJob class, or delete it. Currently unused.
217+
"""
214218
return JobProgress(
215219
summary=JobProgressSummary(status=JobState.CREATED, progress=0),
216220
stages=[
@@ -689,8 +693,8 @@ class Job(BaseModel):
689693
finished_at = models.DateTimeField(null=True, blank=True)
690694
# @TODO can we use an Enum or Pydantic model for status?
691695
status = models.CharField(max_length=255, default=JobState.CREATED.name, choices=JobState.choices())
692-
progress: JobProgress = SchemaField(JobProgress, default=default_job_progress())
693-
logs: JobLogs = SchemaField(JobLogs, default=JobLogs())
696+
progress: JobProgress = SchemaField(JobProgress, default=default_job_progress)
697+
logs: JobLogs = SchemaField(JobLogs, default=JobLogs)
694698
params = models.JSONField(null=True, blank=True)
695699
result = models.JSONField(null=True, blank=True)
696700
task_id = models.CharField(max_length=255, null=True, blank=True)
@@ -781,7 +785,7 @@ def setup(self, save=True):
781785
"""
782786
Setup the job by creating the job stages.
783787
"""
784-
self.progress = self.progress or default_job_progress
788+
self.progress = self.progress or self.get_default_progress()
785789

786790
if self.delay:
787791
delay_stage = self.progress.add_stage("Delay")
@@ -941,7 +945,7 @@ def get_custom_user_permissions(self, user) -> list[str]:
941945
return list(custom_perms)
942946

943947
@classmethod
944-
def default_progress(cls) -> JobProgress:
948+
def get_default_progress(cls) -> JobProgress:
945949
"""Return the progress of each stage of this job as a dictionary"""
946950
return default_job_progress()
947951

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Generated by Django 4.2.10 on 2025-09-03 16:24
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("main", "0070_alter_project_feature_flags"),
9+
]
10+
11+
operations = [
12+
migrations.AlterModelOptions(
13+
name="project",
14+
options={
15+
"ordering": ["-priority", "created_at"],
16+
"permissions": [
17+
("create_identification", "Can create identifications"),
18+
("update_identification", "Can update identifications"),
19+
("delete_identification", "Can delete identifications"),
20+
("create_job", "Can create a job"),
21+
("update_job", "Can update a job"),
22+
("run_ml_job", "Can run/retry/cancel ML jobs"),
23+
("run_populate_captures_collection_job", "Can run/retry/cancel Populate Collection jobs"),
24+
("run_data_storage_sync_job", "Can run/retry/cancel Data Storage Sync jobs"),
25+
("run_data_export_job", "Can run/retry/cancel Data Export jobs"),
26+
("run_single_image_ml_job", "Can process a single capture"),
27+
("delete_job", "Can delete a job"),
28+
("create_deployment", "Can create a deployment"),
29+
("delete_deployment", "Can delete a deployment"),
30+
("update_deployment", "Can update a deployment"),
31+
("sync_deployment", "Can sync images to a deployment"),
32+
("create_sourceimagecollection", "Can create a collection"),
33+
("update_sourceimagecollection", "Can update a collection"),
34+
("delete_sourceimagecollection", "Can delete a collection"),
35+
("populate_sourceimagecollection", "Can populate a collection"),
36+
("create_sourceimage", "Can create a source image"),
37+
("update_sourceimage", "Can update a source image"),
38+
("delete_sourceimage", "Can delete a source image"),
39+
("star_sourceimage", "Can star a source image"),
40+
("create_sourceimageupload", "Can create a source image upload"),
41+
("update_sourceimageupload", "Can update a source image upload"),
42+
("delete_sourceimageupload", "Can delete a source image upload"),
43+
("create_s3storagesource", "Can create storage"),
44+
("delete_s3storagesource", "Can delete storage"),
45+
("update_s3storagesource", "Can update storage"),
46+
("test_s3storagesource", "Can test storage connection"),
47+
("create_site", "Can create a site"),
48+
("delete_site", "Can delete a site"),
49+
("update_site", "Can update a site"),
50+
("create_device", "Can create a device"),
51+
("delete_device", "Can delete a device"),
52+
("update_device", "Can update a device"),
53+
("view_private_data", "Can view private data"),
54+
("trigger_exports", "Can trigger data exports"),
55+
],
56+
},
57+
),
58+
]

ami/main/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ class Permissions:
320320
CREATE_DEPLOYMENT = "create_deployment"
321321
DELETE_DEPLOYMENT = "delete_deployment"
322322
UPDATE_DEPLOYMENT = "update_deployment"
323+
SYNC_DEPLOYMENT = "sync_deployment"
323324

324325
# Collection permissions
325326
CREATE_COLLECTION = "create_sourceimagecollection"
@@ -341,6 +342,7 @@ class Permissions:
341342
CREATE_STORAGE = "create_s3storagesource"
342343
DELETE_STORAGE = "delete_s3storagesource"
343344
UPDATE_STORAGE = "update_s3storagesource"
345+
TEST_STORAGE = "test_s3storagesource"
344346

345347
# Site permissions
346348
CREATE_SITE = "create_site"
@@ -379,6 +381,7 @@ class Meta:
379381
("create_deployment", "Can create a deployment"),
380382
("delete_deployment", "Can delete a deployment"),
381383
("update_deployment", "Can update a deployment"),
384+
("sync_deployment", "Can sync images to a deployment"),
382385
# Collection permissions
383386
("create_sourceimagecollection", "Can create a collection"),
384387
("update_sourceimagecollection", "Can update a collection"),
@@ -397,6 +400,7 @@ class Meta:
397400
("create_s3storagesource", "Can create storage"),
398401
("delete_s3storagesource", "Can delete storage"),
399402
("update_s3storagesource", "Can update storage"),
403+
("test_s3storagesource", "Can test storage connection"),
400404
# Site permissions
401405
("create_site", "Can create a site"),
402406
("delete_site", "Can delete a site"),

ami/main/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ def setUp(self) -> None:
12831283
"project_manager": {
12841284
"project": {"create": False, "update": True, "delete": True},
12851285
"collection": {"create": True, "update": True, "delete": True, "populate": True},
1286-
"storage": {"create": True, "update": True, "delete": True},
1286+
"storage": {"create": True, "update": True, "delete": True, "test": True},
12871287
"sourceimage": {"create": True, "update": True, "delete": True},
12881288
"sourceimageupload": {"create": True, "update": True, "delete": True},
12891289
"site": {"create": True, "update": True, "delete": True},

ami/users/roles.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ class ProjectManager(Role):
105105
Project.Permissions.CREATE_STORAGE,
106106
Project.Permissions.UPDATE_STORAGE,
107107
Project.Permissions.DELETE_STORAGE,
108+
Project.Permissions.TEST_STORAGE,
108109
Project.Permissions.CREATE_DEPLOYMENT,
109110
Project.Permissions.UPDATE_DEPLOYMENT,
110111
Project.Permissions.DELETE_DEPLOYMENT,
112+
Project.Permissions.SYNC_DEPLOYMENT,
111113
Project.Permissions.CREATE_SITE,
112114
Project.Permissions.UPDATE_SITE,
113115
Project.Permissions.DELETE_SITE,

0 commit comments

Comments
 (0)