Skip to content

Commit

Permalink
change entrypoint, fix verbosity settings
Browse files Browse the repository at this point in the history
  • Loading branch information
KRiedmiller committed Feb 28, 2025
1 parent 083a050 commit 56fa1e5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ classifiers = [
]

[project.scripts]
helios = "helios.__main__:helios_entrypoint"
helios = "helios.__main__:cli"

[tool.scikit-build]
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
Expand Down
47 changes: 28 additions & 19 deletions python/helios/__main__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
from datetime import datetime
import click
from click_option_group import optgroup, MutuallyExclusiveOptionGroup
import sys
from helios.settings import ExecutionSettings, OutputSettings
from helios.settings import ExecutionSettings, OutputSettings, LogVerbosity
from helios.survey import Survey
from helios.utils import add_asset_directory, set_rng_seed


def helios_entrypoint():
# raise SystemExit(helios_exec(sys.argv[1:]))
raise SystemExit(cli(sys.argv[1:]))


@click.command()
@click.argument("survey_file_path", required=True)
@optgroup.group("Input")
Expand Down Expand Up @@ -264,21 +257,25 @@ def helios_entrypoint():
"By default: logging will be outputted to standard output."
),
)
@optgroup.group("Verbosity", cls=MutuallyExclusiveOptionGroup)
@optgroup.option(
"--silent",
is_flag=True,
help=("Disable logging output."),
)
@click.version_option()
@click.option(
"-v",
"--verbose",
"-v",
count=True,
help=(
"Increase the verbosity level to include warnings. Can be repeated "
"once to report all messages. Default: report errors only."
"Increase the verbosity level to include information. Can be repeated "
"once to report all messages. Default: report errors and warnings."
),
)
@optgroup.option(
"--silent",
"-s",
is_flag=True,
help=("Disable all logging output."),
)
@optgroup.option("--quiet", "-q", is_flag=True, help="Only errors are reported.")
@optgroup.option("--vt", is_flag=True, help="Report time and errors.")
@click.version_option()
def cli(**kw):

for asset in kw["assets"]:
Expand All @@ -289,6 +286,18 @@ def cli(**kw):
else:
set_rng_seed()

verbosity = LogVerbosity.DEFAULT
if kw.get("verbose") == 1:
verbosity = LogVerbosity.VERBOSE
elif kw.get("verbose") == 2:
verbosity = LogVerbosity.VERY_VERBOSE
elif kw.get("quiet"):
verbosity = LogVerbosity.QUIET
elif kw.get("vt"):
verbosity = LogVerbosity.TIME
elif kw.get("silent"):
verbosity = LogVerbosity.SILENT

output_settings = OutputSettings()
execution_settings = ExecutionSettings()

Expand All @@ -298,7 +307,7 @@ def cli(**kw):
execution_settings.warehouse_factor = kw.get("warehousefactor")
execution_settings.log_file = kw.get("logfile")
execution_settings.log_file_only = kw.get("logfileonly")
execution_settings.verbosity = kw.get("verbose")
execution_settings.verbosity = verbosity
execution_settings.factory_type = kw.get("kdt")
execution_settings.kdt_num_threads = kw.get("kdtjobs")
execution_settings.kdt_geom_num_threads = kw.get("kdtgeomjobs")
Expand All @@ -319,4 +328,4 @@ def cli(**kw):


if __name__ == "__main__":
helios_entrypoint()
raise cli()
9 changes: 6 additions & 3 deletions python/helios/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ class ParallelizationStrategy(IntEnum):


class LogVerbosity(IntEnum):
DEFAULT = 0
VERBOSE = 1
VERY_VERBOSE = 2
SILENT = 0b000000
QUIET = 0b100000
TIME = 0b101000
DEFAULT = 0b111000
VERBOSE = 0b111100
VERY_VERBOSE = 0b111111


class KDTreeFactoryType(IntEnum):
Expand Down

0 comments on commit 56fa1e5

Please sign in to comment.