Wilt
Wilt is an architect’s collection of codebase health probes. The name of the package is inspired by the simplest possible code metric:
W Whitespace I Integrated over L Lines of T Text
It comes from a great talk by Robert Smallshire called Confronting Complexity [1] [2]. In the talk there are a few other ideas for codebase health analysis and visualisation that inspire development of this package.
Install with:
pipx install Wilt
Code quality
Wilt
An implementation of WILT itself. The metric can be calculated like:
$ wilt cq.wilt /usr/lib/python3.12/unittest/case.py 2677.75 $ wilt cq.wilt '/usr/lib/python3.12/**/*.py' 346219.0 $ echo " foo" | wilt cq.wilt -i 2 - 2.0
Continuous integration
REST HTTP API resource synchronisation
This feature allows synchronising collections of CI HTTP API resources in a SQLite database for analysis in SQL. The main use case is GitLab CI pipelines. Create a file called resmapfile.py like the following:
from wilt.resdb import resmap_api as rm
api = rm.Api(
base_url='https://gitlab.com/api/v4/projects/4961127',
default_headers={'PRIVATE-TOKEN': 'S3Cr3t'},
)
resources = [
rm.Resmap(
rm.SourceResourceCollection(
'/jobs',
request_params={'per_page': 100, 'sort': 'desc'},
resource_id_key='id',
resource_timestamp_key='created_at',
),
rm.TargetTable(
'job',
extract_columns=[
rm.ExtractColumn(
'id', rm.ColumnType.integer, name='job_id', pk=True
),
rm.ExtractColumn('name', rm.ColumnType.text),
rm.ExtractColumn('created_at', rm.ColumnType.datetime),
rm.ExtractColumn('duration', rm.ColumnType.numeric),
rm.ExtractColumn('status', rm.ColumnType.text),
rm.ExtractColumn('pipeline.id', rm.ColumnType.integer),
],
),
load_interval=rm.timedelta(days=2 * 365),
sync_lookbehind=rm.timedelta(hours=6),
),
]
Then run wilt -v ci.rest sync-db to create and then synchronise a SQLite database with the HTTP API resources according to the mapping.
GitLab CI visualisation
Assuming the following pipeline synchronisation:
resources = [
rm.Resmap(
rm.SourceResourceCollection(
'/pipelines',
request_params={'per_page': 10, 'sort': 'desc'},
page_size=10,
),
rm.TargetTable(
'pipeline_short',
extract_columns=[
rm.ExtractColumn(
'id', rm.ColumnType.integer, name='pipeline_short_id', pk=True
),
rm.ExtractColumn('created_at', rm.ColumnType.datetime),
],
),
subresources=[
rm.SubResmap(
rm.SourceSubresource('/pipelines/{id}', 'pipeline_id'),
rm.TargetTable(
'pipeline',
extract_columns=[
rm.ExtractColumn(
'id', rm.ColumnType.integer, name='pipeline_id', pk=True
),
rm.ExtractColumn('created_at', rm.ColumnType.datetime),
rm.ExtractColumn('duration', rm.ColumnType.numeric),
rm.ExtractColumn('ref', rm.ColumnType.text),
],
),
),
],
),
]
the pipeline runtime can be visualised with a command like:
wilt ci.gitlab pipeline-runtime --clamp-max 3600 --after 2023-01-01T00:00:00
This produces plot.html file with interactive Plotly visualisation. See wilt ci.gitlab pipeline-runtime --help for more details.
Metadata
Release files for Wilt 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Wilt-0.0.2.tar.gz | 18.8 kB | Without provenance | Details for Wilt-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Wilt-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for Wilt-0.0.2-py3-none-any.whl |
Total release size: 39.8 kB
Release files / Wilt-0.0.2.tar.gz
| Download URL | Wilt-0.0.2.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3fc455e155a1fd8c7e888ced0f5c45096ff3ab93d219d36eccc9dea1139e5b0f
|
|
BLAKE2b-256 checksum How to use checksums |
c9e5e22f03e228eb4076e745a0659f1d4e4c6ba19ad935ac18a73faa20bd24a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.7
|
Release files / Wilt-0.0.2-py3-none-any.whl
| Download URL | Wilt-0.0.2-py3-none-any.whl |
|---|---|
| Size | 21.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
720cd6467fc60084fb7d76714c5f8f014732b0019043a74a157a08d3844b6894
|
|
BLAKE2b-256 checksum How to use checksums |
1feb17e5751a3f2ddd124f3aba41c45a07325f898429300eeba7470c1fdb1dba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.7
|
Security for Wilt 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.