feat: adds click cli app
This commit is contained in:
parent
1264c2145e
commit
3b7dfd2462
13
poetry.lock
generated
13
poetry.lock
generated
@ -55,7 +55,7 @@ uvloop = ["uvloop (>=0.15.2)"]
|
|||||||
name = "click"
|
name = "click"
|
||||||
version = "8.1.7"
|
version = "8.1.7"
|
||||||
description = "Composable command line interface toolkit"
|
description = "Composable command line interface toolkit"
|
||||||
category = "dev"
|
category = "main"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.7"
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
@ -66,13 +66,13 @@ colorama = {version = "*", markers = "platform_system == \"Windows\""}
|
|||||||
name = "colorama"
|
name = "colorama"
|
||||||
version = "0.4.6"
|
version = "0.4.6"
|
||||||
description = "Cross-platform colored terminal text."
|
description = "Cross-platform colored terminal text."
|
||||||
category = "dev"
|
category = "main"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
|
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "coverage"
|
name = "coverage"
|
||||||
version = "7.3.2"
|
version = "7.4.4"
|
||||||
description = "Code coverage measurement for Python"
|
description = "Code coverage measurement for Python"
|
||||||
category = "dev"
|
category = "dev"
|
||||||
optional = false
|
optional = false
|
||||||
@ -492,7 +492,7 @@ python-versions = "*"
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "1.1"
|
lock-version = "1.1"
|
||||||
python-versions = ">=3.8.1,<3.10"
|
python-versions = ">=3.8.1,<3.10"
|
||||||
content-hash = "b5275c33449e8f85acbf9c0f6dfe1ec4e7296adfa16360d782b33534e1223638"
|
content-hash = "66c63e7a7a61bc34880f47e2568e2407f330c2691dabc0dace9aa15f03a97531"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
appnope = []
|
appnope = []
|
||||||
@ -510,10 +510,7 @@ iniconfig = []
|
|||||||
ipython = []
|
ipython = []
|
||||||
jedi = []
|
jedi = []
|
||||||
matplotlib-inline = []
|
matplotlib-inline = []
|
||||||
mccabe = [
|
mccabe = []
|
||||||
{file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"},
|
|
||||||
{file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"},
|
|
||||||
]
|
|
||||||
mypy = []
|
mypy = []
|
||||||
mypy-extensions = []
|
mypy-extensions = []
|
||||||
numpy = []
|
numpy = []
|
||||||
|
@ -10,6 +10,7 @@ readme = "README.md"
|
|||||||
python = ">=3.8.1,<3.10"
|
python = ">=3.8.1,<3.10"
|
||||||
numpy = "^1.22.3"
|
numpy = "^1.22.3"
|
||||||
scipy = "~1.10"
|
scipy = "~1.10"
|
||||||
|
click = "^8.1.7"
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
pytest = ">=6"
|
pytest = ">=6"
|
||||||
@ -40,3 +41,6 @@ module = [
|
|||||||
"scipy.optimize"
|
"scipy.optimize"
|
||||||
]
|
]
|
||||||
ignore_missing_imports = true
|
ignore_missing_imports = true
|
||||||
|
|
||||||
|
[tool.poetry.scripts]
|
||||||
|
tantri = "tantri.cli:cli"
|
||||||
|
34
tantri/cli/__init__.py
Executable file
34
tantri/cli/__init__.py
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
import click
|
||||||
|
import logging
|
||||||
|
import tantri
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
LOG_PATTERN = "%(asctime)s | %(levelname)-7s | %(name)s | %(message)s"
|
||||||
|
|
||||||
|
|
||||||
|
def _set_up_logging(filename):
|
||||||
|
logging.basicConfig(
|
||||||
|
level=logging.DEBUG,
|
||||||
|
format=LOG_PATTERN,
|
||||||
|
handlers=[logging.StreamHandler(), logging.FileHandler(filename)],
|
||||||
|
)
|
||||||
|
logging.getLogger("pdme").setLevel(logging.INFO)
|
||||||
|
logging.captureWarnings(True)
|
||||||
|
|
||||||
|
|
||||||
|
@click.group()
|
||||||
|
@click.version_option(tantri.get_version())
|
||||||
|
@click.option("--log-file", help="A filename to use for logging")
|
||||||
|
def cli(log_file):
|
||||||
|
print("hi")
|
||||||
|
if log_file is not None:
|
||||||
|
# log file has been provided, let's log
|
||||||
|
_set_up_logging(log_file)
|
||||||
|
_logger.info("cli")
|
||||||
|
|
||||||
|
|
||||||
|
@cli.command()
|
||||||
|
def hello():
|
||||||
|
_logger.info("in hello")
|
||||||
|
print("in hello")
|
15
tantri/cli/file_importer.py
Executable file
15
tantri/cli/file_importer.py
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
import json
|
||||||
|
import logging
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# note that json is insecure by default right?
|
||||||
|
# but don't worry for now
|
||||||
|
# TODO: if this ever matters, can improve file handling.
|
||||||
|
|
||||||
|
|
||||||
|
def read_json_file(filename):
|
||||||
|
try:
|
||||||
|
return json.load(filename)
|
||||||
|
except Exception:
|
||||||
|
_logger.exception(f"failed on reading filename {filename}")
|
1
tantri/cli/input_files/json_dots.py
Executable file
1
tantri/cli/input_files/json_dots.py
Executable file
@ -0,0 +1 @@
|
|||||||
|
import tantri
|
@ -32,8 +32,8 @@ class Dipole:
|
|||||||
|
|
||||||
# For caching purposes tell each dipole where the dots are
|
# For caching purposes tell each dipole where the dots are
|
||||||
# TODO: This can be done better by only passing into the time series the non-repeated p s and w,
|
# TODO: This can be done better by only passing into the time series the non-repeated p s and w,
|
||||||
# and then creating a new wrapper type to include all the cached stuff.
|
# TODO: and then creating a new wrapper type to include all the cached stuff.
|
||||||
# Realistically, the dot positions and measurement type data should live in the time series.
|
# TODO: Realistically, the dot positions and measurement type data should live in the time series.
|
||||||
dot_positions: typing.Sequence[DotPosition]
|
dot_positions: typing.Sequence[DotPosition]
|
||||||
|
|
||||||
measurement_type: DipoleMeasurementType
|
measurement_type: DipoleMeasurementType
|
||||||
|
0
tests/cli/test_read_dots_json.py
Executable file
0
tests/cli/test_read_dots_json.py
Executable file
Loading…
x
Reference in New Issue
Block a user