Skip to content
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

Alternative module configuration syntax #43955

Merged
merged 2 commits into from
Mar 3, 2024

Conversation

Dr15Jones
Copy link
Contributor

PR description:

Uses the default C++ configuration description to generate a new python file that knows the module

  • class name
  • type
  • default parameters names and types
    By importing the file (directly or indirectly through the new 'modules' python module) the developer no longer needs
    to specify those information with declaring a module for use.

PR validation:

Framework unit tests all pass, including the two that were modified to use the new syntax.

@cmsbuild
Copy link
Contributor

cmsbuild commented Feb 13, 2024

cms-bot internal usage

@cmsbuild
Copy link
Contributor

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-43955/38840

  • This PR adds an extra 40KB to repository

Code check has found code style and quality issues which could be resolved by applying following patch(s)

@Dr15Jones
Copy link
Contributor Author

please test

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-43955/38841

  • This PR adds an extra 40KB to repository

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @Dr15Jones (Chris Jones) for master.

It involves the following packages:

  • FWCore/Integration (core)
  • FWCore/ParameterSet (core)

@Dr15Jones, @makortel, @smuzaffar can you please review it and eventually sign? Thanks.
@missirol, @wddgit, @makortel this is something you requested to watch as well.
@rappoccio, @antoniovilela, @sextonkennedy you are the release manager for this.

cms-bot commands are listed here

Comment on lines -5 to +14
process.source = cms.Source("DelayedReaderThrowingSource", labels = cms.untracked.vstring("test", "test2", "test3"))
process.source = DelayedReaderThrowingSource( labels = ["test", "test2", "test3"])

process.getter = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag(cms.InputTag("test","","INPUTTEST")))
process.onPath = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag(cms.InputTag("test2", "", "INPUTTEST"), cms.InputTag("getter", "other")))
process.f1 = cms.EDFilter("IntProductFilter", label = cms.InputTag("onPath"), shouldProduce = cms.bool(True))
process.f2 = cms.EDFilter("IntProductFilter", label = cms.InputTag("onPath"), shouldProduce = cms.bool(True))
process.inFront = cms.EDFilter("IntProductFilter", label = cms.InputTag("test3"))
process.getter = AddIntsProducer(labels = [("test","","INPUTTEST")])
process.onPath = AddIntsProducer(labels = [("test2", "", "INPUTTEST"), ("getter", "other")])
process.f1 = IntProductFilter( label = "onPath", shouldProduce = True)
process.f2 = IntProductFilter( label = "onPath", shouldProduce = True)
process.inFront = IntProductFilter( label = "test3")
Copy link
Contributor

Choose a reason for hiding this comment

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

This is something I was thinking about ages ago, when I was spending too much of my time looking after the HLT configurations, and I'm glad to see it being implemented !

Looking at the example, the main concern I have is for InputTags and VInputTags: writing or reading

labels = [("test2", "", "INPUTTEST"), ("getter", "other")]

I think it's very easy to get confused about getter and other being two components on an InputTag instead of two separate InputTags.

Some other confusing exmples:

this is a VInputTag with only one InputTag ?

labels = [("getter", "other")]

this is a VInputTag with two InputTags ?

labels = ["getter", "other"]

this is a VInputTag with two InputTags ?

labels = ["getter"]

this is a VInputTag with two InputTags ?

labels = [("getter")]

this is a VInputTag with two InputTags ?

labels = [("getter",)]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fwyzard Thanks for the feedback! All the examples are already possible since this code just reuses what is already available. The reduced syntax can already be used in

  • Modifiers
  • clone statements
  • explicit changing of existing established parameters

E.g.

>>> import FWCore.ParameterSet.Config as cms
>>> test = cms.EDProducer("FOO", srcs = cms.VInputTag())
>>> test.srcs = ["getter"]
>>> print(test.dumpPython())
cms.EDProducer("FOO",
    srcs = cms.VInputTag("getter")
)

That being said, the reduced syntax also excepts the explicit type information as well

>>> test.srcs = [cms.InputTag("getter")]
>>> print(test.dumpPython())
cms.EDProducer("FOO",
    srcs = cms.VInputTag(cms.InputTag("getter"))
)

As for some of your explicit examples, I'm curious why you ask if the following are VInputTags with two entries, rather than (the correct) a VInputTags with 1 entry.

labels = ["getter"]
labels = [("getter")]

or even

labels = [("getter",)]

which does require one to understand that (...,) in python is just a way to express a tuple with a single entry.

All the above are standard python for a container with 1 entry.

Copy link
Contributor

Choose a reason for hiding this comment

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

These two cases could be interpreted as ambiguous for understanding the type of labels (InputTag vs VInputTag) only from the assignment.

this is a VInputTag with two InputTags ?

labels = ["getter", "other"]

The same syntax would work for InputTag (with module and instance labels) and for 2-element VInputTag

this is a VInputTag with two InputTags ?

labels = ["getter"]

The same syntax would work for InputTag (with module labels) and for 1-element VInputTag.

