From f4778b5b1e4dd81485139be267f4115af4c33180 Mon Sep 17 00:00:00 2001 From: David Hendriks <davidhendriks93@gmail.com> Date: Sun, 13 Dec 2020 00:27:56 +0000 Subject: [PATCH] added interface function for the description of options/settings. need to change some things but works now --- .../utils/grid_options_descriptions.py | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 binarycpython/utils/grid_options_descriptions.py diff --git a/binarycpython/utils/grid_options_descriptions.py b/binarycpython/utils/grid_options_descriptions.py new file mode 100644 index 000000000..732a17e94 --- /dev/null +++ b/binarycpython/utils/grid_options_descriptions.py @@ -0,0 +1,65 @@ +""" +File containing a dictionary which holds the description for all the grid_options settings. + +Using this, together with the accompanied function, the user can interactively check what the settings result in. + +With this its also possible to automatically generate a pdf file containing all the setting names + descriptions. + +TODO: change the options that one should not use (i.e. the things that are set by the grid itself) to start with an underscore + +""" + +from binarycpython.utils.grid_options_defaults import grid_options_defaults_dict + +# Grid containing the descriptions of the options +grid_options_descriptions = { + 'tmp_dir': "Directory where certain types of output are stored. The grid code is stored in that directory, as well as the custom logging libraries. Log files and other diagnostics will usually be written to this location, unless specified otherwise", # TODO: improve this + 'binary_c_dir': 'Director where binary_c is stored. This options are not really used', + 'binary_c_config_executable': 'Full path of the binary_c-config executable. This option is not really used.', + 'binary_c_executable': 'Full path to the binary_c executable. This options is not really used.', + 'binary_c_shared_library': "Full path to the libbinary_c file. This option is not really used", + 'verbosity': 'Verbosity of the population code. Default is 0, by which only errors will be printed. Higher values will show more output, which is good for debugging.', + 'binary': "Set this to 1 if the population contains binaries. Input: int", # TODO: write what effect this has. + 'amt_cores': "The amount of cores that the population grid will use. The multiprocessing is useful but make sure to figure out how many logical cores the machine has. The core is multiprocessed, not multithreaded, and will gain no extra speed when amt_cores exceeds the amount of logical cores. Input: int" +} + + +def grid_options_help(option): + """ + Function that returns the description of a grid option + """ + + option_keys = grid_options_defaults_dict.keys() + description_keys = grid_options_descriptions.keys() + + if not option in option_keys: + print("Error: This is an invalid entry. Option does not exist, please choose from the following options:\n\t{}".format(', '.join(option_keys))) + else: + if not option in description_keys: + print("This option has not been described properly yet. Please contact on of the authors") + + else: + print(grid_options_descriptions[option]) + +def grid_options_description_checker(print_info=True): + """ + Function that checks which descriptions are missing + """ + + option_keys = grid_options_defaults_dict.keys() + description_keys = grid_options_descriptions.keys() + + undescribed_keys = list(set(option_keys)-set(description_keys)) + + if undescribed_keys: + if print_info: + print("Warning: the following keys have no description yet:\n\t{}".format(", ".join(sorted(undescribed_keys)))) + print("Total description progress: {:.2f}%%".format(100 * len(description_keys)/len(option_keys))) + return len(undescribed_keys) + + +grid_options_help('amt_cores') + +grid_options_description_checker() + + -- GitLab