diff --git a/arkindex_worker/worker/base.py b/arkindex_worker/worker/base.py index a13d1fb427a94024663d9ce6256d7957f84379d9..7e3f97769d76eb18348fb28ec95213a0db94ed73 100644 --- a/arkindex_worker/worker/base.py +++ b/arkindex_worker/worker/base.py @@ -50,8 +50,6 @@ class ModelNotFoundError(Exception): Exception raised when the path towards the model is invalid """ - pass - class BaseWorker(object): """ @@ -105,7 +103,7 @@ class BaseWorker(object): # To load models locally self.parser.add_argument( "--model-dir", - help=("The path to a local model's directory. "), + help=("The path to a local model's directory (development only)."), type=Path, ) @@ -369,19 +367,19 @@ class BaseWorker(object): # downloads the model and set it in the current task work dir return Path(self.work_dir) else: - model_path = self.config.get("model_dir", self.args.model_dir) - if model_path is None: + model_dir = self.config.get("model_dir", self.args.model_dir) + if model_dir is None: raise ModelNotFoundError( "No path to the model was provided. " "Please provide model_dir either through configuration " "or as CLI argument." ) - if Path(model_path).exists(): - return Path(model_path) - else: + model_dir = Path(model_dir) + if not model_dir.exists(): raise ModelNotFoundError( - f"The path {model_path} does not link to any directory" + f"The path {model_dir} does not link to any directory" ) + return model_dir @retry( retry=retry_if_exception(_is_500_error),