(for reference, the sequence-syntax for assining InputTag was added in #29992, #29846)

@cmsbuild
Copy link
Contributor

-1

Failed Tests: Build
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-4771e4/37437/summary.html
COMMIT: dbd80eb
CMSSW: CMSSW_14_1_X_2024-02-13-1100/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/43955/37437/install.sh to create a dev area with all the needed externals and cmssw changes.

Build

I found compilation error when building:

>> Done generating edm plugin poisoned information
gmake[1]: *** [config/SCRAM/GMake/Makefile.rules:1958: CompilePython] Error 1
>> Plugins of all types refreshed.
gmake[1]: Target 'PostBuild' not remade because of errors.
gmake[1]: Leaving directory '/data/cmsbld/jenkins/workspace/ib-run-pr-tests/CMSSW_14_1_X_2024-02-13-1100'
gmake: *** [config/SCRAM/GMake/Makefile.rules:1846: src] Error 2
gmake: Target 'all' not remade because of errors.
gmake: *** [There are compilation/build errors. Please see the detail log above.] Error 2
+ eval scram build outputlog '&&' '(python3' /data/cmsbld/jenkins/workspace/ib-run-pr-tests/cms-bot/buildLogAnalyzer.py --logDir /data/cmsbld/jenkins/workspace/ib-run-pr-tests/CMSSW_14_1_X_2024-02-13-1100/tmp/el8_amd64_gcc12/cache/log/src '||' 'true)'
++ scram build outputlog
>> Entering Package FWCore/Integration


@Dr15Jones
Copy link
Contributor Author

please test

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-43955/39287

  • This PR adds an extra 32KB to repository

  • There are other open Pull requests which might conflict with changes you have proposed:

@cmsbuild
Copy link
Contributor

Pull request #43955 was updated. @makortel, @smuzaffar, @Dr15Jones can you please check and sign again.

@Dr15Jones
Copy link
Contributor Author

Dr15Jones commented Feb 29, 2024

As a test, I found that the following could be a different way to implement the _cfi.py files from fillDescriptions

from .FooProd import FooProd

foo = FooProd(aValue = 5)

The relative python module path would avoid needing to know into which SubSystem.Package the file is generated.

I hand created one such _cfi.py file in the correct cfipython sub-directory and everything (including calling cms.Process.load) worked just fine.

NOTE: Using from .modules import FooProd also works.

@fwyzard
Copy link
Contributor

fwyzard commented Feb 29, 2024

from .FooProd import FooProd

foo = FooProd(aValue = 5)

This only works for auto-generated cfis, or also for hand written ones ?

@Dr15Jones
Copy link
Contributor Author

This only works for auto-generated cfis, or also for hand written ones ?

I did a quick test and it does work with hand-written ones as well (surprisingly).

@cmsbuild
Copy link
Contributor

cmsbuild commented Mar 1, 2024

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-4771e4/37822/summary.html
COMMIT: acefa33
CMSSW: CMSSW_14_1_X_2024-02-29-1100/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/43955/37822/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

@makortel
Copy link
Contributor

makortel commented Mar 1, 2024

+core

@cmsbuild
Copy link
Contributor

cmsbuild commented Mar 1, 2024

This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @sextonkennedy, @antoniovilela, @rappoccio (and backports should be raised in the release meeting by the corresponding L2)

@antoniovilela
Copy link
Contributor

+1

@cmsbuild cmsbuild merged commit 236dee5 into cms-sw:master Mar 3, 2024
11 checks passed
@smuzaffar
Copy link
Contributor

smuzaffar commented Mar 11, 2024

@Dr15Jones , looks like this change now creates cfipythion/arch/SubSystem/Package/modules.py file for every plugin. I think this is causing build failures like [a]. This happens when a package has multuiple plugins which generate cfi modules. Currently build rules assumes that all plugins should generate a unique files.

[a] cms-sw/cmsdist#9046 (comment)

Leaving library rule at src/CalibCalorimetry/EcalLaserCorrection/plugins
@@@@ Running edmWriteConfigs for CalibCalorimetryEcalLaserCorrectionService
EcalLaserCorrectionServiceMC
EcalLaserCorrectionService
cp: cannot create regular file 'cfipython/el8_aarch64_gcc12/CalibCalorimetry/EcalLaserCorrection/modules.py': File exists
gmake: *** [lib/el8_aarch64_gcc12/CalibCalorimetryEcalLaserCorrectionService.edmplugin] Error 1
Entering library rule at src/CalibCalorimetry/EcalLaserCorrection/test
>> Compiling edm plugin src/CalibCalorimetry/EcalLaserCorrection/test/EcalLaserDbAnalyzer.cc
>> Building edm plugin tmp/el8_aarch64_gcc12/src/CalibCalorimetry/EcalLaserCorrection/test/EcalLaserDbAnalyzer/libEcalLaserDbAnalyzer.so
Leaving library rule at src/CalibCalorimetry/EcalLaserCorrection/test
@@@@ Running edmWriteConfigs for EcalLaserDbAnalyzer

@makortel
Copy link
Contributor

looks like this change now creates cfipythion/arch/SubSystem/Package/modules.py file for every plugin.

Correct. We think it would be best if scram would create the modules.py file for every package that generates any python files (i.e. treat it similarly to the __init__.py, see also #44314 (comment)). The content of the modules.py file is always the same. Creating the modules.py for every plugin was kind of the best that could be done in edmWriteConfigs alone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants