Skip to content

Commit 65a9261

Browse files
authored
Merge pull request #8546 from aldbr/fix-dms-add-file-help-7290
[8.0] docs: retrieve dirac-dms-add-file lost documentation
2 parents a1dc25d + 142a24f commit 65a9261

4 files changed

Lines changed: 38 additions & 34 deletions

File tree

docs/docs.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ no_inherited_members =
3131
DIRAC.Core.Utilities.Graphs.GraphUtilities,
3232
DIRAC.DataManagementSystem.private.HttpStorageAccessHandler,
3333
DIRAC.FrameworkSystem.private.standardLogging.LogLevels,
34+
DIRAC.Resources.IdProvider.OAuth2IdProvider,
35+
DIRAC.Resources.IdProvider.CheckInIdProvider,
36+
DIRAC.Resources.IdProvider.IAMIdProvider,
3437

3538
# only creating dummy files, because they cannot be safely imported due to sideEffects
3639
create_dummy_files = lfc_dfc_copy, lfc_dfc_db_copy, JobWrapperTemplate

src/DIRAC/Core/Utilities/ElasticSearchDB.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def getDoc(self, index: str, docID: str) -> dict:
248248
"""
249249
sLog.debug(f"Retrieving document {docID} in index {index}")
250250
try:
251-
return S_OK(self.client.get(index, docID)["_source"])
251+
return S_OK(self.client.get(index=index, id=docID)["_source"])
252252
except NotFoundError:
253253
sLog.warn("Could not find the document in index", index)
254254
return S_OK({})
@@ -265,7 +265,7 @@ def getDocs(self, indexFunc, docIDs: list[str]) -> list[dict]:
265265
sLog.debug(f"Retrieving documents {docIDs}")
266266
docs = [{"_index": indexFunc(docID), "_id": docID} for docID in docIDs]
267267
try:
268-
response = self.client.mget({"docs": docs})
268+
response = self.client.mget(body={"docs": docs})
269269
except RequestError as re:
270270
return S_ERROR(re)
271271
else:
@@ -283,12 +283,12 @@ def updateDoc(self, index: str, docID: str, body) -> dict:
283283
"""
284284
sLog.debug(f"Updating document {docID} in index {index}")
285285
try:
286-
self.client.update(index, docID, body)
286+
self.client.update(index=index, id=docID, body=body)
287287
except ConflictError:
288288
# updates are rather "heavy" operations from ES point of view, needing seqNo to be updated.
289289
# Not ideal, but we just wait and retry.
290290
time.sleep(1)
291-
self.client.update(index, docID, body, params={"retry_on_conflict": 3})
291+
self.client.update(index=index, id=docID, body=body, params={"retry_on_conflict": 3})
292292
except RequestError as re:
293293
return S_ERROR(re)
294294
return S_OK()
@@ -302,7 +302,7 @@ def deleteDoc(self, index: str, docID: str):
302302
"""
303303
sLog.debug(f"Deleting document {docID} in index {index}")
304304
try:
305-
return S_OK(self.client.delete(index, docID))
305+
return S_OK(self.client.delete(index=index, id=docID))
306306
except RequestError as re:
307307
return S_ERROR(re)
308308
except NotFoundError:
@@ -317,7 +317,7 @@ def existsDoc(self, index: str, docID: str) -> bool:
317317
:param docID: document ID
318318
"""
319319
sLog.debug(f"Checking if document {docID} in index {index} exists")
320-
return self.client.exists(index, docID)
320+
return self.client.exists(index=index, id=docID)
321321

322322
@ifConnected
323323
def _Search(self, indexname):
@@ -348,7 +348,7 @@ def getIndexes(self, indexName=None):
348348
indexName = self.__indexPrefix
349349
sLog.debug(f"Getting indices alias of {indexName}")
350350
# we only return indexes which belong to a specific prefix for example 'lhcb-production' or 'dirac-production etc.
351-
return list(self.client.indices.get_alias(f"{indexName}*"))
351+
return list(self.client.indices.get_alias(index=f"{indexName}*"))
352352

