Skip to content

Commit

Permalink
Merge pull request #7740 from andresailer/80_fileDetails
Browse files Browse the repository at this point in the history
[8.0] FileCatalog: add function to get user metadata for list of LFNs
  • Loading branch information
fstagni authored Aug 14, 2024
2 parents f27c14c + 504439d commit 7c8eedd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/DIRAC/DataManagementSystem/DB/FileCatalogDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,23 @@ def getFileDescendents(self, lfns, depths, credDict):
successful = res["Value"]["Successful"]
return S_OK({"Successful": successful, "Failed": failed})

def getFileDetailsPublic(self, lfns, credDict):
"""Return all the metadata, including user defined, for those lfns that exist.
:return: S_OK with a dictionary of LFNs to detailed information
"""

res = self._checkPathPermissions("getFileDetailsPublic", lfns, credDict)
if not res["OK"]:
return res
failed = res["Value"]["Failed"]

# if no successful, just return empty dict
if not res["Value"]["Successful"]:
return S_OK({})

return self.getFileDetails(res["Value"]["Successful"], credDict)

def getFileDetails(self, lfnList, credDict):
"""Get all the metadata for the given files"""
connection = False
Expand Down
8 changes: 7 additions & 1 deletion src/DIRAC/DataManagementSystem/Service/FileCatalogHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ def export_getFileMetadata(self, lfns):
"""Get the metadata associated to supplied lfns"""
return self.fileCatalogDB.getFileMetadata(lfns, self.getRemoteCredentials())

types_getFileDetails = [[list, dict, str]]

def export_getFileDetails(self, lfns):
"""Get all the metadata associated to supplied lfns, including user metadata"""
return self.fileCatalogDB.getFileDetailsPublic(lfns, self.getRemoteCredentials())

types_getReplicas = [[list, dict, str], bool]

def export_getReplicas(self, lfns, allStatus=False):
Expand Down Expand Up @@ -336,7 +342,7 @@ def export_isDirectory(self, lfns):
types_getDirectoryMetadata = [[list, dict, str]]

def export_getDirectoryMetadata(self, lfns):
"""Get the size of the supplied directory"""
"""Get the metadata of the supplied directory"""
return self.fileCatalogDB.getDirectoryMetadata(lfns, self.getRemoteCredentials())

types_getDirectorySize = [[list, dict, str]]
Expand Down
6 changes: 6 additions & 0 deletions src/DIRAC/Resources/Catalog/FileCatalogClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class FileCatalogClient(FileCatalogClientBase):
READ_METHODS = FileCatalogClientBase.READ_METHODS + [
"isFile",
"getFileMetadata",
"getFileDetails",
"getReplicas",
"getReplicaStatus",
"getFileSize",
Expand Down Expand Up @@ -472,6 +473,11 @@ def getFileMetadata(self, lfns, timeout=120):
"""Get the metadata associated to supplied lfns"""
return self._getRPC(timeout=timeout).getFileMetadata(lfns)

@checkCatalogArguments
def getFileDetails(self, lfns, timeout=120):
"""Get the (user) metadata associated to supplied lfns"""
return self._getRPC(timeout=timeout).getFileDetails(lfns)

@checkCatalogArguments
def getReplicaStatus(self, lfns, timeout=120):
"""Get the status for the supplied replicas"""
Expand Down

0 comments on commit 7c8eedd

Please sign in to comment.