Coverage for sparkle/CLI/help/global_variables.py: 88%

25 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-07 15:22 +0000

1#!/usr/bin/env python3 

2"""Definitions of constants broadly used in Sparkle.""" 

3import ast 

4 

5from sparkle.CLI.help.reporting_scenario import ReportingScenario 

6from sparkle.platform.settings_objects import Settings 

7 

8 

9# TODO: Handle different seed requirements; for the moment this is a dummy function 

10def get_seed() -> int: 

11 """Return a seed.""" 

12 return 1 

13 

14 

15__latest_scenario: ReportingScenario = None 

16 

17 

18def latest_scenario() -> ReportingScenario: 

19 """Function to get the global latest scenario object.""" 

20 global __latest_scenario 

21 if __latest_scenario is None: 

22 __latest_scenario = ReportingScenario() 

23 return __latest_scenario 

24 

25 

26__settings: Settings = None 

27 

28 

29def settings() -> Settings: 

30 """Function to get the global settings object.""" 

31 global __settings 

32 if __settings is None: 

33 __settings = Settings() 

34 return __settings 

35 

36 

37reference_list_dir = settings().DEFAULT_reference_dir 

38extractor_nickname_list_path = reference_list_dir / "sparkle_extractor_nickname_list.txt" 

39solver_nickname_list_path = reference_list_dir / "sparkle_solver_nickname_list.txt" 

40instances_nickname_path = reference_list_dir / "sparkle_instance_nickname_list.txt" 

41 

42file_storage_data_mapping = {solver_nickname_list_path: {}, 

43 instances_nickname_path: {}, 

44 extractor_nickname_list_path: {}} 

45 

46for data_path in file_storage_data_mapping.keys(): 

47 if data_path.exists(): 

48 with data_path.open("r+") as fo: 

49 file_storage_data_mapping[data_path] = ast.literal_eval(fo.read()) 

50 

51solver_nickname_mapping = file_storage_data_mapping[solver_nickname_list_path]