Skip to content

Commit 9a1ef2c

Browse files
committed
chore: cleanup
1 parent cc0eb3b commit 9a1ef2c

File tree

9 files changed

+86
-159
lines changed

9 files changed

+86
-159
lines changed

.gitlab-ci.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.kiara_complete.zsh

Lines changed: 0 additions & 32 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,54 @@ default_language_version:
33

44
repos:
55

6+
# cleans out all jupyter notebook result cells for git commit
7+
- repo: https://github.com/srstevenson/nb-clean
8+
rev: 4.0.1
9+
hooks:
10+
- id: nb-clean
11+
12+
# makes sure the commit message adheres to the commitlint standard
613
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
7-
rev: 'v9.20.0'
14+
rev: 'v9.22.0'
815
hooks:
916
- id: commitlint
1017
stages: [commit-msg]
1118
additional_dependencies: ['@commitlint/config-conventional']
1219

20+
# runs the mypy type checker
1321
- repo: https://github.com/pre-commit/mirrors-mypy
14-
rev: 'v1.13.0' # Use the sha / tag you want to point at
22+
rev: 'v1.16.0' # Use the sha / tag you want to point at
1523
hooks:
1624
- id: mypy
17-
files: "^src/kiara"
25+
files: "^src/"
1826
pass_filenames: true
19-
args: ["--config-file", "pyproject.toml"]
20-
additional_dependencies: [pydantic>=2.0.0, pydantic_settings, rich>=10.0.0, ruamel.yaml, anyio>=3.0.0, pyzmq>=22.0.3, bidict, sqlalchemy-stubs, types-python-slugify, types-setuptools, types-python-dateutil, dag_cbor>=0.3.0, multiformats>=0.2.0, textual, regex, types-pytz, types-orjson, dag_cbor>=0.3.2]
27+
args: ["--config-file", "pyproject.toml", "--ignore-missing-imports"]
28+
additional_dependencies: [pydantic>=2.0.0, rich>=10.0.0, ruamel.yaml, anyio>=3.0.0, pyzmq>=22.0.3, bidict, sqlalchemy-stubs, types-python-slugify, types-setuptools, types-python-dateutil, dag_cbor, multiformats, textual, regex, types-pytz, types-orjson]
2129

30+
# runs the ruff linter and formater
2231
- repo: https://github.com/astral-sh/ruff-pre-commit
2332
# Ruff version.
24-
rev: v0.8.3
33+
rev: v0.11.13
2534
hooks:
26-
- id: ruff
35+
- id: ruff-check
2736
args: [ --fix ]
28-
# Run the formatter.
2937
- id: ruff-format
3038

39+
# misc tasks
3140
- repo: https://github.com/pre-commit/pre-commit-hooks
32-
rev: v4.6.0 # Use the ref you want to point at
41+
rev: 'v5.0.0'
3342
hooks:
3443
- id: trailing-whitespace
35-
exclude: '(setup.cfg|src/kiara/utils/cli/__init__.py)'
3644
- id: check-added-large-files
3745
- id: check-ast
3846
- id: check-json
3947
- id: check-merge-conflict
4048
- id: check-xml
4149
- id: check-yaml
42-
exclude: '(tests/\*|ci/conda/kiara/meta.yaml)'
50+
exclude: 'tests/\*'
4351
- id: debug-statements
4452
- id: end-of-file-fixer
45-
exclude: '(.*.json|.*.j2)'
53+
exclude: '.*.json'
4654
- id: requirements-txt-fixer
4755
- id: fix-encoding-pragma
4856
- id: mixed-line-ending

Makefile

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,14 @@
44
help:
55
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
66

7-
docs: ## build documentation
8-
mkdocs build
9-
10-
serve-docs: ## serve and watch documentation
11-
mkdocs serve --dirtyreload -a 0.0.0.0:8000
127

138
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
149

15-
clean-doc: ## remove doc artifacts
16-
rm -fr build/site
17-
1810
clean-build: ## remove build artifacts
1911
rm -fr build/
2012
rm -fr dist/
2113
rm -fr .eggs/
22-
find . -name '*.egg' -exec rm -fr {} +
14+
find . -name '*.egg' -exec rm -rf {} +
2315

