Skip to content

Commit

Permalink
fix: deprecated getTransformationFilesAsJsonString
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Nov 6, 2024
1 parent c61df70 commit 25a36c1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/DIRAC/TransformationSystem/Client/TransformationClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def getTransformationFiles(
timeStamp = "LastUpdate"

if "LFN" not in condDict:
res = rpcClient.getTransformationFilesAsJsonString(
res = rpcClient.getTransformationFiles(
condDict, older, newer, timeStamp, orderAttribute, offset, maxfiles, columns
)
if not res["OK"]:
Expand Down Expand Up @@ -208,7 +208,7 @@ def getTransformationFiles(
# Apply the offset to the list of LFNs
condDict["LFN"] = lfnList[offsetToApply : offsetToApply + limit]
# No limit and no offset as the list is limited already
res = rpcClient.getTransformationFilesAsJsonString(
res = rpcClient.getTransformationFiles(
condDict, older, newer, timeStamp, orderAttribute, None, None, columns
)
if not res["OK"]:
Expand Down
9 changes: 1 addition & 8 deletions src/DIRAC/TransformationSystem/DB/TransformationDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@ def getTransformationFiles(
offset=None,
connection=False,
columns=None,
include_web_records=True,
):
"""Get files for the supplied transformations with support for the web standard structure"""
connection = self.__getConnection(connection)
Expand Down Expand Up @@ -634,12 +633,7 @@ def getTransformationFiles(

resultList = [dict(zip(columns, row)) for row in res["Value"]]

result = S_OK(resultList)
if include_web_records:
webList = [[str(item) if not isinstance(item, int) else item for item in row] for row in res["Value"]]
result["Records"] = webList
result["ParameterNames"] = columns
return result
return S_OK(resultList)

def getFileSummary(self, lfns, connection=False):
"""Get file status summary in all the transformations"""
Expand Down Expand Up @@ -909,7 +903,6 @@ def getTransformationTasks(
return res
resultList.append(taskDict)
result = S_OK(resultList)
result["Records"] = webList
result["ParameterNames"] = self.TASKSPARAMS
return result

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
""" Service for interacting with TransformationDB
"""

from DIRAC import S_OK, S_ERROR
from DIRAC import S_ERROR, S_OK
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
from DIRAC.Core.DISET.RequestHandler import RequestHandler
from DIRAC.Core.Security.Properties import SecurityProperty
from DIRAC.Core.Utilities.Decorators import deprecated
from DIRAC.Core.Utilities.DEncode import ignoreEncodeWarning
from DIRAC.Core.Utilities.JEncode import encode as jencode
from DIRAC.Core.Utilities.ObjectLoader import ObjectLoader
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
from DIRAC.RequestManagementSystem.Client.Operation import Operation
from DIRAC.RequestManagementSystem.Client.Request import Request
from DIRAC.TransformationSystem.Client import TransformationFilesStatus
from DIRAC.WorkloadManagementSystem.Client import JobStatus
from DIRAC.RequestManagementSystem.Client.Request import Request
from DIRAC.RequestManagementSystem.Client.Operation import Operation


TASKS_STATE_NAMES = ["TotalCreated", "Created"] + sorted(
set(JobStatus.JOB_STATES) | set(Request.ALL_STATES) | set(Operation.ALL_STATES)
Expand Down Expand Up @@ -292,11 +292,10 @@ def export_getTransformationFiles(
limit=None,
offset=None,
columns=None,
include_web_records=True,
):
if not condDict:
condDict = {}
return self.transformationDB.getTransformationFiles(
result = self.transformationDB.getTransformationFiles(
condDict=condDict,
older=older,
newer=newer,
Expand All @@ -306,21 +305,21 @@ def export_getTransformationFiles(
offset=offset,
connection=False,
columns=columns,
include_web_records=include_web_records,
)

# DEncode cannot cope with nested structures of multiple millions items.
# Encode everything as a json string, that DEncode can then transmit faster.

return S_OK(jencode(result))

types_getTransformationFilesAsJsonString = types_getTransformationFiles

@deprecated("Use getTransformationFiles instead")
def export_getTransformationFilesAsJsonString(self, *args, **kwargs):
"""
DEncode cannot cope with nested structures of multiple millions items.
Encode everything as a json string, that DEncode can then transmit faster.
This will be the default as of v9.0
Deprecated call -- redirect to getTransformationFiles
"""
kwargs["include_web_records"] = False
res = self.export_getTransformationFiles(*args, **kwargs)
return S_OK(jencode(res))
return self.export_getTransformationFiles(*args, **kwargs)

####################################################################
#
Expand Down

0 comments on commit 25a36c1

Please sign in to comment.