ethyca-fides 2.64.1b1__py2.py3-none-any.whl → 2.64.1rc0__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ethyca_fides-2.64.1b1.dist-info → ethyca_fides-2.64.1rc0.dist-info}/METADATA +2 -2
- {ethyca_fides-2.64.1b1.dist-info → ethyca_fides-2.64.1rc0.dist-info}/RECORD +104 -107
- fides/_version.py +3 -3
- fides/api/db/base.py +0 -4
- fides/api/models/manual_tasks/__init__.py +1 -7
- fides/api/models/manual_tasks/manual_task.py +3 -19
- fides/api/models/manual_tasks/manual_task_config.py +6 -39
- fides/api/models/manual_tasks/manual_task_log.py +7 -20
- fides/api/schemas/manual_tasks/manual_task_schemas.py +0 -42
- fides/api/schemas/manual_tasks/manual_task_status.py +46 -107
- fides/service/manual_tasks/manual_task_config_service.py +5 -17
- fides/service/manual_tasks/manual_task_service.py +10 -66
- fides/ui-build/static/admin/404.html +1 -1
- fides/ui-build/static/admin/_next/static/chunks/{6662-cb11881dcaabe5e2.js → 6662-6a6b90fc8f11558f.js} +1 -1
- fides/ui-build/static/admin/_next/static/{zBkPKRGECPjwEx0G7BvHe → hCJxUAFBWobWrps6RkP0K}/_buildManifest.js +1 -1
- fides/ui-build/static/admin/add-systems/manual.html +1 -1
- fides/ui-build/static/admin/add-systems/multiple.html +1 -1
- fides/ui-build/static/admin/add-systems.html +1 -1
- fides/ui-build/static/admin/consent/configure/add-vendors.html +1 -1
- fides/ui-build/static/admin/consent/configure.html +1 -1
- fides/ui-build/static/admin/consent/privacy-experience/[id].html +1 -1
- fides/ui-build/static/admin/consent/privacy-experience/new.html +1 -1
- fides/ui-build/static/admin/consent/privacy-experience.html +1 -1
- fides/ui-build/static/admin/consent/privacy-notices/[id].html +1 -1
- fides/ui-build/static/admin/consent/privacy-notices/new.html +1 -1
- fides/ui-build/static/admin/consent/privacy-notices.html +1 -1
- fides/ui-build/static/admin/consent/properties.html +1 -1
- fides/ui-build/static/admin/consent/reporting.html +1 -1
- fides/ui-build/static/admin/consent.html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/projects/[projectUrn]/[resourceUrn].html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/projects/[projectUrn].html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/projects.html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/resources/[resourceUrn].html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/resources.html +1 -1
- fides/ui-build/static/admin/data-catalog.html +1 -1
- fides/ui-build/static/admin/data-discovery/action-center/[monitorId]/[systemId].html +1 -1
- fides/ui-build/static/admin/data-discovery/action-center/[monitorId].html +1 -1
- fides/ui-build/static/admin/data-discovery/action-center.html +1 -1
- fides/ui-build/static/admin/data-discovery/activity.html +1 -1
- fides/ui-build/static/admin/data-discovery/detection/[resourceUrn].html +1 -1
- fides/ui-build/static/admin/data-discovery/detection.html +1 -1
- fides/ui-build/static/admin/data-discovery/discovery/[resourceUrn].html +1 -1
- fides/ui-build/static/admin/data-discovery/discovery.html +1 -1
- fides/ui-build/static/admin/datamap.html +1 -1
- fides/ui-build/static/admin/dataset/[datasetId]/[collectionName]/[...subfieldNames].html +1 -1
- fides/ui-build/static/admin/dataset/[datasetId]/[collectionName].html +1 -1
- fides/ui-build/static/admin/dataset/[datasetId].html +1 -1
- fides/ui-build/static/admin/dataset/new.html +1 -1
- fides/ui-build/static/admin/dataset.html +1 -1
- fides/ui-build/static/admin/datastore-connection/[id].html +1 -1
- fides/ui-build/static/admin/datastore-connection/new.html +1 -1
- fides/ui-build/static/admin/datastore-connection.html +1 -1
- fides/ui-build/static/admin/index.html +1 -1
- fides/ui-build/static/admin/integrations/[id].html +1 -1
- fides/ui-build/static/admin/integrations.html +1 -1
- fides/ui-build/static/admin/lib/fides-headless.js +1 -1
- fides/ui-build/static/admin/lib/fides-preview.js +1 -1
- fides/ui-build/static/admin/lib/fides-tcf.js +2 -2
- fides/ui-build/static/admin/lib/fides.js +2 -2
- fides/ui-build/static/admin/login/[provider].html +1 -1
- fides/ui-build/static/admin/login.html +1 -1
- fides/ui-build/static/admin/messaging/[id].html +1 -1
- fides/ui-build/static/admin/messaging/add-template.html +1 -1
- fides/ui-build/static/admin/messaging.html +1 -1
- fides/ui-build/static/admin/poc/ant-components.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/AntForm.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/FormikAntFormItem.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/FormikControlled.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/FormikField.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/FormikSpreadField.html +1 -1
- fides/ui-build/static/admin/poc/forms.html +1 -1
- fides/ui-build/static/admin/poc/table-migration.html +1 -1
- fides/ui-build/static/admin/privacy-requests/[id].html +1 -1
- fides/ui-build/static/admin/privacy-requests/configure/messaging.html +1 -1
- fides/ui-build/static/admin/privacy-requests/configure/storage.html +1 -1
- fides/ui-build/static/admin/privacy-requests/configure.html +1 -1
- fides/ui-build/static/admin/privacy-requests.html +1 -1
- fides/ui-build/static/admin/properties/[id].html +1 -1
- fides/ui-build/static/admin/properties/add-property.html +1 -1
- fides/ui-build/static/admin/properties.html +1 -1
- fides/ui-build/static/admin/reporting/datamap.html +1 -1
- fides/ui-build/static/admin/settings/about/alpha.html +1 -1
- fides/ui-build/static/admin/settings/about.html +1 -1
- fides/ui-build/static/admin/settings/consent/[configuration_id]/[purpose_id].html +1 -1
- fides/ui-build/static/admin/settings/consent.html +1 -1
- fides/ui-build/static/admin/settings/custom-fields.html +1 -1
- fides/ui-build/static/admin/settings/domain-records.html +1 -1
- fides/ui-build/static/admin/settings/domains.html +1 -1
- fides/ui-build/static/admin/settings/email-templates.html +1 -1
- fides/ui-build/static/admin/settings/locations.html +1 -1
- fides/ui-build/static/admin/settings/organization.html +1 -1
- fides/ui-build/static/admin/settings/regulations.html +1 -1
- fides/ui-build/static/admin/systems/configure/[id]/test-datasets.html +1 -1
- fides/ui-build/static/admin/systems/configure/[id].html +1 -1
- fides/ui-build/static/admin/systems.html +1 -1
- fides/ui-build/static/admin/taxonomy.html +1 -1
- fides/ui-build/static/admin/user-management/new.html +1 -1
- fides/ui-build/static/admin/user-management/profile/[id].html +1 -1
- fides/ui-build/static/admin/user-management.html +1 -1
- fides/api/alembic/migrations/versions/6a76a1fa4f3f_add_manual_task_instance_table.py +0 -256
- fides/api/models/manual_tasks/manual_task_instance.py +0 -187
- fides/service/manual_tasks/manual_task_instance_service.py +0 -285
- {ethyca_fides-2.64.1b1.dist-info → ethyca_fides-2.64.1rc0.dist-info}/WHEEL +0 -0
- {ethyca_fides-2.64.1b1.dist-info → ethyca_fides-2.64.1rc0.dist-info}/entry_points.txt +0 -0
- {ethyca_fides-2.64.1b1.dist-info → ethyca_fides-2.64.1rc0.dist-info}/licenses/LICENSE +0 -0
- {ethyca_fides-2.64.1b1.dist-info → ethyca_fides-2.64.1rc0.dist-info}/top_level.txt +0 -0
- /fides/ui-build/static/admin/_next/static/{zBkPKRGECPjwEx0G7BvHe → hCJxUAFBWobWrps6RkP0K}/_ssgManifest.js +0 -0
@@ -5,15 +5,6 @@ from typing import Annotated, Any, Optional
|
|
5
5
|
from pydantic import ConfigDict, Field
|
6
6
|
|
7
7
|
from fides.api.schemas.base_class import FidesSchema
|
8
|
-
from fides.api.schemas.manual_tasks.manual_task_status import StatusType
|
9
|
-
|
10
|
-
|
11
|
-
class ManualTaskExecutionTiming(str, Enum):
|
12
|
-
"""Enum for when a manual task should be executed in the privacy request DAG."""
|
13
|
-
|
14
|
-
pre_execution = "pre_execution" # Execute before the main DAG
|
15
|
-
post_execution = "post_execution" # Execute after the main DAG
|
16
|
-
parallel = "parallel" # Execute in parallel with the main DAG
|
17
8
|
|
18
9
|
|
19
10
|
class ManualTaskType(str, Enum):
|
@@ -32,13 +23,6 @@ class ManualTaskParentEntityType(str, Enum):
|
|
32
23
|
# Add more parent entity types as needed
|
33
24
|
|
34
25
|
|
35
|
-
class ManualTaskEntityType(str, Enum):
|
36
|
-
"""Enum for manual task entity types."""
|
37
|
-
|
38
|
-
privacy_request = "privacy_request"
|
39
|
-
# Add more entity types as needed
|
40
|
-
|
41
|
-
|
42
26
|
class ManualTaskReferenceType(str, Enum):
|
43
27
|
"""Enum for manual task reference types."""
|
44
28
|
|
@@ -62,32 +46,6 @@ class ManualTaskLogStatus(str, Enum):
|
|
62
46
|
awaiting_input = "awaiting_input"
|
63
47
|
|
64
48
|
|
65
|
-
class ManualTaskResponse(FidesSchema):
|
66
|
-
"""Schema for manual task response."""
|
67
|
-
|
68
|
-
model_config = ConfigDict(extra="forbid")
|
69
|
-
|
70
|
-
id: Annotated[str, Field(..., description="Task ID")]
|
71
|
-
parent_entity_id: Annotated[str, Field(..., description="Parent entity ID")]
|
72
|
-
parent_entity_type: Annotated[
|
73
|
-
ManualTaskParentEntityType, Field(..., description="Parent entity type")
|
74
|
-
]
|
75
|
-
status: Annotated[StatusType, Field(..., description="Task status")]
|
76
|
-
created_at: Annotated[datetime, Field(..., description="Creation timestamp")]
|
77
|
-
updated_at: Annotated[datetime, Field(..., description="Last update timestamp")]
|
78
|
-
|
79
|
-
|
80
|
-
class ManualTaskCreate(FidesSchema):
|
81
|
-
"""Schema for creating a manual task."""
|
82
|
-
|
83
|
-
model_config = ConfigDict(extra="forbid")
|
84
|
-
|
85
|
-
parent_entity_id: Annotated[str, Field(..., description="Parent entity ID")]
|
86
|
-
parent_entity_type: Annotated[
|
87
|
-
ManualTaskParentEntityType, Field(..., description="Parent entity type")
|
88
|
-
]
|
89
|
-
|
90
|
-
|
91
49
|
class ManualTaskLogCreate(FidesSchema):
|
92
50
|
"""Schema for creating a manual task log entry."""
|
93
51
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from datetime import datetime, timezone
|
2
2
|
from enum import Enum as EnumType
|
3
|
-
from typing import Optional
|
3
|
+
from typing import Optional
|
4
4
|
|
5
5
|
from sqlalchemy.orm import Session
|
6
6
|
|
@@ -23,133 +23,61 @@ class StatusType(str, EnumType):
|
|
23
23
|
|
24
24
|
@classmethod
|
25
25
|
def get_valid_transitions(cls, current_status: "StatusType") -> list["StatusType"]:
|
26
|
-
"""Get valid transitions from the current status.
|
27
|
-
transitions = {
|
28
|
-
cls.pending: [cls.in_progress, cls.failed, cls.completed],
|
29
|
-
cls.in_progress: [cls.completed, cls.failed],
|
30
|
-
cls.completed: [],
|
31
|
-
cls.failed: [cls.pending, cls.in_progress],
|
32
|
-
}
|
33
|
-
return transitions.get(current_status, [])
|
34
|
-
|
35
|
-
|
36
|
-
class StatusTransitionProtocol(Protocol):
|
37
|
-
"""Protocol for objects that support status transitions.
|
38
|
-
|
39
|
-
This protocol defines the interface that any object supporting status transitions
|
40
|
-
must implement. It includes both the required attributes and methods.
|
41
|
-
|
42
|
-
Example:
|
43
|
-
```python
|
44
|
-
# Any class that implements this protocol can be used interchangeably
|
45
|
-
def process_status_update(obj: StatusTransitionProtocol, db: Session) -> None:
|
46
|
-
if obj.is_pending:
|
47
|
-
obj.start_progress(db)
|
48
|
-
elif obj.is_in_progress:
|
49
|
-
obj.mark_completed(db, user_id="user123")
|
50
|
-
|
51
|
-
# This works with ManualTaskInstance or any other class implementing the protocol
|
52
|
-
instance = ManualTaskInstance(...)
|
53
|
-
process_status_update(instance, db)
|
54
|
-
```
|
55
|
-
"""
|
26
|
+
"""Get valid transitions from the current status.
|
56
27
|
|
57
|
-
|
58
|
-
|
59
|
-
completed_at: Optional[datetime] # Can be None when resetting to pending
|
60
|
-
completed_by_id: Optional[str] # Can be None when resetting to pending
|
28
|
+
Args:
|
29
|
+
current_status: The current status
|
61
30
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
def mark_failed(self, db: Session) -> None:
|
75
|
-
"""Mark as failed."""
|
76
|
-
... # pylint: disable=unnecessary-ellipsis
|
77
|
-
|
78
|
-
def start_progress(self, db: Session) -> None:
|
79
|
-
"""Mark as in progress."""
|
80
|
-
... # pylint: disable=unnecessary-ellipsis
|
81
|
-
|
82
|
-
def reset_to_pending(self, db: Session) -> None:
|
83
|
-
"""Reset to pending status."""
|
84
|
-
... # pylint: disable=unnecessary-ellipsis
|
85
|
-
|
86
|
-
@property
|
87
|
-
def is_completed(self) -> bool:
|
88
|
-
"""Check if completed."""
|
89
|
-
... # pylint: disable=unnecessary-ellipsis
|
90
|
-
|
91
|
-
@property
|
92
|
-
def is_failed(self) -> bool:
|
93
|
-
"""Check if failed."""
|
94
|
-
... # pylint: disable=unnecessary-ellipsis
|
95
|
-
|
96
|
-
@property
|
97
|
-
def is_in_progress(self) -> bool:
|
98
|
-
"""Check if in progress."""
|
99
|
-
... # pylint: disable=unnecessary-ellipsis
|
100
|
-
|
101
|
-
@property
|
102
|
-
def is_pending(self) -> bool:
|
103
|
-
"""Check if pending."""
|
104
|
-
... # pylint: disable=unnecessary-ellipsis
|
105
|
-
|
106
|
-
|
107
|
-
def validate_status_transition_object(obj: StatusTransitionProtocol) -> bool:
|
108
|
-
"""Validate that an object properly implements the StatusTransitionProtocol.
|
109
|
-
|
110
|
-
This function demonstrates how the Protocol can be used for runtime validation
|
111
|
-
and type checking.
|
112
|
-
"""
|
113
|
-
required_attrs = ["status", "completed_at", "completed_by_id"]
|
114
|
-
required_methods = [
|
115
|
-
"update_status",
|
116
|
-
"mark_completed",
|
117
|
-
"mark_failed",
|
118
|
-
"start_progress",
|
119
|
-
"reset_to_pending",
|
120
|
-
]
|
121
|
-
required_properties = ["is_completed", "is_failed", "is_in_progress", "is_pending"]
|
122
|
-
|
123
|
-
# Check all required elements
|
124
|
-
all_required = required_attrs + required_methods + required_properties
|
125
|
-
return all(hasattr(obj, attr) for attr in all_required) and all(
|
126
|
-
callable(getattr(obj, method)) for method in required_methods
|
127
|
-
)
|
31
|
+
Returns:
|
32
|
+
list[StatusType]: List of valid transitions
|
33
|
+
"""
|
34
|
+
if current_status == cls.pending:
|
35
|
+
return [cls.in_progress, cls.failed, cls.completed]
|
36
|
+
if current_status == cls.in_progress:
|
37
|
+
return [cls.completed, cls.failed]
|
38
|
+
if current_status == cls.completed:
|
39
|
+
return []
|
40
|
+
if current_status == cls.failed:
|
41
|
+
return [cls.pending, cls.in_progress]
|
42
|
+
return []
|
128
43
|
|
129
44
|
|
130
45
|
class StatusTransitionMixin:
|
131
46
|
"""Mixin for handling status transitions.
|
132
47
|
|
133
48
|
This mixin provides methods for managing status transitions and completion tracking.
|
134
|
-
It
|
49
|
+
It can be used by any model that needs status management.
|
135
50
|
"""
|
136
51
|
|
137
|
-
#
|
52
|
+
# These should be overridden by the implementing class
|
138
53
|
status: StatusType
|
139
54
|
completed_at: Optional[datetime]
|
140
55
|
completed_by_id: Optional[str]
|
141
56
|
|
142
57
|
def _get_valid_transitions(self) -> list[StatusType]:
|
143
|
-
"""Get valid transitions from the current status.
|
58
|
+
"""Get valid transitions from the current status.
|
59
|
+
|
60
|
+
Returns:
|
61
|
+
list[StatusType]: List of valid transitions
|
62
|
+
"""
|
144
63
|
return StatusType.get_valid_transitions(self.status)
|
145
64
|
|
146
65
|
def _validate_status_transition(self, new_status: StatusType) -> None:
|
147
|
-
"""Validate that a status transition is allowed.
|
66
|
+
"""Validate that a status transition is allowed.
|
67
|
+
|
68
|
+
Args:
|
69
|
+
new_status: The new status to transition to
|
70
|
+
|
71
|
+
Raises:
|
72
|
+
StatusTransitionNotAllowed: If the transition is not allowed
|
73
|
+
"""
|
74
|
+
# Don't allow transitions to the same status
|
148
75
|
if new_status == self.status:
|
149
76
|
raise StatusTransitionNotAllowed(
|
150
77
|
f"Invalid status transition: already in status {new_status}"
|
151
78
|
)
|
152
79
|
|
80
|
+
# Get valid transitions for current status
|
153
81
|
valid_transitions = self._get_valid_transitions()
|
154
82
|
if new_status not in valid_transitions:
|
155
83
|
raise StatusTransitionNotAllowed(
|
@@ -160,7 +88,13 @@ class StatusTransitionMixin:
|
|
160
88
|
def update_status(
|
161
89
|
self, db: Session, new_status: StatusType, user_id: Optional[str] = None
|
162
90
|
) -> None:
|
163
|
-
"""Update the status with validation and completion handling.
|
91
|
+
"""Update the status with validation and completion handling.
|
92
|
+
|
93
|
+
Args:
|
94
|
+
db: Database session
|
95
|
+
new_status: New status to set
|
96
|
+
user_id: Optional user ID who is making the change
|
97
|
+
"""
|
164
98
|
self._validate_status_transition(new_status)
|
165
99
|
|
166
100
|
if new_status == StatusType.completed:
|
@@ -176,7 +110,12 @@ class StatusTransitionMixin:
|
|
176
110
|
db.commit()
|
177
111
|
|
178
112
|
def mark_completed(self, db: Session, user_id: str) -> None:
|
179
|
-
"""Mark as completed.
|
113
|
+
"""Mark as completed.
|
114
|
+
|
115
|
+
Args:
|
116
|
+
db: Database session
|
117
|
+
user_id: user ID who completed the task
|
118
|
+
"""
|
180
119
|
self.update_status(db, StatusType.completed, user_id)
|
181
120
|
|
182
121
|
def mark_failed(self, db: Session) -> None:
|
@@ -15,14 +15,6 @@ from fides.api.schemas.manual_tasks.manual_task_config import (
|
|
15
15
|
from fides.service.manual_tasks.utils import validate_fields, with_task_logging
|
16
16
|
|
17
17
|
|
18
|
-
class ManualTaskConfigError(Exception):
|
19
|
-
"""Exception raised when a manual task config error occurs."""
|
20
|
-
|
21
|
-
def __init__(self, message: str):
|
22
|
-
self.message = message
|
23
|
-
super().__init__(self.message)
|
24
|
-
|
25
|
-
|
26
18
|
class ManualTaskConfigService:
|
27
19
|
def __init__(self, db: Session):
|
28
20
|
self.db = db
|
@@ -59,8 +51,8 @@ class ManualTaskConfigService:
|
|
59
51
|
"""
|
60
52
|
try:
|
61
53
|
ManualTaskConfigurationType(config_type)
|
62
|
-
except
|
63
|
-
raise
|
54
|
+
except ValueError:
|
55
|
+
raise ValueError(f"Invalid config type: {config_type}")
|
64
56
|
|
65
57
|
# Set all existing versions to non-current
|
66
58
|
if is_current:
|
@@ -104,11 +96,7 @@ class ManualTaskConfigService:
|
|
104
96
|
modified_keys = set(fields_to_remove or [])
|
105
97
|
|
106
98
|
if field_updates:
|
107
|
-
|
108
|
-
validate_fields(field_updates, is_submission=False)
|
109
|
-
except ValueError as e:
|
110
|
-
raise ManualTaskConfigError(f"Invalid field updates: {e}") from e
|
111
|
-
|
99
|
+
validate_fields(field_updates, is_submission=False)
|
112
100
|
fields_to_create = [
|
113
101
|
{
|
114
102
|
"task_id": config.task_id,
|
@@ -179,7 +167,7 @@ class ManualTaskConfigService:
|
|
179
167
|
)
|
180
168
|
|
181
169
|
if not config:
|
182
|
-
raise
|
170
|
+
raise ValueError(
|
183
171
|
f"No current config found for task {task.id} and type {config_type}"
|
184
172
|
)
|
185
173
|
return config
|
@@ -367,7 +355,7 @@ class ManualTaskConfigService:
|
|
367
355
|
"""
|
368
356
|
config = self.db.query(ManualTaskConfig).filter_by(id=config_id).first()
|
369
357
|
if not config:
|
370
|
-
raise
|
358
|
+
raise ValueError(f"Config with ID {config_id} not found")
|
371
359
|
|
372
360
|
log_data = self._create_log_data(
|
373
361
|
task.id,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import Any, Optional, cast
|
2
2
|
|
3
3
|
from loguru import logger
|
4
4
|
from sqlalchemy import select
|
@@ -15,31 +15,13 @@ from fides.api.schemas.manual_tasks.manual_task_schemas import (
|
|
15
15
|
from fides.service.manual_tasks.manual_task_config_service import (
|
16
16
|
ManualTaskConfigService,
|
17
17
|
)
|
18
|
-
from fides.service.manual_tasks.manual_task_instance_service import (
|
19
|
-
ManualTaskInstanceService,
|
20
|
-
)
|
21
18
|
from fides.service.manual_tasks.utils import with_task_logging
|
22
19
|
|
23
|
-
if TYPE_CHECKING:
|
24
|
-
from fides.api.models.manual_tasks.manual_task_instance import (
|
25
|
-
ManualTaskInstance,
|
26
|
-
ManualTaskSubmission,
|
27
|
-
)
|
28
|
-
|
29
|
-
|
30
|
-
class ManualTaskError(Exception):
|
31
|
-
"""Exception raised when a manual task error occurs."""
|
32
|
-
|
33
|
-
def __init__(self, message: str):
|
34
|
-
self.message = message
|
35
|
-
super().__init__(self.message)
|
36
|
-
|
37
20
|
|
38
21
|
class ManualTaskService:
|
39
22
|
def __init__(self, db: Session):
|
40
23
|
self.db = db
|
41
24
|
self.config_service = ManualTaskConfigService(db)
|
42
|
-
self.instance_service = ManualTaskInstanceService(db)
|
43
25
|
|
44
26
|
def get_task(
|
45
27
|
self,
|
@@ -64,7 +46,7 @@ class ManualTaskService:
|
|
64
46
|
"""
|
65
47
|
if not any([task_id, parent_entity_id, parent_entity_type, task_type]):
|
66
48
|
logger.debug("No filters provided to get_task")
|
67
|
-
raise
|
49
|
+
raise ValueError("No filters provided to get_task")
|
68
50
|
|
69
51
|
# Build filter conditions and a human-readable description
|
70
52
|
filters = []
|
@@ -90,7 +72,7 @@ class ManualTaskService:
|
|
90
72
|
task = self.db.execute(stmt).scalar_one_or_none()
|
91
73
|
if task is None:
|
92
74
|
logger.debug(f"No task found with filters: {filter_desc}")
|
93
|
-
raise
|
75
|
+
raise ValueError(f"No task found with filters: {filter_desc}")
|
94
76
|
return task
|
95
77
|
|
96
78
|
@with_task_logging("Provided user IDs verified")
|
@@ -109,7 +91,7 @@ class ManualTaskService:
|
|
109
91
|
None
|
110
92
|
"""
|
111
93
|
if len(non_existent_user_ids) > 0:
|
112
|
-
raise
|
94
|
+
raise ValueError(
|
113
95
|
f"User(s) {sorted(list(non_existent_user_ids))} do not exist"
|
114
96
|
)
|
115
97
|
|
@@ -146,11 +128,11 @@ class ManualTaskService:
|
|
146
128
|
error_key: Key to use for error details
|
147
129
|
|
148
130
|
Raises:
|
149
|
-
|
131
|
+
ValueError: If no successful operations and users don't exist
|
150
132
|
"""
|
151
133
|
try:
|
152
134
|
self._non_existent_users(non_existent_users, task_id=task_id)
|
153
|
-
except
|
135
|
+
except ValueError as e:
|
154
136
|
details[error_key] = sorted(non_existent_users)
|
155
137
|
if success_count == 0:
|
156
138
|
raise e
|
@@ -190,7 +172,7 @@ class ManualTaskService:
|
|
190
172
|
tuple: (processed_users, log_data)
|
191
173
|
"""
|
192
174
|
if not (user_ids := list(set(user_ids))):
|
193
|
-
raise
|
175
|
+
raise ValueError(f"User ID is required for {operation_type}ment")
|
194
176
|
|
195
177
|
existing_users = set(
|
196
178
|
u.id
|
@@ -206,7 +188,7 @@ class ManualTaskService:
|
|
206
188
|
if non_existing := list(set(user_ids) - existing_users):
|
207
189
|
try:
|
208
190
|
self._non_existent_users(non_existing, task_id=task_id)
|
209
|
-
except
|
191
|
+
except ValueError as e:
|
210
192
|
details[f"user_ids_not_{operation_type}ed"] = sorted(non_existing)
|
211
193
|
if not processed_users:
|
212
194
|
raise e
|
@@ -299,8 +281,8 @@ class ManualTaskService:
|
|
299
281
|
config: The config to delete
|
300
282
|
task_id: The task ID
|
301
283
|
Raises:
|
302
|
-
|
303
|
-
|
284
|
+
ValueError: If there are active instances using this configuration
|
285
|
+
ValueError: If the task does not exist
|
304
286
|
|
305
287
|
Returns:
|
306
288
|
dict[str, Any]: The log details - intercepted by the `with_task_logging` decorator.
|
@@ -310,41 +292,3 @@ class ManualTaskService:
|
|
310
292
|
# Delete the configuration
|
311
293
|
config_id = config.id
|
312
294
|
self.config_service.delete_config(task, config_id)
|
313
|
-
|
314
|
-
def create_instance(
|
315
|
-
self, task_id: str, config_id: str, entity_id: str, entity_type: str
|
316
|
-
) -> "ManualTaskInstance":
|
317
|
-
"""Create a new instance for a task.
|
318
|
-
|
319
|
-
Args:
|
320
|
-
task_id: The task ID
|
321
|
-
config_id: The config ID
|
322
|
-
entity_id: The entity ID
|
323
|
-
entity_type: The entity type
|
324
|
-
|
325
|
-
Returns:
|
326
|
-
ManualTaskInstance: The new instance
|
327
|
-
"""
|
328
|
-
self.get_task(task_id=task_id)
|
329
|
-
instance = self.instance_service.create_instance(
|
330
|
-
task_id, config_id, entity_id, entity_type
|
331
|
-
)
|
332
|
-
return cast("ManualTaskInstance", instance)
|
333
|
-
|
334
|
-
def create_submission(
|
335
|
-
self, instance_id: str, field_id: str, data: dict[str, Any]
|
336
|
-
) -> "ManualTaskSubmission":
|
337
|
-
"""Create a new submission for a task.
|
338
|
-
|
339
|
-
Args:
|
340
|
-
instance_id: The instance ID
|
341
|
-
field_id: The field ID
|
342
|
-
data: The data for the submission
|
343
|
-
|
344
|
-
Returns:
|
345
|
-
ManualTaskSubmission: The new submission
|
346
|
-
"""
|
347
|
-
submission = self.instance_service.create_submission(
|
348
|
-
instance_id, field_id, data
|
349
|
-
)
|
350
|
-
return cast("ManualTaskSubmission", submission)
|
@@ -1 +1 @@
|
|
1
|
-
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link data-next-font="" rel="preconnect" href="/" crossorigin="anonymous"/><link rel="preload" href="/_next/static/css/c693338e3bc8dcc6.css" as="style"/><link rel="stylesheet" href="/_next/static/css/c693338e3bc8dcc6.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-0a61b5bd21a41fe6.js" defer=""></script><script src="/_next/static/chunks/framework-c92fc3344e6fd165.js" defer=""></script><script src="/_next/static/chunks/main-090643377c8254e6.js" defer=""></script><script src="/_next/static/chunks/pages/_app-8ec6e466f3373ac0.js" defer=""></script><script src="/_next/static/chunks/pages/404-ac2f0844e5c4b4cd.js" defer=""></script><script src="/_next/static/
|
1
|
+
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link data-next-font="" rel="preconnect" href="/" crossorigin="anonymous"/><link rel="preload" href="/_next/static/css/c693338e3bc8dcc6.css" as="style"/><link rel="stylesheet" href="/_next/static/css/c693338e3bc8dcc6.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-0a61b5bd21a41fe6.js" defer=""></script><script src="/_next/static/chunks/framework-c92fc3344e6fd165.js" defer=""></script><script src="/_next/static/chunks/main-090643377c8254e6.js" defer=""></script><script src="/_next/static/chunks/pages/_app-8ec6e466f3373ac0.js" defer=""></script><script src="/_next/static/chunks/pages/404-ac2f0844e5c4b4cd.js" defer=""></script><script src="/_next/static/hCJxUAFBWobWrps6RkP0K/_buildManifest.js" defer=""></script><script src="/_next/static/hCJxUAFBWobWrps6RkP0K/_ssgManifest.js" defer=""></script><style>.data-ant-cssinjs-cache-path{content:"";}</style></head><body><div id="__next"><div style="height:100%;display:flex"></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{}},"page":"/404","query":{},"buildId":"hCJxUAFBWobWrps6RkP0K","nextExport":true,"autoExport":true,"isFallback":false,"scriptLoader":[]}</script></body></html>
|