DIRAC icon indicating copy to clipboard operation
DIRAC copied to clipboard

Bad refactoring lead to client needing DB access

Open chaen opened this issue 6 months ago • 1 comments

The error below is due to https://github.com/DIRACGrid/DIRAC/pull/8192

$ dirac-admin-allow-se --AllowRemove Tier1-Archive
Traceback (most recent call last):
  File "/home/chaen/dirac/diracx-project/lhcbdiracx/.pixi/envs/default/bin/dirac-admin-allow-se", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/chaen/dirac/DIRAC/src/DIRAC/Core/Base/Script.py", line 74, in __call__
    return entrypointFunc._func()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chaen/dirac/DIRAC/src/DIRAC/DataManagementSystem/scripts/dirac_admin_allow_se.py", line 62, in main
    from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
  File "/home/chaen/dirac/DIRAC/src/DIRAC/Interfaces/API/DiracAdmin.py", line 22, in <module>
    from DIRAC.WorkloadManagementSystem.Service.WMSUtilities import (
  File "/home/chaen/dirac/DIRAC/src/DIRAC/WorkloadManagementSystem/Service/WMSUtilities.py", line 15, in <module>
    from DIRAC.Resources.Computing.ComputingElementFactory import ComputingElementFactory
  File "/home/chaen/dirac/DIRAC/src/DIRAC/Resources/Computing/ComputingElementFactory.py", line 5, in <module>
    from DIRAC.Resources.Computing.ComputingElement import getCEConfigDict
  File "/home/chaen/dirac/DIRAC/src/DIRAC/Resources/Computing/ComputingElement.py", line 50, in <module>
    from DIRAC.WorkloadManagementSystem.Utilities.JobParameters import (
  File "/home/chaen/dirac/DIRAC/src/DIRAC/WorkloadManagementSystem/Utilities/JobParameters.py", line 7, in <module>
    from DIRAC.WorkloadManagementSystem.DB.JobDB import JobDB
  File "/home/chaen/dirac/DIRAC/src/DIRAC/WorkloadManagementSystem/DB/JobDB.py", line 22, in <module>
    from DIRAC.Core.Base.DB import DB
  File "/home/chaen/dirac/DIRAC/src/DIRAC/Core/Base/DB.py", line 5, in <module>
    from DIRAC.Core.Utilities.MySQL import MySQL
  File "/home/chaen/dirac/DIRAC/src/DIRAC/Core/Utilities/MySQL.py", line 156, in <module>
    import MySQLdb
ModuleNotFoundError: No module named 'MySQLdb'

Moving a DB import into a utility which is used a lot client side is not a good thing. I've temporarily fixed it with https://github.com/DIRACGrid/DIRAC/pull/8217 but probably a better overhaul is needed

chaen avatar Jun 04 '25 13:06 chaen

I don't think #8217 is a satisfactory option really. It probably deserves a better refactoring

chaen avatar Jun 05 '25 11:06 chaen