Skip to content

Commit 63c4243

Browse files
authored
v0.9.0 (#11)
1 parent 18c14cd commit 63c4243

File tree

7 files changed

+244
-117
lines changed

7 files changed

+244
-117
lines changed

README.md

Lines changed: 216 additions & 109 deletions
Large diffs are not rendered by default.

mlops-python-package.code-workspace

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"ms-python.mypy-type-checker",
2626
"ms-python.python",
2727
"ms-python.vscode-pylance",
28+
"redhat.vscode-yaml",
2829
]
2930
}
3031
}

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
[tool.poetry]
66
name = "bikes"
7-
version = "0.8.0"
7+
version = "0.9.0"
88
description = "Predict the number of bikes available."
99
repository = "https://github.com/fmind/mlops-python-package"
1010
documentation = "https://fmind.github.io/mlops-python-package/"
@@ -89,6 +89,7 @@ plugins = ["pandera.mypy", "pydantic.mypy"]
8989

9090
[tool.pytest.ini_options]
9191
addopts = "--verbosity=2"
92+
pythonpath = ["src"]
9293

9394
[tool.ruff]
9495
fix = true

src/bikes/scripts.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ def main(argv: list[str] | None = None) -> int:
2626
schema = settings.MainSettings.model_json_schema()
2727
json.dump(schema, sys.stdout, indent=4)
2828
return 0
29-
files = map(configs.parse_file, args.files)
30-
strings = map(configs.parse_string, args.extras)
29+
files = [configs.parse_file(file) for file in args.files]
30+
strings = [configs.parse_string(string) for string in args.extras]
31+
if len(files) == 0 and len(strings) == 0:
32+
raise RuntimeError("No configs provided.")
3133
config = configs.merge_configs([*files, *strings])
3234
object_ = configs.to_object(config) # python object
3335
setting = settings.MainSettings.model_validate(object_)

tasks/checks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test(ctx: Context) -> None:
3939

4040

4141
@task
42-
def bandit(ctx: Context) -> None:
42+
def security(ctx: Context) -> None:
4343
"""Check the security with bandit."""
4444
ctx.run("poetry run bandit --recursive --configfile=pyproject.toml src/")
4545

@@ -50,6 +50,6 @@ def coverage(ctx: Context) -> None:
5050
ctx.run("poetry run pytest --numprocesses='auto' --cov=src/ --cov-fail-under=80 tests/")
5151

5252

53-
@task(pre=[poetry, format, type, code, bandit, coverage], default=True)
53+
@task(pre=[poetry, format, type, code, security, coverage], default=True)
5454
def all(_: Context) -> None:
5555
"""Run all check tasks."""

tasks/formats.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@
99

1010

1111
@task
12-
def code(ctx: Context) -> None:
13-
"""Format python code with ruff."""
12+
def imports(ctx: Context) -> None:
13+
"""Format python imports with ruff."""
14+
ctx.run("poetry run ruff check --select I --fix")
15+
16+
17+
@task
18+
def sources(ctx: Context) -> None:
19+
"""Format python sources with ruff."""
1420
ctx.run("poetry run ruff format src/ tasks/ tests/")
1521

1622

17-
@task(pre=[code], default=True)
23+
@task(pre=[imports, sources], default=True)
1824
def all(_: Context) -> None:
1925
"""Run all format tasks."""

tests/test_scripts.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,13 @@ def test_main(scenario: str, confs_path: str, extra_config: str) -> None:
4646
status = scripts.main(argv=argv)
4747
# then
4848
assert status == 0, f"Job should succeed for config: {config}"
49+
50+
51+
def test_main__no_configs() -> None:
52+
# given
53+
argv: list[str] = []
54+
# when
55+
with pytest.raises(RuntimeError) as error:
56+
scripts.main(argv)
57+
# then
58+
assert error.match("No configs provided."), "RuntimeError should be raised!"

0 commit comments

Comments
 (0)