diff --git a/arkindex_worker/worker/training.py b/arkindex_worker/worker/training.py index 50e8159e674bc32d98576a16aeed1709f8681bde..29bd7d696dcc12156884e03032860b6bdf2e2306 100644 --- a/arkindex_worker/worker/training.py +++ b/arkindex_worker/worker/training.py @@ -102,12 +102,12 @@ def build_clean_payload(**kwargs): def skip_if_read_only(func): """ - Return shortly in case the read_only attribute is evaluated to True + Return shortly in case the is_read_only property is evaluated to True """ @functools.wraps(func) def wrapper(self, *args, **kwargs): - if getattr(self, "read_only", False): + if getattr(self, "is_read_only", False): logger.warning( "Cannot perform this operation as the worker is in read-only mode" ) diff --git a/tests/test_elements_worker/test_training.py b/tests/test_elements_worker/test_training.py index 516c52359d129ff4eaffa81b4a3e0b1be326f6c1..1a6a18913dca80796b15275c33079958afc64fd9 100644 --- a/tests/test_elements_worker/test_training.py +++ b/tests/test_elements_worker/test_training.py @@ -101,7 +101,10 @@ def test_handle_s3_uploading_errors(mock_training_worker, model_file_dir): ) def test_training_mixin_read_only(mock_training_worker, method, caplog): """All operations related to models versions returns early if the worker is configured as read only""" - mock_training_worker.read_only = True + # Set worker in read_only mode + mock_training_worker.worker_run_id = None + assert mock_training_worker.is_read_only + assert mock_training_worker.model_version is None getattr(mock_training_worker, method)() assert mock_training_worker.model_version is None