Skip to content

Commit

Permalink
TMP fix monitoring loader
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed Feb 23, 2024
1 parent 495785e commit ee102aa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/DIRAC/Core/Utilities/ObjectLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def getObjects(self, modulePath, reFilter=None, parentClass=None, recurse=False,
reFilter is a regular expression to filter what to load. For instance ".*Handler"
parentClass is a class object from which the loaded modules have to import from. For instance RequestHandler
:param continueOnError: if True, continue loading further module even if one fails
"""
modules = collections.OrderedDict()
Expand Down Expand Up @@ -192,10 +191,14 @@ def loadObjects(path, reFilter=None, parentClass=None):
objDir = os.path.join(os.path.dirname(os.path.dirname(DIRAC.__file__)), parentModule, *pathList)
if not os.path.isdir(objDir):
continue

for objFile in os.listdir(objDir):
print(objFile)
if reFilter.match(objFile):
print("match")
pythonClassName = objFile[:-3]
if pythonClassName not in objectsToLoad:
print("adding")
gLogger.debug(f"Adding to load queue {parentModule}/{path}/{pythonClassName}")
objectsToLoad[pythonClassName] = parentModule

Expand Down
11 changes: 9 additions & 2 deletions src/DIRAC/Core/Utilities/Plotting/TypeLoader.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
""" Utility for loading plotting types.
Works both for Accounting and Monitoring.
"""

import re

from DIRAC.Core.Utilities.ObjectLoader import loadObjects
from DIRAC.Core.Utilities.ObjectLoader import ObjectLoader

from DIRAC.AccountingSystem.Client.Types.BaseAccountingType import BaseAccountingType
from DIRAC.MonitoringSystem.Client.Types.BaseType import BaseType
Expand Down Expand Up @@ -39,5 +40,11 @@ def getTypes(self):
It returns all monitoring classes
"""
if not self.__loaded:
self.__loaded = loadObjects(self.__path, self.__reFilter, self.__parentCls)
allObjects = ObjectLoader().getObjects("MonitoringSystem.Client.Types", parentClass=self.__parentCls)[
"Value"
]
for _objectModule, objectClass in allObjects.items():
if objectClass.__name__ not in self.__loaded and objectClass != self.__parentCls:
self.__loaded[objectClass.__name__] = objectClass

return self.__loaded

0 comments on commit ee102aa

Please sign in to comment.