@@ -137,42 +137,41 @@ def initializeParameters(self):
137
137
138
138
self .log .debug ("Initializing the CE parameters" )
139
139
140
- # Collect global defaults first
141
- for section in ["/Resources/Computing/CEDefaults" , f"/Resources/Computing/{ self .ceType } " ]:
142
- result = gConfig .getOptionsDict (section )
143
-
144
- self .log .debug (result )
145
-
146
- if result ["OK" ]:
147
- ceOptions = result ["Value" ]
148
- for key in ceOptions :
149
- if key in INTEGER_PARAMETERS :
150
- ceOptions [key ] = int (ceOptions [key ])
151
- if key in FLOAT_PARAMETERS :
152
- ceOptions [key ] = float (ceOptions [key ])
153
- if key in LIST_PARAMETERS :
154
- ceOptions [key ] = gConfig .getValue (os .path .join (section , key ), [])
155
- self .ceParameters .update (ceOptions )
156
-
157
- # Get local CE configuration
158
- localConfigDict = getCEConfigDict (self .ceName )
159
- self .ceParameters .update (localConfigDict )
160
-
161
- # Adds site level parameters
162
- section = "/LocalSite"
163
- result = gConfig .getOptionsDict (section )
164
- if result ["OK" ] and result ["Value" ]:
165
- localSiteParameters = result ["Value" ]
166
- self .log .debug (f"Local site parameters are: { localSiteParameters } " )
167
- for option , value in localSiteParameters .items ():
168
- if option == "Architecture" :
169
- self .ceParameters ["Platform" ] = value
170
- self .ceParameters ["Architecture" ] = value
171
- elif option == "LocalSE" :
172
- self .ceParameters ["LocalSE" ] = value .split (", " )
173
- else :
174
- self .ceParameters [option ] = value
175
-
140
+ # Collect global defaults first:
141
+ # - /Resources/Computing/CEDefaults and /Resources/Computing/<CEType>
142
+ # Then the local CE configuration:
143
+ # - /LocalSite/<CEName>
144
+ # Finally the site level parameters
145
+ # - /LocalSite
146
+ for section in [
147
+ "/Resources/Computing/CEDefaults" ,
148
+ f"/Resources/Computing/{ self .ceType } " ,
149
+ f"/LocalSite/{ self .ceName } " ,
150
+ "/LocalSite" ,
151
+ ]:
152
+ ceParameters = getCEConfigDict (section )
153
+
154
+ # List parameters cannot be updated as any other fields, they should be concatenated in a set(), not overriden
155
+ for listParam in LIST_PARAMETERS :
156
+ # If listParam is not present or null, we remove it from ceParameters and continue
157
+ if not listParam in ceParameters or not ceParameters [listParam ]:
158
+ ceParameters .pop (listParam , [])
159
+ continue
160
+ # Initialize self.ceParameters[listParam] is not done and update the set
161
+ if not listParam in self .ceParameters :
162
+ self .ceParameters [listParam ] = set ()
163
+ self .ceParameters [listParam ].update (set (ceParameters .pop (listParam )))
164
+
165
+ self .log .debug (f"CE Parameters from { section } :" , ceParameters )
166
+ self .ceParameters .update (ceParameters )
167
+
168
+ # Site level adjustments
169
+ if "Architecture" in self .ceParameters :
170
+ self .ceParameters ["Platform" ] = self .ceParameters ["Architecture" ]
171
+ if "LocalSE" in self .ceParameters :
172
+ self .ceParameters ["LocalSE" ] = self .ceParameters ["LocalSE" ].split (", " )
173
+
174
+ # Add default values if required
176
175
self ._addCEConfigDefaults ()
177
176
178
177
def isValid (self ):
@@ -462,12 +461,14 @@ def getDescription(self):
462
461
for option , value in self .ceParameters .items ():
463
462
if isinstance (value , list ):
464
463
ceDict [option ] = value
464
+ elif isinstance (value , set ):
465
+ ceDict [option ] = list (value )
465
466
elif isinstance (value , str ):
466
467
try :
467
468
ceDict [option ] = int (value )
468
469
except ValueError :
469
470
ceDict [option ] = value
470
- elif isinstance (value , (int ,) + ( float , )):
471
+ elif isinstance (value , (int , float )):
471
472
ceDict [option ] = value
472
473
else :
473
474
self .log .warn (f"Type of option { option } = { value } not determined" )
@@ -515,11 +516,24 @@ def shutdown(self):
515
516
return S_OK (self .taskResults )
516
517
517
518
518
- def getCEConfigDict (ceName ):
519
- """Look into LocalSite for configuration Parameters for this CE"""
520
- ceConfigDict = {}
521
- if ceName :
522
- result = gConfig .getOptionsDict (f"/LocalSite/{ ceName } " )
523
- if result ["OK" ]:
524
- ceConfigDict = result ["Value" ]
525
- return ceConfigDict
519
+ def getCEConfigDict (section : str ) -> dict :
520
+ """Look into section for configuration Parameters for this CE
521
+
522
+ :param section: name of the CFG section to exploit
523
+ """
524
+
525
+ result = gConfig .getOptionsDict (section )
526
+
527
+ if not result ["OK" ]:
528
+ return {}
529
+
530
+ ceOptions = result ["Value" ]
531
+ for key in ceOptions :
532
+ if key in INTEGER_PARAMETERS :
533
+ ceOptions [key ] = int (ceOptions [key ])
534
+ if key in FLOAT_PARAMETERS :
535
+ ceOptions [key ] = float (ceOptions [key ])
536
+ if key in LIST_PARAMETERS :
537
+ ceOptions [key ] = gConfig .getValue (os .path .join (section , key ), [])
538
+
539
+ return ceOptions
0 commit comments