Skip to content

Change how SQL database schema is initialized - adopting SQL raw files #12341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 22, 2025

Conversation

amaltaro
Copy link
Contributor

@amaltaro amaltaro commented Apr 21, 2025

Fixes #12339

Status

ready

Description

This pull request changes how the database schema is defined and initialized in WMCore/WMAgent, using the SQL plain files defined in this repository https://github.com/dmwm/wmcoredb instead. For the conversion from Python-based to plain SQL files, files have been identified and extract in WMCore and T0 repositories.

Summary of changes/commits so far are:

  • new python library dependency on wmcoredb (which now contains the SQL files and look-up functions)
  • WMInit and TestInit can now map the old schema name (e.g. WMCore.WMBS) to the new schema name (e.g. wmbs)
  • to keep changes as compatible as possible, calls are still made to WMInit.setSchema() with the old module name, but it maps it to the new module and calls WMInit.setSchemaFromModules().
  • look up for the new SQL schema under WMCORE_ROOT env var; or fallback to the base path used for wmcoredb library;
  • ensure module schema deployment dependency order is performed;
  • parse Oracle SQL files to separate SQL statements between each call to processData() (if we execute the full content of an SQL file through SQLAlchemy, it will fail)
  • integrated wm_init table creation with the new SQL schema (hence, to be removed from CMSKubernetes)
  • refactored usage of SEQ.nextval for Oracle, as we no longer use sequences for autoincrement, but we rely on the IDENTITY feature available as of Oracle 12c.
  • updated several unit tests to deploy the required module schema; plus a few unit tests changes/updates

Deprecate old Python-based database schema data:

  • remove CreateWMBSBase module and use
  • remove unused DQMCat/ package
  • removed Create.py modules for: WMBS, TestDB, ResourceControl, Agent, BossAir, DBS3Buffer

WMCore actual bug-fixes:

  • WMBS.Job.AddFiles MySQL DAO was missing an IGNORE clause;
  • removed none job status from bl_status table (batch system status)
  • no longer insert None file checksum into the database (as now there are explicit table constraints)
  • made column type consistent for wmbs_job_mask.inclusivemask column

Is it backward compatible (if not, which system it affects?)

YES (it should be)

Related PRs

None

External dependencies / deployment changes

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: failed
    • 476 new failures
    • 14 changes in unstable tests
  • Python3 Pylint check: failed
    • 20 warnings and errors that must be fixed
    • 6 warnings
    • 62 comments to review
  • Pycodestyle check: succeeded
    • 68 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/588/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: failed
    • 158 new failures
    • 12 changes in unstable tests
  • Python3 Pylint check: failed
    • 20 warnings and errors that must be fixed
    • 6 warnings
    • 62 comments to review
  • Pycodestyle check: succeeded
    • 68 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/589/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: failed
    • 88 new failures
    • 1 changes in unstable tests
  • Python3 Pylint check: failed
    • 20 warnings and errors that must be fixed
    • 6 warnings
    • 92 comments to review
  • Pycodestyle check: succeeded
    • 77 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/590/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: failed
    • 65 new failures
    • 3 changes in unstable tests
  • Python3 Pylint check: failed
    • 20 warnings and errors that must be fixed
    • 6 warnings
    • 92 comments to review
  • Pycodestyle check: succeeded
    • 77 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/591/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: failed
    • 50 new failures
    • 5 changes in unstable tests
  • Python3 Pylint check: failed
    • 40 warnings and errors that must be fixed
    • 7 warnings
    • 158 comments to review
  • Pycodestyle check: succeeded
    • 97 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/592/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: failed
    • 17 new failures
    • 3 changes in unstable tests
  • Python3 Pylint check: failed
    • 45 warnings and errors that must be fixed
    • 7 warnings
    • 165 comments to review
  • Pycodestyle check: succeeded
    • 97 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/593/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: failed
    • 1 new failures
    • 4 changes in unstable tests
  • Python3 Pylint check: failed
    • 51 warnings and errors that must be fixed
    • 7 warnings
    • 166 comments to review
  • Pycodestyle check: succeeded
    • 120 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/594/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: failed
    • 3 new failures
    • 3 changes in unstable tests
  • Python3 Pylint check: failed
    • 50 warnings and errors that must be fixed
    • 7 warnings
    • 166 comments to review
  • Pycodestyle check: succeeded
    • 120 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/595/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: failed
    • 3 new failures
    • 5 changes in unstable tests
  • Python3 Pylint check: failed
    • 50 warnings and errors that must be fixed
    • 7 warnings
    • 166 comments to review
  • Pycodestyle check: succeeded
    • 120 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/596/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 4 changes in unstable tests
  • Python3 Pylint check: failed
    • 50 warnings and errors that must be fixed
    • 7 warnings
    • 191 comments to review
  • Pycodestyle check: succeeded
    • 121 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/597/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 5 changes in unstable tests
  • Python3 Pylint check: failed
    • 65 warnings and errors that must be fixed
    • 8 warnings
    • 303 comments to review
  • Pycodestyle check: succeeded
    • 183 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/598/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 1 changes in unstable tests
  • Python3 Pylint check: failed
    • 65 warnings and errors that must be fixed
    • 8 warnings
    • 313 comments to review
  • Pycodestyle check: succeeded
    • 193 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/599/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 3 changes in unstable tests
  • Python3 Pylint check: failed
    • 65 warnings and errors that must be fixed
    • 8 warnings
    • 313 comments to review
  • Pycodestyle check: succeeded
    • 193 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/612/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
  • Python3 Pylint check: failed
    • 65 warnings and errors that must be fixed
    • 8 warnings
    • 313 comments to review
  • Pycodestyle check: succeeded
    • 193 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/614/artifact/artifacts/PullRequestReport.html

