|
13 | 13 | from app.api.dependencies import get_pipeline_metrics_service, get_pipeline_service, get_system_service |
14 | 14 | from app.api.schemas import PipelineMetricsView, PipelineView |
15 | 15 | from app.api.validators import ProjectID |
16 | | -from app.models import DataCollectionPolicyAdapter, PipelineStatus |
| 16 | +from app.models import DataCollectionConfig, DataCollectionPolicyAdapter, PipelineStatus |
17 | 17 | from app.services import PipelineMetricsService, PipelineService, ResourceNotFoundError, SystemService |
18 | 18 |
|
19 | 19 | router = APIRouter(prefix="/api/projects/{project_id}/pipeline", tags=["Pipelines"]) |
20 | 20 |
|
21 | 21 | UPDATE_PIPELINE_BODY_DESCRIPTION = """ |
22 | | -Partial pipeline configuration update. May contain any subset of fields including 'device', 'data_collection_policies', |
| 22 | +Partial pipeline configuration update. May contain any subset of fields including 'device', 'data_collection', |
23 | 23 | 'source_id', 'sink_id', or 'model_id'. Fields not included in the request will remain unchanged. |
24 | 24 | """ |
25 | 25 | UPDATE_PIPELINE_BODY_EXAMPLES = { |
|
38 | 38 | "sink_id": "c6787c06-964b-4097-8eca-238b8cf79fc9", |
39 | 39 | }, |
40 | 40 | ), |
41 | | - "enable_data_collection_policies": Example( |
42 | | - summary="Enable data collection policies", |
43 | | - description="Change data collection policies of the pipeline to fixed rate", |
| 41 | + "enable_data_collection": Example( |
| 42 | + summary="Enable data collection with max size", |
| 43 | + description="Configure data collection with max dataset size and policies", |
44 | 44 | value={ |
45 | | - "data_collection_policies": [ |
46 | | - { |
47 | | - "type": "fixed_rate", |
48 | | - "enabled": "true", |
49 | | - "rate": 0.1, |
50 | | - } |
51 | | - ] |
| 45 | + "data_collection": { |
| 46 | + "max_dataset_size": 500, |
| 47 | + "policies": [ |
| 48 | + { |
| 49 | + "type": "fixed_rate", |
| 50 | + "enabled": True, |
| 51 | + "rate": 0.1, |
| 52 | + } |
| 53 | + ], |
| 54 | + } |
52 | 55 | }, |
53 | 56 | ), |
54 | | - "clean_data_collection_policies": Example( |
55 | | - summary="Clean data collection policies", |
| 57 | + "disable_data_collection": Example( |
| 58 | + summary="Disable data collection", |
56 | 59 | description="Remove all data collection policies of the pipeline", |
57 | | - value={"data_collection_policies": []}, |
| 60 | + value={"data_collection": {"max_dataset_size": None, "policies": []}}, |
58 | 61 | ), |
59 | 62 | "change_device": Example( |
60 | 63 | summary="Change inference device", |
@@ -119,11 +122,13 @@ def update_pipeline( |
119 | 122 | ) |
120 | 123 |
|
121 | 124 | try: |
122 | | - if "data_collection_policies" in pipeline_config: |
123 | | - pipeline_config["data_collection_policies"] = [ |
124 | | - DataCollectionPolicyAdapter.validate_python(policy) |
125 | | - for policy in pipeline_config["data_collection_policies"] |
126 | | - ] |
| 125 | + if "data_collection" in pipeline_config: |
| 126 | + data_collection = pipeline_config["data_collection"] |
| 127 | + if "policies" in data_collection: |
| 128 | + data_collection["policies"] = [ |
| 129 | + DataCollectionPolicyAdapter.validate_python(policy) for policy in data_collection["policies"] |
| 130 | + ] |
| 131 | + pipeline_config["data_collection"] = DataCollectionConfig.model_validate(data_collection) |
127 | 132 | updated = pipeline_service.update_pipeline(project_id, pipeline_config) |
128 | 133 | return PipelineView.model_validate(updated, from_attributes=True) |
129 | 134 | except ResourceNotFoundError as e: |
|
0 commit comments