From e0403ead99435ef5227fee3859c6a6ef0e09043e Mon Sep 17 00:00:00 2001 From: Hasan Ozturk Date: Thu, 12 Sep 2024 11:59:36 +0300 Subject: [PATCH] Add pfn2lfn function to the policy package --- src/policy/CMSRucioPolicy/__init__.py | 5 ++++- src/policy/CMSRucioPolicy/algorithms/pfn2lfn.py | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/policy/CMSRucioPolicy/algorithms/pfn2lfn.py diff --git a/src/policy/CMSRucioPolicy/__init__.py b/src/policy/CMSRucioPolicy/__init__.py index f086772..320a783 100644 --- a/src/policy/CMSRucioPolicy/__init__.py +++ b/src/policy/CMSRucioPolicy/__init__.py @@ -2,7 +2,7 @@ # # Eric Vaandering , 2022 -from CMSRucioPolicy.algorithms import lfn2pfn, auto_approve +from CMSRucioPolicy.algorithms import lfn2pfn, auto_approve, pfn2lfn SUPPORTED_VERSION = ["32", "33", "34"] @@ -17,5 +17,8 @@ def get_algorithms(): }, 'auto_approve': { 'global': auto_approve.global_approval, + }, + 'pfn2lfn': { + 'cms_pfn2lfn': pfn2lfn.cms_pfn2lfn, } } diff --git a/src/policy/CMSRucioPolicy/algorithms/pfn2lfn.py b/src/policy/CMSRucioPolicy/algorithms/pfn2lfn.py new file mode 100644 index 0000000..cd98657 --- /dev/null +++ b/src/policy/CMSRucioPolicy/algorithms/pfn2lfn.py @@ -0,0 +1,14 @@ +""" +PFN to scope:name translation algorithm for CMS Rucio policy +""" +from collections.abc import Mapping + +def cms_pfn2lfn(parsed_pfn: Mapping[str, str]) -> tuple[str, str]: + """ + This function converts a PFN into scope:name pair. + It ignores user scopes and sets all scopes to cms. + """ + # Ignore user scopes for now + scope = "cms" + name = parsed_pfn['path'] + parsed_pfn['name'] + return name, scope \ No newline at end of file