From 020c38db1190e21d7ce02e3b17e8d194650ff201 Mon Sep 17 00:00:00 2001
From: LHCbDIRAC Bot <dirac.bot@cern.ch>
Date: Thu, 17 Oct 2024 17:24:37 +0200
Subject: [PATCH] Merge branch 'roneil/fix-client-methods-and-handlers' into
 'master'

Fixed client and tornado handler methods for getProductions and get/addPublications

See merge request lhcb-dirac/LHCbDIRAC!1654

(cherry picked from commit fb1b53ffdf2c024dd289ca10898b26e34d0a6afb)

3d9fb599 Fixed client and tornado handler methods for getProductions and get/addPublications

Co-authored-by: Federico Stagni <federico.stagni@cern.ch>
---
 .../Client/AnalysisProductionsClient.py        |  8 ++++++--
 .../TornadoAnalysisProductionsHandler.py       | 18 ++++++++++++++++--
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/LHCbDIRAC/ProductionManagementSystem/Client/AnalysisProductionsClient.py b/src/LHCbDIRAC/ProductionManagementSystem/Client/AnalysisProductionsClient.py
index 10317bd062..6d5d4cb19f 100644
--- a/src/LHCbDIRAC/ProductionManagementSystem/Client/AnalysisProductionsClient.py
+++ b/src/LHCbDIRAC/ProductionManagementSystem/Client/AnalysisProductionsClient.py
@@ -158,6 +158,8 @@ class AnalysisProductionsClient(Client):
         with_pfns: bool = True,
         with_transformations: bool = False,
         at_time: Opt[datetime] = None,
+        show_archived: bool = False,
+        require_has_publication: bool = False,
     ):
         """Return the list of productions for a specific analysis
 
@@ -182,6 +184,8 @@ class AnalysisProductionsClient(Client):
             with_pfns,
             with_transformations,
             at_time,
+            show_archived,
+            require_has_publication,
             call="getProductions",
         )
 
@@ -299,9 +303,9 @@ class AnalysisProductionsClient(Client):
         :param number: publication number as a string (<64chars).
         :returns: S_OK() || S_ERROR()
         """
-        return self.executeRPC(samples, call="addPublication")
+        return self.executeRPC(samples, number, call="addPublication")
 
-    def getPublications(self, sample_ids):
+    def getPublications(self, sample_ids: Opt[list] = None):
         """Get publication numbers for the specified sample.
 
         :param samples: List of sample IDs
diff --git a/src/LHCbDIRAC/ProductionManagementSystem/Service/TornadoAnalysisProductionsHandler.py b/src/LHCbDIRAC/ProductionManagementSystem/Service/TornadoAnalysisProductionsHandler.py
index 9b6931d09c..0ad3170a90 100644
--- a/src/LHCbDIRAC/ProductionManagementSystem/Service/TornadoAnalysisProductionsHandler.py
+++ b/src/LHCbDIRAC/ProductionManagementSystem/Service/TornadoAnalysisProductionsHandler.py
@@ -27,6 +27,8 @@ from LHCbDIRAC.ProductionManagementSystem.DB.AnalysisProductionsDB import Analys
 
 optDate = (type(None), datetime)
 optString = (type(None), str)
+optList = (type(None), list)
+optBool = (type(None), bool)
 
 sLog = gLogger.getSubLogger(__name__)
 sLog._setOption("tornadoComponent", "ProductionManagement/TornadoAnalysisProduction")
@@ -76,7 +78,19 @@ class TornadoAnalysisProductionsHandler(TornadoService):
         """See :meth:`~.AnalysisProductionsClient.setOwners`"""
         return self._db.setOwners(wg=wg, analysis=analysis, owners=owners)
 
-    types_getProductions = [optString, optString, optString, optString, optString, bool, bool, bool, optDate]
+    types_getProductions = [
+        optString,
+        optString,
+        optString,
+        optString,
+        optString,
+        bool,
+        bool,
+        bool,
+        optDate,
+        optBool,
+        optBool,
+    ]
 
     @convertToReturnValue
     def export_getProductions(
@@ -212,7 +226,7 @@ class TornadoAnalysisProductionsHandler(TornadoService):
         """See :meth:`~.AnalysisProductionsClient.addPublication`"""
         return self._db.addPublication(samples, number)
 
-    types_getPublications = [list]
+    types_getPublications = [optList]
 
     @convertToReturnValue
     def export_getPublications(self, sample_ids):
-- 
GitLab