From 00719ae6222408bdb61018aff15e114a41080654 Mon Sep 17 00:00:00 2001 From: Lloyd Dakin Date: Wed, 13 Nov 2024 13:41:38 -0800 Subject: [PATCH] removed test operations from datalab --- .../datalab_session/data_operations/error.py | 53 ------------------- .../datalab_session/data_operations/long.py | 47 ---------------- .../datalab_session/data_operations/noop.py | 45 ---------------- 3 files changed, 145 deletions(-) delete mode 100644 datalab/datalab_session/data_operations/error.py delete mode 100644 datalab/datalab_session/data_operations/long.py delete mode 100644 datalab/datalab_session/data_operations/noop.py diff --git a/datalab/datalab_session/data_operations/error.py b/datalab/datalab_session/data_operations/error.py deleted file mode 100644 index a8f3172..0000000 --- a/datalab/datalab_session/data_operations/error.py +++ /dev/null @@ -1,53 +0,0 @@ -import builtins -import logging - -from requests.exceptions import RequestException -from datalab.datalab_session.data_operations.data_operation import BaseDataOperation -from datalab.datalab_session.exceptions import ClientAlertException - -log=logging.getLogger() -log.setLevel(logging.INFO) - -class ErrorOperation(BaseDataOperation): - @staticmethod - def name(): - return 'Error' - - @staticmethod - def description(): - return """The Error will raise an error in the dramatiq worker!""" - - @staticmethod - def wizard_description(): - return { - 'name': 'Error', - 'description': 'The Error will raise an error in the dramatiq worker!', - 'category': 'test', - 'inputs': { - 'input_files': { - 'name': 'Input Files', - 'description': 'The input files to operate on', - 'type': 'file', - 'minimum': 1, - 'maximum': 999 - }, - 'Error Type': { - 'name': 'Error Type', - 'description': 'The type of error to raise, should be a python error type', - 'type': 'text', - }, - 'Error Message': { - 'name': 'Error Message', - 'description': 'The message to include with the error', - 'type': 'text', - } - } - } - - def operate(self): - error_type_name = self.input_data.get('Error Type') - error_type = getattr(builtins, error_type_name, None) - if not error_type or not issubclass(error_type, BaseException): - raise ClientAlertException(f'Unknown Error Type: {error_type_name}') - else: - raise error_type(self.input_data.get('Error Message', 'No Error Message, Default Error Message!')) diff --git a/datalab/datalab_session/data_operations/long.py b/datalab/datalab_session/data_operations/long.py deleted file mode 100644 index 909bbdc..0000000 --- a/datalab/datalab_session/data_operations/long.py +++ /dev/null @@ -1,47 +0,0 @@ -from datalab.datalab_session.data_operations.data_operation import BaseDataOperation -from time import sleep -from math import ceil - -class LongOperation(BaseDataOperation): - @staticmethod - def name(): - return 'Long' - - @staticmethod - def description(): - return """The Long operation just sleeps and then returns your input images as output without doing anything""" - - @staticmethod - def wizard_description(): - return { - 'name': LongOperation.name(), - 'description': LongOperation.description(), - 'category': 'test', - 'inputs': { - 'input_files': { - 'name': 'Input Files', - 'description': 'The input files to operate on', - 'type': 'file', - 'minimum': 1, - 'maximum': 999 - }, - 'duration': { - 'name': 'Duration', - 'description': 'The duration of the operation', - 'type': 'number', - 'minimum': 0, - 'maximum': 99999.0, - 'default': 60.0 - }, - } - } - - def operate(self): - num_files = max(len(self.input_data.get('input_files', [])), 1) - per_image_timeout = ceil(float(self.input_data.get('duration', 60.0)) / num_files) - for i, file in enumerate(self.input_data.get('input_files', [])): - print(f"Processing long operation on file {file.get('basename', 'No basename found')}") - sleep(per_image_timeout) - self.set_operation_progress((i+1) / num_files) - # Done "processing" the files so set the output which sets the final status - self.set_output(self.input_data.get('input_files', [])) diff --git a/datalab/datalab_session/data_operations/noop.py b/datalab/datalab_session/data_operations/noop.py deleted file mode 100644 index a5806cd..0000000 --- a/datalab/datalab_session/data_operations/noop.py +++ /dev/null @@ -1,45 +0,0 @@ -from datalab.datalab_session.data_operations.data_operation import BaseDataOperation - - -class NoOperation(BaseDataOperation): - @staticmethod - def name(): - return 'NoOp' - - @staticmethod - def description(): - return """The NoOp just returns your input images as output without doing anything!""" - - @staticmethod - def wizard_description(): - return { - 'name': 'NoOp', - 'description': 'The NoOp operation returns your input images as output.\n\nIt does nothing!!!', - 'category': 'test', - 'inputs': { - 'input_files': { - 'name': 'Input Files', - 'description': 'The input files to operate on', - 'type': 'file', - 'minimum': 1, - 'maximum': 999 - }, - 'scalar_parameter_1': { - 'name': 'Scalar Parameter 1', - 'description': 'This scalar parameter controls nothing', - 'type': 'number', - 'minimum': 0, - 'maximum': 25.0, - 'default': 5.0 - }, - 'string_parameter': { - 'name': 'String Parameter', - 'description': 'This is a string parameter', - 'type': 'text' - } - } - } - - def operate(self): - print("No-op triggered!") - self.set_output(self.input_data.get('input_files', []))