@amaltaro amaltaro force-pushed the fix-12339 branch 2 times, most recently from b2fa410 to c3da3ec Compare April 25, 2025 01:14
@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 2 changes in unstable tests
  • Python3 Pylint check: failed
    • 63 warnings and errors that must be fixed
    • 8 warnings
    • 313 comments to review
  • Pycodestyle check: succeeded
    • 193 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/615/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
  • Python3 Pylint check: failed
    • 63 warnings and errors that must be fixed
    • 8 warnings
    • 313 comments to review
  • Pycodestyle check: succeeded
    • 193 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/616/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 2 tests added
    • 4 changes in unstable tests
  • Python3 Pylint check: failed
    • 67 warnings and errors that must be fixed
    • 8 warnings
    • 325 comments to review
  • Pycodestyle check: succeeded
    • 197 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/617/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 2 tests added
    • 2 changes in unstable tests
  • Python3 Pylint check: failed
    • 106 warnings and errors that must be fixed
    • 10 warnings
    • 381 comments to review
  • Pycodestyle check: succeeded
    • 249 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/869/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 2 tests added
    • 1 changes in unstable tests
  • Python3 Pylint check: failed
    • 104 warnings and errors that must be fixed
    • 10 warnings
    • 381 comments to review
  • Pycodestyle check: succeeded
    • 249 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/870/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 2 tests added
  • Python3 Pylint check: failed
    • 110 warnings and errors that must be fixed
    • 11 warnings
    • 388 comments to review
  • Pycodestyle check: succeeded
    • 249 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/871/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 2 tests added
    • 3 changes in unstable tests
  • Python3 Pylint check: failed
    • 110 warnings and errors that must be fixed
    • 11 warnings
    • 388 comments to review
  • Pycodestyle check: succeeded
    • 249 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/872/artifact/artifacts/PullRequestReport.html

@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 2 tests added
    • 5 changes in unstable tests
  • Python3 Pylint check: failed
    • 110 warnings and errors that must be fixed
    • 11 warnings
    • 388 comments to review
  • Pycodestyle check: succeeded
    • 249 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/873/artifact/artifacts/PullRequestReport.html

amaltaro added 8 commits July 17, 2025 23:30
Streamline DB initialization in WMInit and TestInit

Backwards compatibility from setSchema() to setSchemaFromModules()

