From be2354ce6bf64491f2065189c72006a36cb066b8 Mon Sep 17 00:00:00 2001 From: Stuart McAlpine Date: Fri, 18 Oct 2024 15:14:31 +0200 Subject: [PATCH] Add check on relative path when old location is None --- src/dataregistry/registrar/dataset.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/dataregistry/registrar/dataset.py b/src/dataregistry/registrar/dataset.py index 85034977..6a607a8e 100644 --- a/src/dataregistry/registrar/dataset.py +++ b/src/dataregistry/registrar/dataset.py @@ -76,6 +76,12 @@ def _validate_register_inputs( if i_char in name: raise ValueError(f"Cannot have character {i_char} in name string") + # If no data is being copied from an `old_location`, `relative_path` is + # required + if kwargs_dict["old_location"] is None and kwargs_dict["location_type"] == "dataregistry" and kwargs_dict["relative_path"] is None: + raise ValueError("A `relative_path` must be passed when `old_location` is None " + "i.e., the data is assumed to be already within the `root_dir`") + # If external dataset, check for either a `url` or `contact_email` if kwargs_dict["location_type"] == "external": if kwargs_dict["url"] is None and kwargs_dict["contact_email"] is None: