diff --git a/servicex/models.py b/servicex/models.py index 9d64e9cb..4da52046 100644 --- a/servicex/models.py +++ b/servicex/models.py @@ -162,6 +162,7 @@ class TransformRequest(db.Model): generated_code_cm = db.Column(db.String(128), nullable=True) status = db.Column(db.String(128), nullable=True) failure_description = db.Column(db.String(max_string_size), nullable=True) + archived = db.Column(db.Boolean, default=False) app_version = db.Column(db.String(64), nullable=True) code_gen_image = db.Column(db.String(256), nullable=True) diff --git a/servicex/resources/transformation/archive.py b/servicex/resources/transformation/archive.py new file mode 100644 index 00000000..c98b8333 --- /dev/null +++ b/servicex/resources/transformation/archive.py @@ -0,0 +1,26 @@ +from servicex.decorators import auth_required +from servicex.models import TransformRequest, db +from servicex.resources.servicex_resource import ServiceXResource + + +class ArchiveTransform(ServiceXResource): + + @auth_required + def get(self, request_id: str): + transform_req = TransformRequest.lookup(request_id) + if not transform_req: + msg = f'Transformation request not found with id: {request_id}' + self.logger.warning(msg) + return {'message': msg}, 404 + elif transform_req.incomplete: + msg = f"Transform request with id {request_id} is still in progress." + self.logger.warning(msg) + return {"message": msg}, 400 + + # todo - Cleanup Minio here + + transform_req.archived = True + transform_req.save_to_db() + db.session.commit() + + return {"message": f"Archived transformation request {request_id}"}, 200 diff --git a/servicex/routes.py b/servicex/routes.py index bec0204c..969080bd 100644 --- a/servicex/routes.py +++ b/servicex/routes.py @@ -42,13 +42,14 @@ def add_routes(api, transformer_manager, rabbit_mq_adaptor, from servicex.resources.internal.transform_status import TransformationStatusInternal from servicex.resources.internal.transformer_file_complete import TransformerFileComplete - from servicex.resources.transformation.submit import SubmitTransformationRequest - from servicex.resources.transformation.status import TransformationStatus + from servicex.resources.transformation.archive import ArchiveTransform from servicex.resources.transformation.cancel import CancelTransform + from servicex.resources.transformation.deployment import DeploymentStatus + from servicex.resources.transformation.errors import TransformErrors from servicex.resources.transformation.get_all import AllTransformationRequests from servicex.resources.transformation.get_one import TransformationRequest - from servicex.resources.transformation.errors import TransformErrors - from servicex.resources.transformation.deployment import DeploymentStatus + from servicex.resources.transformation.status import TransformationStatus + from servicex.resources.transformation.submit import SubmitTransformationRequest from servicex.resources.users.all_users import AllUsers from servicex.resources.users.token_refresh import TokenRefresh @@ -123,6 +124,7 @@ def add_routes(api, transformer_manager, rabbit_mq_adaptor, api.add_resource(TransformErrors, prefix + "/errors") api.add_resource(DeploymentStatus, prefix + "/deployment-status") api.add_resource(CancelTransform, prefix + "/cancel") + api.add_resource(ArchiveTransform, prefix + "/archive") # Internal service endpoints api.add_resource(TransformationStatusInternal,