Skip to content

Commit

Permalink
Require namespace in Rucio DIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
ponyisi authored and BenGalewsky committed Nov 14, 2024
1 parent 36faf36 commit b196f68
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
5 changes: 5 additions & 0 deletions servicex/dataset_identifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ def __init__(self, dataset: str, num_files: Optional[int] = None):
returns the same subset of files.
"""
if ':' not in dataset:
# Missing a colon means that no namespace is specified and the request
# will fail on the backend
raise ValueError(f'Specified dataset {dataset} is missing a Rucio namespace. '
'Please specify the dataset ID in the form "namespace:dataset".')
super().__init__("rucio", dataset, num_files=num_files)

yaml_tag = '!Rucio'
Expand Down
18 changes: 12 additions & 6 deletions tests/test_dataset_identifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,22 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from servicex.dataset_identifier import DataSetIdentifier, RucioDatasetIdentifier, \
FileListDataset
import pytest


def test_did():
did = DataSetIdentifier(scheme="rucio", dataset="123-455")
assert did.did == "rucio://123-455"
did = DataSetIdentifier(scheme="rucio", dataset="abc:123-455")
assert did.did == "rucio://abc:123-455"


def test_rucio():
did = RucioDatasetIdentifier("123-456")
assert did.did == "rucio://123-456"
did = RucioDatasetIdentifier("abc:123-456")
assert did.did == "rucio://abc:123-456"


def test_rucio_no_namespace():
with pytest.raises(ValueError):
RucioDatasetIdentifier("123-456")


def test_file_list():
Expand All @@ -54,6 +60,6 @@ def test_populate_transform_request(transform_request):
did.populate_transform_request(transform_request)
assert transform_request.file_list == ["c:/foo.bar"]

did2 = RucioDatasetIdentifier("123-456")
did2 = RucioDatasetIdentifier("abc:123-456")
did2.populate_transform_request(transform_request)
assert transform_request.did == "rucio://123-456"
assert transform_request.did == "rucio://abc:123-456"

0 comments on commit b196f68

Please sign in to comment.