353353
@ifConnected
354354
def getDocTypes(self, indexName):
@@ -361,7 +361,7 @@ def getDocTypes(self, indexName):
361361
result = []
362362
try:
363363
sLog.debug("Getting mappings for ", indexName)
364-
result = self.client.indices.get_mapping(indexName)
364+
result = self.client.indices.get_mapping(index=indexName)
365365
except Exception as e: # pylint: disable=broad-except
366366
sLog.exception()
367367
return S_ERROR(e)
@@ -392,7 +392,7 @@ def existingIndex(self, indexName):
392392
"""
393393
sLog.debug(f"Checking existance of index {indexName}")
394394
try:
395-
return S_OK(self.client.indices.exists(indexName))
395+
return S_OK(self.client.indices.exists(index=indexName))
396396
except TransportError as e:
397397
sLog.exception()
398398
return S_ERROR(e)
@@ -434,7 +434,7 @@ def deleteIndex(self, indexName):
434434
"""
435435
sLog.info("Deleting index", indexName)
436436
try:
437-
retVal = self.client.indices.delete(indexName)
437+
retVal = self.client.indices.delete(index=indexName)
438438
except NotFoundError:
439439
sLog.warn("Index does not exist", indexName)
440440
return S_OK("Nothing to delete")

src/DIRAC/DataManagementSystem/scripts/dirac_dms_add_file.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,24 @@
44
# Author : Stuart Paterson
55
########################################################################
66
"""
7-
Upload a file to the grid storage and register it in the File Catalog
7+
Upload a file to the grid storage and register it in the File Catalog.
88
9-
Usage:
10-
dirac-dms-add-file [options] ... LFN Path SE [GUID]
11-
12-
Arguments:
13-
LFN: Logical File Name
14-
Path: Local path to the file
15-
SE: DIRAC Storage Element
16-
GUID: GUID to use in the registration (optional)
17-
18-
**OR**
9+
The file(s) to upload can be passed either directly as arguments, or listed in a
10+
local text file given as the only argument (one upload per line).
1911
2012
Usage:
13+
dirac-dms-add-file [options] ... LFN Path SE [GUID]
2114
dirac-dms-add-file [options] ... LocalFile ...
2215
2316
Arguments:
24-
LocalFile: Path to local file containing all the above, i.e.::
25-
26-
lfn1 localfile1 SE [GUID1]
27-
lfn2 localfile2 SE [GUID2]
17+
LFN: Logical File Name
18+
Path: Local path to the file
19+
SE: DIRAC Storage Element
20+
GUID: GUID to use in the registration (optional)
21+
LocalFile: Path to a local file listing the uploads described above, one per line, i.e.::
22+
23+
lfn1 localfile1 SE [GUID1]
24+
lfn2 localfile2 SE [GUID2]
2825
2926
Example:
3027
$ dirac-dms-add-file LFN:/formation/user/v/vhamar/Example.txt Example.txt DIRAC-USER

src/DIRAC/RequestManagementSystem/DB/RequestDB.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@
55

66
# We disable pylint no-callable because of https://github.com/PyCQA/pylint/issues/8138
77

8-
""" Frontend for ReqDB
8+
"""Frontend for ReqDB
99
10-
:mod: RequestDB
10+
:mod: RequestDB
1111
12-
=======================
12+
=======================
1313
14-
.. module: RequestDB
14+
.. module: RequestDB
1515
16-
:synopsis: db holding Requests
16+
:synopsis: db holding Requests
1717
18-
db holding Request, Operation and File
18+
db holding Request, Operation and File
1919
"""
20+
2021
import errno
2122
import random
2223
from urllib.parse import quote_plus
@@ -600,7 +601,9 @@ def getDBSummary(self):
600601

601602
operationQuery = (
602603
session.query(
603-
Operation.Type, Operation._Status, func.count(Operation.OperationID) # pylint: disable=not-callable
604+
Operation.Type,
605+
Operation._Status,
606+
func.count(Operation.OperationID), # pylint: disable=not-callable
604607
)
605608
.group_by(Operation.Type, Operation._Status)
606609
.all()
@@ -759,8 +762,9 @@ def getRequestCountersWeb(self, groupingAttribute, selectDict):
759762
groupingColumn = self._get_column("Request", groupingAttribute)
760763

761764
summaryQuery = session.query(
762-
groupingColumn, func.count(Request.RequestID)
763-
) # pylint: disable=not-callable,no-member
765+
groupingColumn,
766+
func.count(Request.RequestID), # pylint: disable=not-callable
767+
)
764768

765769
for key, value in selectDict.items():
766770
if key == "ToDate":

0 commit comments

Comments
 (0)