Correct map of old to new SQL module names

Update DBS3Buffer module map; add tier0 map files

Fix agent SQL map; remove call to self.init.setSchemaFromComponent

Add WMQuality.TestDB schema to WMInit

Avoid primary key violation for WMBS/Job - wmbs_job_assoc

Now Job object can be associated multiple times

some pylint fixes for WMInit

Reorganize SQL files structure to keep db flavor at top level

Use WMCORE_ROOT env var to find the SQL files in production

Fix exception args in WMInit

Avoid double sql directory

Fix tier0 module dependency

REMOVE: temporary SQL files to test unit tests

REMOVE: add tier0 SQL files

Add testdb SQL schema

Indexes and primary key fixes for wmbs SQL files

Remove primary keys for TestDB tables

Add SQL files to new structure

REMOVE-ME: removed tablespace from wmbs indexes

REMOVE-ME: fix initial data for wmbs

REMOVE-ME: more consistent database schema for Oracle

REMOVE-ME: make wmbs_job.retry_count larger to support 99999

REMOVE-ME: sync last sql schema changes

REMOVE-ME: update tier0 create tables file

Oracle schema requires splitting of statements

Refactor all Oracle SQL files to use slash as statement terminator

update create_wmbs_tables with slash terminator

Increase id column length for t0_deployment_id

Update WMInit to separate statements using slask instead of semicolon

Remove hard-coded SQL files from this PR

Update requirements to new wmcoredb version; adopt wmcoredb in WMInit

Update wmcoredb to 0.9.2

Add debugging to WMInit

Extra debugging

Remove debugging from WMInit

Update wmcoredb to 0.9.3
Remove TestDB Create.py modules

Remove ResourceControl Create.py modules

Remove Agent Create.py modules

Remove BossAir Create.py modules

Remove DBS3Buffer Create.py modules
…oincrement now

Fix SEQ.nextval changes for wmbs_subscription

Ignore duplicate bl_status values in Oracle

Fix NewState Oracle DAO

Fix again Oracle NewState DAO

Stop using SEQ.nextval in the WMComponent DAOs, as it uses autoincrement now
Skip None checksum insertion in JobAccountant
@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: failed
    • 2 tests added
    • 1 changes in unstable tests
  • Python3 Pylint check: failed
    • 110 warnings and errors that must be fixed
    • 11 warnings
    • 388 comments to review
  • Pycodestyle check: succeeded
    • 249 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/874/artifact/artifacts/PullRequestReport.html

WMInit unit tests for _getSQLStatements

Fix unit tests adopting wmcoredb to locate SQL files

more fixes to unit test

Move ResourceControl_t.py test to SQL based schema

Adapt ResourceControl_t to use a friendly DB initialization

Fix modules for setSchema in DBSBufferFile_t.py

Fix many unit tests

Fix ChangeState_t unit test

Fix unit tests for wma_init
@dmwm-bot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 2 tests added
    • 3 changes in unstable tests
  • Python3 Pylint check: failed
    • 110 warnings and errors that must be fixed
    • 11 warnings
    • 388 comments to review
  • Pycodestyle check: succeeded
    • 249 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/WMCore-PR-Report/875/artifact/artifacts/PullRequestReport.html

@amaltaro amaltaro requested review from todor-ivanov and anpicci July 18, 2025 04:06
@amaltaro
Copy link
Contributor Author

I would say I have completed all this development now and the description should be summarizing all of the changes and pointing to related/dependent external pull requests.

Please let me know if you want me to further squash these commits. I tried to separate them by concerns (new sql model, removal of old python schema, bug fix in the CRUD DAOs, unit tests, etc) and I would suggest to keep the current granularity, but I am happy to squeeze them further. Thanks!

Copy link
Contributor

@todor-ivanov todor-ivanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
Looking good.

@amaltaro
Copy link
Contributor Author

Thanks Todor. I am getting this merged and its dependencies merged then.

@amaltaro amaltaro merged commit ded0b8a into dmwm:master Jul 22, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Separate WMAgent SQL database schema from python modules
3 participants