Skip to content
Snippets Groups Projects
Verified Commit c80438e2 authored by Yoann Schneider's avatar Yoann Schneider :tennis:
Browse files

nits and earlier raising if model dir does not exist

parent bf73055f
No related branches found
No related tags found
1 merge request!217Find local model directory method
Pipeline #79614 passed
......@@ -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),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment