Skip to content

Commit 8c7c672

Browse files
authored
Merge pull request #7496 from chaen/v8.0_fix_monitoringTypeLoader
[8.0] Monitoring type loader fixes for editable install
2 parents bb0d266 + 3c1812f commit 8c7c672

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/DIRAC/Core/Utilities/ObjectLoader.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ def getObjects(self, modulePath, reFilter=None, parentClass=None, recurse=False,
177177

178178
def loadObjects(path, reFilter=None, parentClass=None):
179179
"""
180+
181+
Note: this does not work for editable install because it hardcodes
182+
DIRAC.__file__
183+
It is better to use ObjectLoader().getObjects()
184+
180185
:param str path: the path to the syetem for example: DIRAC/AccountingSystem
181186
:param object reFilter: regular expression used to found the class
182187
:param object parentClass: class instance
@@ -192,6 +197,7 @@ def loadObjects(path, reFilter=None, parentClass=None):
192197
objDir = os.path.join(os.path.dirname(os.path.dirname(DIRAC.__file__)), parentModule, *pathList)
193198
if not os.path.isdir(objDir):
194199
continue
200+
195201
for objFile in os.listdir(objDir):
196202
if reFilter.match(objFile):
197203
pythonClassName = objFile[:-3]

src/DIRAC/Core/Utilities/Plotting/TypeLoader.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
""" Utility for loading plotting types.
22
Works both for Accounting and Monitoring.
33
"""
4+
45
import re
56

6-
from DIRAC.Core.Utilities.ObjectLoader import loadObjects
7+
from DIRAC.Core.Utilities.ObjectLoader import ObjectLoader
78

89
from DIRAC.AccountingSystem.Client.Types.BaseAccountingType import BaseAccountingType
910
from DIRAC.MonitoringSystem.Client.Types.BaseType import BaseType
@@ -26,18 +27,21 @@ def __init__(self, plottingFamily="Accounting"):
2627
"""c'tor"""
2728
self.__loaded = {}
2829
if plottingFamily == "Accounting":
29-
self.__path = "AccountingSystem/Client/Types"
30+
self.__path = "AccountingSystem.Client.Types"
3031
self.__parentCls = BaseAccountingType
3132
elif plottingFamily == "Monitoring":
32-
self.__path = "MonitoringSystem/Client/Types"
33+
self.__path = "MonitoringSystem.Client.Types"
3334
self.__parentCls = BaseType
34-
self.__reFilter = re.compile(r".*[a-z1-9]\.py$")
3535

3636
########################################################################
3737
def getTypes(self):
3838
"""
3939
It returns all monitoring classes
4040
"""
4141
if not self.__loaded:
42-
self.__loaded = loadObjects(self.__path, self.__reFilter, self.__parentCls)
42+
allObjects = ObjectLoader().getObjects(self.__path, parentClass=self.__parentCls)["Value"]
43+
for _objectModule, objectClass in allObjects.items():
44+
if objectClass.__name__ not in self.__loaded and objectClass != self.__parentCls:
45+
self.__loaded[objectClass.__name__] = objectClass
46+
4347
return self.__loaded

0 commit comments

Comments
 (0)