def init_local_config_at(path, wrapped_vcs): """ Arguments: path(str): path where the empty shared config will be initialized wrapped_vcs(dict): dictionary with wrapped vcs of type {'vcs': {'type', 'url'}} """ if not path.endswith('local.yml') and not path.endswith('local.yaml'): path = os.path.join(path, 'local.yml') store.touch_file(path) # Create a config for user to set up local_config = streams.safely_load_yaml_from_stream(""" vcs: type: {0} url: {1} ## To collect profiling data from the binary using the set of collectors, ## uncomment and edit the following region: # cmds: # - echo ## To add set of parameters for the profiled command/binary, ## uncomment and edit the following region: # args: # - -e ## To add workloads/inputs for the profiled command/binary, ## uncomment and edit the following region: # workloads: # - hello # - world ## To register a collector for generating profiling data, ## uncomment and edit the following region: # collectors: # - name: time ## Try '$ perun collect --help' to obtain list of supported collectors! ## To register a postprocessor for generated profiling data, ## uncomment and edit the following region (!order matters!): # postprocessors: # - name: normalizer # params: --remove-zero # - name: filter ## Try '$ perun postprocessby --help' to obtain list of supported collectors! """.format(wrapped_vcs['vcs']['type'], wrapped_vcs['vcs']['url'])) write_config_file(local_config, path)
def init_shared_config_at(path): """Creates the new configuration at given path with sane defaults of e.g. editor, paging of outputs or formats for status or log commands. :param str path: path where the empty global config will be initialized """ if not path.endswith('shared.yml') and not path.endswith('shared.yaml'): path = os.path.join(path, 'shared.yml') store.touch_file(path) shared_config = streams.safely_load_yaml_from_stream(""" general: editor: vim paging: only-log format: status: "\u2503 %type% \u2503 %collector% \u2503 (%time%) \u2503 %source% \u2503" shortlog: "%checksum:6% (%stats%) %desc% %changes%" output_profile_template: "%collector%-%cmd%-%args%-%workload%-%date%" output_show_template: "%collector%-%cmd%-%args%-%workload%-%date%" sort_profiles_by: time degradation: apply: all strategies: - method: average_amount_threshold generators: workload: - id: basic_strings type: string min_len: 8 max_len: 128 step: 8 - id: basic_integers type: integer min_range: 100 max_range: 10000 step: 200 - id: basic_files type: textfile min_lines: 10 max_lines: 10000 step: 1000 """) write_config_to(path, shared_config)
def init_shared_config_at(path): """ Arguments: path(str): path where the empty global config will be initialized """ if not path.endswith('shared.yml') and not path.endswith('shared.yaml'): path = os.path.join(path, 'shared.yml') store.touch_file(path) shared_config = streams.safely_load_yaml_from_stream(""" global: profile_info_fmt: "\u2503 [type] \u2503 [cmd] \u2503 [workload] \u2503 [collector] \u2503 ([time]) \u2503 [id] \u2503" minor_version_info_fmt: "[id:6] ([stats]) [desc]" editor: vim """) write_config_file(shared_config, path)
def init_local_config_at(path, wrapped_vcs, config_template='master'): """Creates the new local configuration at given path with sane defaults and helper comments for use in order to initialize the config matrix. :param str path: path where the empty shared config will be initialized :param dict wrapped_vcs: dictionary with wrapped vcs of type {'vcs': {'type', 'url'}} :param str config_template: name of the template that will be used to initialize the local """ if not path.endswith('local.yml') and not path.endswith('local.yaml'): path = os.path.join(path, 'local.yml') store.touch_file(path) # Get configuration template predefined_config = templates.get_predefined_configuration( config_template, wrapped_vcs) # Create a config for user to set up local_config = streams.safely_load_yaml_from_stream(predefined_config) write_config_to(path, local_config)
def parse_yaml_param(ctx, param, value): """Callback function for parsing the yaml files to dictionary object Arguments: ctx(Context): context of the called command param(click.Option): parameter that is being parsed and read from commandline value(str): value that is being read from the commandline Returns: dict: parsed yaml file """ unit_to_params = {} for (unit, yaml_file) in value: # First check if this is file if os.path.exists(yaml_file): unit_to_params[unit] = streams.safely_load_yaml_from_file( yaml_file) else: unit_to_params[unit] = streams.safely_load_yaml_from_stream( yaml_file) return unit_to_params
def parse_yaml_single_param(ctx, param, value): """Callback function for parsing the yaml files to dictionary object, when called from 'collect' This does not require specification of the collector to which the params correspond and is meant as massaging of parameters for 'perun -p file collect ...' command. Arguments: ctx(Context): context of the called command param(click.Option): parameter that is being parsed and read from commandline value(str): value that is being read from the commandline Returns: dict: parsed yaml file """ unit_to_params = {} for yaml_file in value: # First check if this is file if os.path.exists(yaml_file): unit_to_params.update( streams.safely_load_yaml_from_file(yaml_file)) else: unit_to_params.update( streams.safely_load_yaml_from_stream(yaml_file)) return unit_to_params