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

Keep looping through configurables #138

Merged
merged 2 commits into from
Aug 22, 2023
Merged

Conversation

kjvbrt
Copy link
Contributor

@kjvbrt kjvbrt commented Aug 11, 2023

BEGINRELEASENOTES

  • k4run: fix error about "dictionary changed size during iteration"

ENDRELEASENOTES

Otherwise, I'm getting the following error with this configuration file.

Traceback (most recent call last):                                                                         
  File "/home/jsmiesko/Work/FCC/k4FWCore/install/bin/k4run", line 140, in <module>                         
    add_arguments(parser, ApplicationMgr())                                                                
  File "/home/jsmiesko/Work/FCC/k4FWCore/install/bin/k4run", line 32, in add_arguments                     
    for conf in configurables:                                                                             
RuntimeError: dictionary changed size during iteration

Nota bene: The configuration file has also other problems :)

@Zehvogel
Copy link
Contributor

Interesting, we should probably at least honour this particularity it with a comment then.
Do you have an idea why this happens? Can we come up with a smaller reproducer for this?

@kjvbrt
Copy link
Contributor Author

kjvbrt commented Aug 14, 2023

From the print debugging I would say that when the algorithm with tools is added its tools are added to the list of configurables

11:31:06 [jsmiesko@carriacou k4RecCalorimeter (main =)]$ k4run RecFCCeeCalorimeter/tests/options/runCaloSim.py 
-------------------------------------------------
<bound method Configurable.name of ApplicationMgr('ApplicationMgr')>
-------------------------------------------------
<bound method Configurable.name of FCCDataSvc('EventDataSvc')>
configurables num. of elemets: 37
dict_values([ApplicationMgr('ApplicationMgr'), FCCDataSvc('EventDataSvc'), MomentumRangeParticleGun('ToolSvc.MomentumRangeParticleGun'), GenAlg('GenAlg'), MomentumRangeParticleGun('GenAlg.MomentumRangeParticleGun'), HepMCToEDMConverter('Converter'), GeoSvc('GeoSvc'), SimG4Svc('SimG4Svc'), SimG4ConstantMagneticFieldTool('ToolSvc.SimG4ConstantMagneticFieldTool'), SimG4SaveCalHits('ToolSvc.saveECalBarrelHits'), SimG4Alg('SimG4Alg'), SimG4SaveCalHits('ToolSvc.saveECalEndcapHits'), SimG4SaveCalHits('ToolSvc.saveHCalBarrelHits'), SimG4PrimariesFromEdmTool('ToolSvc.EdmConverter'), SimG4PrimariesFromEdmTool('SimG4Alg.EdmConverter'), CalibrateInLayersTool('ToolSvc.CalibrateECalBarrel'), CalibrateCaloHitsTool('ToolSvc.CalibrateHCal'), CalibrateCaloHitsTool('ToolSvc.CalibrateECalEndcap'), CreateCaloCells('CreateECalBarrelCellsStep1'), CalibrateInLayersTool('CreateECalBarrelCellsStep1.CalibrateECalBarrel'), RedoSegmentation('ReSegmentationEcal'), CreateCaloCells('CreateECalBarrelCells'), CellPositionsECalBarrelTool('ToolSvc.CellPositionsECalBarrel'), CreateCaloCellPositionsFCCee('ECalBarrelPositionedCells'), CreateCaloCells('CreateHCaloCells'), CalibrateCaloHitsTool('CreateHCaloCells.CalibrateHCal'), CreateCaloCells('CreateEcalEndcapCaloCells'), CalibrateCaloHitsTool('CreateEcalEndcapCaloCells.CalibrateECalEndcap'), CreateEmptyCaloCellsCollection('CreateEmptyCaloCells'), CaloTowerTool('ToolSvc.towers'), CreateCaloClustersSlidingWindow('CreateClusters'), CreateCaloCellPositionsFCCee('ECalBarrelPositionedCaloClusterCells'), CorrectCaloClusters('correctCaloClusters'), PodioOutput('out'), ChronoAuditor('ChronoAuditor'), AuditorSvc('AuditorSvc'), EventCounter('event_counter')])
-------------------------------------------------
<bound method Configurable.name of MomentumRangeParticleGun('ToolSvc.MomentumRangeParticleGun')>
-------------------------------------------------
<bound method Configurable.name of GenAlg('GenAlg')>
configurables num. of elemets: 41
dict_values([ApplicationMgr('ApplicationMgr'), FCCDataSvc('EventDataSvc'), MomentumRangeParticleGun('ToolSvc.MomentumRangeParticleGun'), GenAlg('GenAlg'), MomentumRangeParticleGun('GenAlg.MomentumRangeParticleGun'), HepMCToEDMConverter('Converter'), GeoSvc('GeoSvc'), SimG4Svc('SimG4Svc'), SimG4ConstantMagneticFieldTool('ToolSvc.SimG4ConstantMagneticFieldTool'), SimG4SaveCalHits('ToolSvc.saveECalBarrelHits'), SimG4Alg('SimG4Alg'), SimG4SaveCalHits('ToolSvc.saveECalEndcapHits'), SimG4SaveCalHits('ToolSvc.saveHCalBarrelHits'), SimG4PrimariesFromEdmTool('ToolSvc.EdmConverter'), SimG4PrimariesFromEdmTool('SimG4Alg.EdmConverter'), CalibrateInLayersTool('ToolSvc.CalibrateECalBarrel'), CalibrateCaloHitsTool('ToolSvc.CalibrateHCal'), CalibrateCaloHitsTool('ToolSvc.CalibrateECalEndcap'), CreateCaloCells('CreateECalBarrelCellsStep1'), CalibrateInLayersTool('CreateECalBarrelCellsStep1.CalibrateECalBarrel'), RedoSegmentation('ReSegmentationEcal'), CreateCaloCells('CreateECalBarrelCells'), CellPositionsECalBarrelTool('ToolSvc.CellPositionsECalBarrel'), CreateCaloCellPositionsFCCee('ECalBarrelPositionedCells'), CreateCaloCells('CreateHCaloCells'), CalibrateCaloHitsTool('CreateHCaloCells.CalibrateHCal'), CreateCaloCells('CreateEcalEndcapCaloCells'), CalibrateCaloHitsTool('CreateEcalEndcapCaloCells.CalibrateECalEndcap'), CreateEmptyCaloCellsCollection('CreateEmptyCaloCells'), CaloTowerTool('ToolSvc.towers'), CreateCaloClustersSlidingWindow('CreateClusters'), CreateCaloCellPositionsFCCee('ECalBarrelPositionedCaloClusterCells'), CorrectCaloClusters('correctCaloClusters'), PodioOutput('out'), ChronoAuditor('ChronoAuditor'), AuditorSvc('AuditorSvc'), EventCounter('event_counter'), ConstPileUp('GenAlg.PileUpTool'), FlatSmearVertex('GenAlg.VertexSmearingTool'), HepMCSimpleMerge('GenAlg.HepMCMergeTool'), MomentumRangeParticleGun('GenAlg.HepMCProviderTool')])
Traceback (most recent call last):
  File "/home/jsmiesko/Work/FCC/k4FWCore/install/bin/k4run", line 139, in <module>
    add_arguments(parser, ApplicationMgr())
  File "/home/jsmiesko/Work/FCC/k4FWCore/install/bin/k4run", line 31, in add_arguments
    for conf in configurables:
RuntimeError: dictionary changed size during iteration

Copy link
Contributor

@Zehvogel Zehvogel left a comment

Choose a reason for hiding this comment

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

Looks like all the tools that an algorithm can have are added when ´.getPropertiesWithDescription()´ gets called, not only the ones explicitly set?

We could also think about looping twice to add all of the tools' properties to the arguments as well, if anyone wants that..

I would really like to have a small test algorithm in this repo that shows the same behavior as e.g. GenAlg but that can be added later and should not keep us from merging this.

k4FWCore/scripts/k4run Outdated Show resolved Hide resolved
Co-authored-by: Leonhard Reichenbach <[email protected]>
@jmcarcell jmcarcell changed the title Keep looping through configurables with dict.fromkeys() Keep looping through configurables Aug 22, 2023
@jmcarcell jmcarcell merged commit f057ccd into key4hep:main Aug 22, 2023
2 of 5 checks passed
@kjvbrt kjvbrt deleted the configurables branch August 24, 2023 09:25
@kjvbrt
Copy link
Contributor Author

kjvbrt commented Aug 24, 2023

Thanks

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.

3 participants