Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require namespace in Rucio DIDs #513

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Loading