2416
clean-pyc: ## remove Python file artifacts
2517
find . -name '*.pyc' -exec rm -f {} +
@@ -34,32 +26,37 @@ clean-test: ## remove test and coverage artifacts
3426
rm -fr .pytest_cache
3527
rm -fr .mypy_cache
3628

37-
init: clean ## initialize a development environment (to be run in virtualenv)
38-
git init
39-
git checkout -b develop || true
40-
pip install -U pip
41-
pip install --extra-index-url https://pypi.fury.io/dharpa/ --extra-index-url https://gitlab.com/api/v4/projects/25344049/packages/pypi/simple -U -e '.[all_dev]'
42-
pre-commit install
43-
pre-commit install --hook-type commit-msg
44-
setup-cfg-fmt setup.cfg || true
45-
git add "*" ".*"
46-
pre-commit run --all-files || true
47-
git add "*" ".*"
48-
4929
mypy: ## run mypy
50-
uv run mypy src/kiara
30+
uv run mypy --namespace-packages --explicit-package-base src/
31+
32+
lint:
33+
uv run ruff check --fix src/
34+
35+
format:
36+
uv run ruff format src/
5137

5238
test: ## run tests quickly with the default Python
5339
uv run pytest tests
5440

41+
docs:
42+
uv run mkdocs build
43+
44+
docs-serve:
45+
uv run mkdocs serve
46+
47+
check: lint mypy test ## run dev-related checks
48+
49+
pre-commit: ## run pre-commit on all files
50+
uv run pre-commit run --all-files
51+
5552
coverage: ## check code coverage quickly with the default Python
5653
coverage run -m pytest tests
5754
coverage report -m
5855
coverage html
5956
xdg-open htmlcov/index.html
6057

6158
render-api:
62-
kiara render --source-type base_api --target-type kiara_api item kiara_api template_file=src/kiara/interfaces/python_api/kiara_api.py target_file=src/kiara/interfaces/python_api/kiara_api.py
59+
uv run kiara render --source-type base_api --target-type kiara_api item kiara_api template_file=src/kiara/interfaces/python_api/kiara_api.py target_file=src/kiara/interfaces/python_api/kiara_api.py
6360

6461
pre-commit: ## run pre-commit on all files
6562
uv run pre-commit run --all-files

README.md

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,57 +24,54 @@ created metadata. Most of this is not yet implemented.
2424

2525
### Requirements
2626

