Skip to content

Conversation

@jwaiton
Copy link
Member

@jwaiton jwaiton commented Oct 28, 2025

A silly bug has slipped through the cracks!

When running satellite killer outwith Beersheba it behaves normally, but when trying to run it from the command line as city Beersheba Beersheba_satkill.conf you receive this error message:

Traceback (most recent call last):
  File "/home/e78368jw/Documents/NEXT_CODE/IC/bin/city", line 21, in <module>
    city_function(**configure(args))
  File "/home/e78368jw/Documents/NEXT_CODE/IC/invisible_cities/core/configure.py", line 78, in configure
    options = read_config_file(CLI.config_file)
  File "/home/e78368jw/Documents/NEXT_CODE/IC/invisible_cities/core/configure.py", line 89, in read_config_file
    whole_config               = read_top_level_config_file(full_file_name)
  File "/home/e78368jw/Documents/NEXT_CODE/IC/invisible_cities/core/configure.py", line 116, in read_included_file
    exec(config_file.read(), globals_, config)
  File "<string>", line 36, in <module>
NameError: name 'CutType' is not defined

Naively importing CutType does not resolve this issue. The problem appears to be due to the globals_ used within exec() not including CutType, but rather just the built-in imports (& numpy).

I believe the Beersheba test doesn't capture this issue as it never uses configure() from configure.py, and as such never follows through the Traceback shown above.

This PR resolves this issue by including CutType into the dictionary of 'built-in' modules, but I believe this issue should be addressed more fully (perhaps an improvement in the output error of read_included_file() if the module isn't included in the builtins)

@gonzaponte
Copy link
Collaborator

gonzaponte commented Oct 29, 2025

I think I understand what's going on. A few lines above we have:

builtins.update(ALL_SYMBOLS)

which essentially adds all symbols to the global scope. Importantly, they are added without qualification (that is, the symbols are "imported" as abs instead of CutType.abs). If you remove the qualification from your config it should work.

@jwaiton
Copy link
Member Author

jwaiton commented Oct 30, 2025

which essentially adds all symbols to the global scope. Importantly, they are added without qualification (that is, the symbols are "imported" as abs instead of CutType.abs). If you remove the qualification from your config it should work.

You're right! I swear I tested this (as that's how it's passed in in the deconv_params), but clearly I had mixed something up. Thanks again.

@jwaiton jwaiton closed this Oct 30, 2025
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