Skip to content

Create a new target to copy the files after all the other targets #326

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 3 commits into from
Jun 12, 2025

Conversation

jmcarcell
Copy link
Member

@jmcarcell jmcarcell commented Jun 12, 2025

Currently the python folder is copied to a subdirectory in the build tree and this is used for the python imports. The problem is that Gaudi can overwrite the __init__.py with an empty file, and then first k4run will complain that the [0] indexing of the loggers doesn't work, and if that is fixed then it will complain with a weird error.

This is the error about the indexing:

32: Traceback (most recent call last):
32:   File "/k4FWCore/k4FWCore/scripts/k4run", line 278, in <module>
32:     main()
32:     ~~~~^^
32:   File "/k4FWCore/k4FWCore/scripts/k4run", line 138, in main
32:     logger.handlers[0].setFormatter(formatter)
32:     ~~~~~~~~~~~~~~~^^^
32: IndexError: list index out of range

which is easy to fix, but then

32: Traceback (most recent call last):
32:   File "/k4FWCore/k4FWCore/scripts/k4run", line 283, in <module>
32:     main()
32:     ~~~~^^
32:   File "/k4FWCore/k4FWCore/scripts/k4run", line 210, in main
32:     load_file(file)
32:     ~~~~~~~~~^^^^^^
32:   File "k4FWCore/build/k4FWCore/k4FWCore/genConfDir/k4FWCore/utils.py", line 87, in load_file
32:     exec(code, globals())
32:     ~~~~^^^^^^^^^^^^^^^^^
32:   File "<string>", line 31, in <module>
32: TypeError: 'module' object is not callable

A way of reproducing it is to build, then comment out one of the files in

components/CollectionMerger.cpp

and then compile again. The file k4FWCore/genConfDir/k4FWCore/__init__.py in the build directory will now be empty, and running ctest will fail. I have also found these errors consistently in CI one day a few weeks ago (I suspect there is a probability that Gaudi overwrites the file in any build if the order is not the right one).

BEGINRELEASENOTES

  • Create a new target to copy the files after all the other targets to prevent errors

ENDRELEASENOTES

Copy link
Contributor

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

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

Nice. I have also stumbled over this at some point, but couldn't reproduce it later, I think.

@jmcarcell
Copy link
Member Author

Because after a clean build the issue disappears... It just happened to happen today for me again after a long while.

@jmcarcell jmcarcell force-pushed the fix-python-errors branch from 40af9ac to 2938e6a Compare June 12, 2025 15:53
@jmcarcell jmcarcell merged commit 72e25f6 into main Jun 12, 2025
7 checks passed
@jmcarcell jmcarcell deleted the fix-python-errors branch June 12, 2025 18:59
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.

2 participants