27-
- Python (version >=3.6 -- some make targets only work for Python >=3.7, but *kiara* itself should work on 3.6)
28-
- pip, virtualenv
27+
- uv ( https://docs.astral.sh/uv/ )
2928
- git
30-
- make
31-
- [direnv](https://direnv.net/) (optional)
29+
- make (on Linux / Mac OS X -- optional)
3230

3331

34-
### Prepare development environment
32+
### Check out the source code & enter the project directory
3533

3634
```console
3735
git clone https://github.com/DHARPA-Project/kiara.git
3836
cd kiara
39-
python3 -m venv .venv
40-
source .venv/bin/activate
41-
make init
4237
```
4338

44-
If you use [direnv](https://direnv.net/), you can alternatively do:
39+
### Prepare development environment
4540

46-
``` console
47-
git clone https://github.com/DHARPA-Project/kiara.git
48-
cd kiara
49-
cp .envrc.disabled .envrc
50-
direnv allow
51-
make init
52-
```
41+
The recommended way to setup a development environment is to use [uv](https://docs.astral.sh/uv/). Check out [their install instructions](https://docs.astral.sh/uv/getting-started/installation/).
5342

54-
*Note*: you might want to adjust the Python version in ``.envrc`` (should not be necessary in most cases though)
43+
Once you have `uv` installed, you can either run `kiara` using the `uv run` command:
5544

56-
### ``make`` targets
45+
```
46+
uv run kiara module list
47+
```
48+
49+
or, activate the virtual environment and run `kiara` directly:
5750

58-
- ``init``: init development project (install project & dev dependencies into virtualenv, as well as pre-commit git hook)
59-
- ``update-modules``: update default kiara modules package from git
60-
- ``flake``: run *flake8* tests
61-
- ``mypy``: run *mypy* tests
62-
- ``test``: run unit tests
63-
- ``docs``: create static documentation pages (under ``build/site``)
64-
- ``serve-docs``: serve documentation pages (incl. auto-reload) for getting direct feedback when working on documentation
65-
- ``clean``: clean build directories
51+
```
52+
uv sync # to make sure the virtualenv exists (and is up to date)
53+
source .venv/bin/activate
54+
kiara module list
55+
```
6656

67-
For details (and other, minor targets), check the ``Makefile``.
57+
### Running pre-defined development-related tasks
6858

59+
The included `Makefile` file includes some useful tasks that help with development. This requires `uv` and the `make` tool to be
60+
installed, which should be the case for Linux & Mac OS X systems.
6961

70-
### Running tests
62+
- `make test`: runs the unit tests
63+
- `make mypy`: run mypy checks
64+
- `make lint`: run the `ruff` linter on the source code
65+
- `make format`: run the `ruff` formatter on the source code (similar to `black`)
66+
- `make docs`: build the documentation (into `build` folder)
67+
- `make docs-serve`: serve the documentation (on port 8000)
7168

72-
``` console
73-
> make test
74-
# or
75-
> make coverage
76-
```
69+
Alternatively, if you don't have the `make` command available, you can use `uv` directly to run those tasks:
7770

71+
- `uv run pytest tests`
72+
- `uv run mypy src/`
73+
- `uv run ruff check --fix src/`
74+
- `uv run ruff format src/`
7875

7976
## Copyright & license
8077

onboarding.folder_to_table.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ dependencies = [
7575
"tzlocal>=2.1,<6.0",
7676
"zstandard>=0.22.0",
7777
"airium>=0.2.7",
78+
"netext>=0.3.1",
7879
]
7980
dynamic = ["version"]
8081

@@ -441,6 +442,7 @@ module = [
441442
"jupytext",
442443
"lz4.*",
443444
"mmh3",
445+
"netext.*",
444446
"pickle5",
445447
"pip.*",
446448
"pp",

src/kiara/utils/cli/rich_click.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
USE_CLICK_SHORT_HELP,
5555
highlighter,
5656
)
57+
from rich_click.rich_help_formatter import RichHelpFormatter
5758
from rich_click.rich_help_rendering import (
5859
_get_option_help,
5960
_make_command_help,
@@ -303,12 +304,13 @@ class MetavarHighlighter(RegexHighlighter):
303304
]
304305

305306
metavar_highlighter = MetavarHighlighter()
307+
formatter = RichHelpFormatter()
306308
rows = [
307309
required,
308310
highlighter(highlighter(",".join(opt_long_strs))),
309311
highlighter(highlighter(",".join(opt_short_strs))),
310312
metavar_highlighter(metavar),
311-
_get_option_help(param, ctx), # type: ignore
313+
_get_option_help(param, ctx, formatter), # type: ignore
312314
]
313315

314316
# Remove metavar if specified in config

src/kiara/utils/graphs.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@
2525

2626
def print_ascii_graph(
2727
graph: nx.Graph, restart_interpreter_if_asciinet_installed: bool = False
28+
):
29+
from netext import ConsoleGraph, EdgeSegmentDrawingMode
30+
31+
nx.set_edge_attributes(
32+
graph, EdgeSegmentDrawingMode.ASCII, "$edge-segment-drawing-mode"
33+
)
34+
terminal_print(ConsoleGraph(graph))
35+
36+
37+
def print_ascii_graph_old(
38+
graph: nx.Graph, restart_interpreter_if_asciinet_installed: bool = False
2839
):
2940
try:
3041
from asciinet import graph_to_ascii # type: ignore

0 commit comments

Comments
 (0)