FairShip
Loading...
Searching...
No Matches
config_tester Namespace Reference

Functions

 parse_arguments ()
 main (arguments)

Variables

 logger = logging.getLogger()

Function Documentation

◆ main()

config_tester.main ( arguments)

Definition at line 31 of file config_tester.py.

31def main(arguments):
32 logger.info("file: %s" % arguments.config_file)
33 if arguments.params:
34 logger.info("parameters: %s" % arguments.params)
35
36 # Load the geometry config module
37 spec = importlib.util.spec_from_file_location("geometry_config", arguments.config_file)
38 if spec is None or spec.loader is None:
39 raise ImportError(f"Could not load geometry config from {arguments.config_file}")
40 geometry_config = importlib.util.module_from_spec(spec)
41 spec.loader.exec_module(geometry_config)
42
43 # Create config with parameters
44 config = geometry_config.create_config(**arguments.params)
45
46 # Print configuration
47 for k, v in config.items():
48 print(f"{k}: {v}")
49
50
create_config(str DecayVolumeMedium="helium", float Yheight=6.0, int strawDesign=10, str shieldName="TRY_2026", int nuTargetPassive=1, bool SND=True, SND_design=None, TARGET_YAML=None)

◆ parse_arguments()

config_tester.parse_arguments ( )

Definition at line 16 of file config_tester.py.

16def parse_arguments():
17 ap = argparse.ArgumentParser(description="test configuration file")
18 ap.add_argument("-d", "--debug", action="store_true")
19 ap.add_argument(
20 "-p", "--params", type=json.loads, help="""config parameters in json form '{"a": 1, "b": 2}' """, default={}
21 )
22
23 ap.add_argument("config_file", help="config file to test")
24 args = ap.parse_args()
25 if args.debug:
26 logger.setLevel(logging.DEBUG)
27 assert os.path.exists(args.config_file)
28 return args
29
30

Variable Documentation

◆ logger

config_tester.logger = logging.getLogger()

Definition at line 12 of file config_tester.py.