Skip to content

Commit

Permalink
Handle too long strings using experimental flag
Browse files Browse the repository at this point in the history
Base black configuration does not format strings that are too long.
A `--experimental-string-processing` flag has been used to format
them properly.
  • Loading branch information
JiriPavela committed Nov 5, 2023
1 parent 69e4f1d commit 2953db9
Show file tree
Hide file tree
Showing 37 changed files with 744 additions and 894 deletions.
252 changes: 156 additions & 96 deletions perun/cli.py

Large diffs are not rendered by default.

28 changes: 17 additions & 11 deletions perun/cli_groups/check_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
"-f",
is_flag=True,
default=False,
help="Force comparison of the selected profiles even if their configuration"
"does not match. This may be necessary when, e.g., different project"
"versions build binaries with version information in their name"
"(python3.10 and python3.11), thus failing the consistency check. ",
help=(
"Force comparison of the selected profiles even if their configuration"
"does not match. This may be necessary when, e.g., different project"
"versions build binaries with version information in their name"
"(python3.10 and python3.11), thus failing the consistency check. "
),
)
@click.option(
"--compute-missing",
Expand All @@ -36,8 +38,10 @@
),
is_flag=True,
default=False,
help="whenever there are missing profiles in the given point of history"
" the matrix will be rerun and new generated profiles assigned.",
help=(
"whenever there are missing profiles in the given point of history"
" the matrix will be rerun and new generated profiles assigned."
),
)
@click.option(
"--models-type",
Expand All @@ -47,10 +51,12 @@
multiple=False,
type=click.Choice(check.get_supported_detection_models_strategies()),
default=check.get_supported_detection_models_strategies()[0],
help="The detection models strategies predict the way of executing "
"the detection between two profiles, respectively between relevant "
"kinds of its models. Available only in the following detection "
"methods: Integral Comparison (IC) and Local Statistics (LS).",
help=(
"The detection models strategies predict the way of executing "
"the detection between two profiles, respectively between relevant "
"kinds of its models. Available only in the following detection "
"methods: Integral Comparison (IC) and Local Statistics (LS)."
),
)
def check_group(**_: Any) -> None:
"""Applies for the points of version history checks for possible performance changes.
Expand Down Expand Up @@ -200,7 +206,7 @@ def check_all(minor_head: str = "HEAD") -> None:
is_eager=True,
callback=cli_helpers.lookup_minor_version_callback,
metavar="<hash>",
help="Will check the index of different minor version <hash>" " during the profile lookup.",
help="Will check the index of different minor version <hash> during the profile lookup.",
)
@click.pass_context
def check_profiles(
Expand Down
8 changes: 5 additions & 3 deletions perun/cli_groups/config_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
"store_type",
flag_value="recursive",
default=True,
help="Sets the nearest suitable config as the source config. The"
" lookup strategy can differ for ``set`` and "
"``get``/``edit``.",
help=(
"Sets the nearest suitable config as the source config. The"
" lookup strategy can differ for ``set`` and "
"``get``/``edit``."
),
)
@click.pass_context
def config(ctx: click.Context, **kwargs: Any) -> None:
Expand Down
40 changes: 24 additions & 16 deletions perun/cli_groups/run_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
callback=cli_helpers.set_config_option_from_flag(
perun_config.runtime, "format.output_profile_template", str
),
help="Specifies the template for automatic generation of output filename"
" This way the file with collected data will have a resulting filename w.r.t "
" to this parameter. Refer to :ckey:`format.output_profile_template` for more"
" details about the format of the template.",
help=(
"Specifies the template for automatic generation of output filename"
" This way the file with collected data will have a resulting filename w.r.t "
" to this parameter. Refer to :ckey:`format.output_profile_template` for more"
" details about the format of the template."
),
)
@click.option(
"--minor-version",
Expand All @@ -43,16 +45,18 @@
is_flag=True,
default=False,
is_eager=True,
help="If set to true, then for each specified minor versions, profiles for parents"
" will be collected as well",
help=(
"If set to true, then for each specified minor versions, profiles for parents"
" will be collected as well"
),
)
@click.option(
"--force-dirty",
"-f",
is_flag=True,
default=False,
callback=cli_helpers.unsupported_option_callback,
help="If set to true, then even if the repository is dirty, " "the changes will not be stashed",
help="If set to true, then even if the repository is dirty, the changes will not be stashed",
)
@click.pass_context
def run(ctx: click.Context, **kwargs: Any) -> None:
Expand Down Expand Up @@ -105,16 +109,18 @@ def matrix(ctx: click.Context, quiet: bool, **kwargs: Any) -> None:
nargs=1,
required=True,
multiple=True,
help="Command that is being profiled. Either corresponds to some"
" script, binary or command, e.g. ``./mybin`` or ``perun``.",
help=(
"Command that is being profiled. Either corresponds to some"
" script, binary or command, e.g. ``./mybin`` or ``perun``."
),
)
@click.option(
"--args",
"-a",
nargs=1,
required=False,
multiple=True,
help="Additional parameters for <cmd>. E.g. ``status`` or " "``-al`` is command parameter.",
help="Additional parameters for <cmd>. E.g. ``status`` or ``-al`` is command parameter.",
)
@click.option(
"--workload",
Expand All @@ -123,7 +129,7 @@ def matrix(ctx: click.Context, quiet: bool, **kwargs: Any) -> None:
required=False,
multiple=True,
default=[""],
help="Inputs for <cmd>. E.g. ``./subdir`` is possible workload" "for ``ls`` command.",
help="Inputs for <cmd>. E.g. ``./subdir`` is possible workloadfor ``ls`` command.",
)
@click.option(
"--collector",
Expand All @@ -132,7 +138,7 @@ def matrix(ctx: click.Context, quiet: bool, **kwargs: Any) -> None:
required=True,
multiple=True,
type=click.Choice(utils.get_supported_module_names("collect")),
help="Profiler used for collection of profiling data for the" " given <cmd>",
help="Profiler used for collection of profiling data for the given <cmd>",
)
@click.option(
"--collector-params",
Expand All @@ -141,7 +147,7 @@ def matrix(ctx: click.Context, quiet: bool, **kwargs: Any) -> None:
required=False,
multiple=True,
callback=cli_helpers.yaml_param_callback,
help="Additional parameters for the <collector> read from the" " file in YAML format",
help="Additional parameters for the <collector> read from the file in YAML format",
)
@click.option(
"--postprocessor",
Expand All @@ -150,8 +156,10 @@ def matrix(ctx: click.Context, quiet: bool, **kwargs: Any) -> None:
required=False,
multiple=True,
type=click.Choice(utils.get_supported_module_names("postprocess")),
help="After each collection of data will run <postprocessor> to "
"postprocess the collected resources.",
help=(
"After each collection of data will run <postprocessor> to "
"postprocess the collected resources."
),
)
@click.option(
"--postprocessor-params",
Expand All @@ -160,7 +168,7 @@ def matrix(ctx: click.Context, quiet: bool, **kwargs: Any) -> None:
required=False,
multiple=True,
callback=cli_helpers.yaml_param_callback,
help="Additional parameters for the <postprocessor> read from the" " file in YAML format",
help="Additional parameters for the <postprocessor> read from the file in YAML format",
)
@click.pass_context
def job(ctx: click.Context, **kwargs: Any) -> None:
Expand Down
32 changes: 21 additions & 11 deletions perun/cli_groups/utils_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ def utils_group() -> None:
"-ne",
default=False,
is_flag=True,
help="Will open the newly created files in the editor specified by "
":ckey:`general.editor` configuration key.",
help=(
"Will open the newly created files in the editor specified by "
":ckey:`general.editor` configuration key."
),
)
@click.option(
"--supported-type",
Expand Down Expand Up @@ -143,8 +145,10 @@ def temp_list(root: str, **kwargs: Any) -> None:
"-w",
flag_value=True,
default=False,
help="Warn the user (and abort the deletion with no files deleted) if protected files"
" are present.",
help=(
"Warn the user (and abort the deletion with no files deleted) if protected files"
" are present."
),
)
@click.option(
"--force",
Expand All @@ -158,7 +162,7 @@ def temp_list(root: str, **kwargs: Any) -> None:
"-k",
flag_value=True,
default=False,
help="If path refers to directory, empty tmp/ directories and subdirectories " "will be kept.",
help="If path refers to directory, empty tmp/ directories and subdirectories will be kept.",
)
def temp_delete(path: str, warn: bool, force: bool, **kwargs: Any) -> None:
"""Deletes the temporary file or directory.
Expand Down Expand Up @@ -200,8 +204,10 @@ def stats_group() -> None:
type=int,
default=stats.DEFAULT_STATS_LIST_TOP,
show_default=True,
help="Show only stat files from top N minor versions. Show all results if set to 0. "
"The minor version to start at can be changed using --from-minor.",
help=(
"Show only stat files from top N minor versions. Show all results if set to 0. "
"The minor version to start at can be changed using --from-minor."
),
)
@click.option(
"--from-minor",
Expand Down Expand Up @@ -257,8 +263,10 @@ def stats_list_files(**kwargs: Any) -> None:
type=int,
default=stats.DEFAULT_STATS_LIST_TOP,
show_default=True,
help="Show only top N minor versions. Show all versions if set to 0. "
"The minor version to start at can be changed using --from-minor.",
help=(
"Show only top N minor versions. Show all versions if set to 0. "
"The minor version to start at can be changed using --from-minor."
),
)
@click.option(
"--from-minor",
Expand Down Expand Up @@ -322,8 +330,10 @@ def stats_delete_group() -> None:
metavar="<hash>",
is_eager=True,
callback=cli_helpers.check_stats_minor_callback,
help="Delete the stats file in the specified minor version (HEAD if not specified) "
'or across all the minor versions if set to ".".',
help=(
"Delete the stats file in the specified minor version (HEAD if not specified) "
'or across all the minor versions if set to ".".'
),
)
@click.option(
"--keep-directory",
Expand Down
6 changes: 4 additions & 2 deletions perun/collect/bounds/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ def lookup_source_files(ctx: click.Context, __: click.Option, value: list[str])
multiple=True,
metavar="<dir>",
callback=lookup_source_files,
help="Directory, where source C files are stored. All of the existing files with "
"valid extensions (.c).",
help=(
"Directory, where source C files are stored. All of the existing files with "
"valid extensions (.c)."
),
)
def bounds(ctx: click.Context, **kwargs: Any) -> None:
"""Generates `memory` performance profile, capturing memory allocations of
Expand Down
15 changes: 9 additions & 6 deletions perun/collect/complexity/makefiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ def _link_libraries(cmake_file: TextIO, library_vars: list[str], target_name: st
libraries = " ".join("${{{0}}}".format(lib) for lib in library_vars)
# Create the target
cmake_file.write(
f"\n# Link the libraries to the target\n"
f"target_link_libraries({target_name} {libraries})\n"
f"\n# Link the libraries to the target\ntarget_link_libraries({target_name} {libraries})\n"
)


Expand All @@ -239,16 +238,20 @@ def _get_libs_path() -> str:
libs_dir = os.path.join(os.path.dirname(__file__), "lib")
if not _libraries_exist(libs_dir):
log.cprintln(
"\nOne or more required libraries are missing - please compile them, "
"otherwise the data collection will not work.",
(
"\nOne or more required libraries are missing - please compile them, "
"otherwise the data collection will not work."
),
"white",
)
return libs_dir
except NameError:
# If the __file__ is not available, the user has to supply the libraries manually
log.cprintln(
"\nUnable to locate the directory with profiling libraries automatically, "
'please supply them manually into the "--target-dir" location',
(
"\nUnable to locate the directory with profiling libraries automatically, "
'please supply them manually into the "--target-dir" location'
),
"white",
)
return "${CMAKE_SOURCE_DIR}"
Expand Down
16 changes: 10 additions & 6 deletions perun/collect/complexity/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def _validate_input(**kwargs: Any) -> None:
os.makedirs(target_dir)
if os.path.exists(target_dir) and not os.path.isdir(target_dir):
raise click.exceptions.BadParameter(
"The given --target-dir already exists and " "is not a directory"
"The given --target-dir already exists and is not a directory"
)
if not kwargs["files"]:
raise click.exceptions.BadParameter("At least one --files parameter must be supplied.")
Expand Down Expand Up @@ -301,18 +301,22 @@ def _sampling_to_dictionary(
"-f",
type=click.Path(exists=True, resolve_path=True),
multiple=True,
help="List of C/C++ source files that will be used to build the"
" custom binary with injected profiling commands. Must be valid"
" resolvable path",
help=(
"List of C/C++ source files that will be used to build the"
" custom binary with injected profiling commands. Must be valid"
" resolvable path"
),
)
@click.option("--rules", "-r", type=str, multiple=True, help="Marks the function for profiling.")
@click.option(
"--internal-data-filename",
"-if",
type=str,
default=configurator.DEFAULT_DATA_FILENAME,
help="Sets the different path for internal output filename for"
" storing temporary profiling data file name.",
help=(
"Sets the different path for internal output filename for"
" storing temporary profiling data file name."
),
)
@click.option(
"--internal-storage-size",
Expand Down
18 changes: 11 additions & 7 deletions perun/collect/memory/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,27 +142,31 @@ def after(
"-s",
default=DEFAULT_SAMPLING,
type=click.FLOAT,
help="Sets the sampling interval for profiling the allocations."
" I.e. memory snapshots will be collected each <sampling>"
" seconds.",
help=(
"Sets the sampling interval for profiling the allocations."
" I.e. memory snapshots will be collected each <sampling>"
" seconds."
),
)
@click.option(
"--no-source",
multiple=True,
help="Will exclude allocations done from <no_source> file during" " the profiling.",
help="Will exclude allocations done from <no_source> file during the profiling.",
)
@click.option(
"--no-func",
multiple=True,
help="Will exclude allocations done by <no func> function during" " the profiling.",
help="Will exclude allocations done by <no func> function during the profiling.",
)
@click.option(
"--all",
"-a",
is_flag=True,
default=False,
help="Will record the full trace for each allocation, i.e. it"
" will include all allocators and even unreachable records.",
help=(
"Will record the full trace for each allocation, i.e. it"
" will include all allocators and even unreachable records."
),
)
@click.pass_context
def memory(ctx: click.Context, **kwargs: Any) -> None:
Expand Down
Loading

0 comments on commit 2953db9

Please sign in to comment.