.. image:: https://img.shields.io/pypi/l/Wilt.svg
:target: https://spdx.org/licenses/GPL-3.0-or-later.html
:alt: PyPI - License
.. image:: https://heptapod.host/saajns/wilt/badges/branch/default/pipeline.svg
:target: https://heptapod.host/saajns/wilt/-/commits/branch/default
:alt: Pipeline status
.. image:: https://heptapod.host/saajns/wilt/badges/branch/default/coverage.svg
:target: https://heptapod.host/saajns/wilt/-/commits/branch/default
:alt: Test code coverage
.. image:: https://badge.fury.io/py/Wilt.svg
:target: https://pypi.python.org/pypi/Wilt
:alt: PyPI
****
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:
.. code:: python
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.
.. note::
Each table is expected to have ``{table_name}_id`` and ``created_at``
columns.
GitLab CI visualisation
-----------------------
Assuming the following pipeline synchronisation:
.. code:: python
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.
____
.. [1] https://www.youtube.com/watch?v=W44Ub5ykBY4
.. [2] https://web.archive.org/web/20170331000730/http://ticosa.org/output/Robert%20Smallshire-Confronting%20Complexity-%20TICOSA%202014.pdf
Raw data
{
"_id": null,
"home_page": "https://heptapod.host/saajns/wilt",
"name": "Wilt",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "code-metrics code-quality continuous-integration",
"author": "saaj",
"author_email": "mail@saaj.me",
"download_url": "https://files.pythonhosted.org/packages/c9/e5/e22f03e228eb4076e745a0659f1d4e4c6ba19ad935ac18a73faa20bd24a6/Wilt-0.0.2.tar.gz",
"platform": null,
"description": ".. image:: https://img.shields.io/pypi/l/Wilt.svg\n :target: https://spdx.org/licenses/GPL-3.0-or-later.html\n :alt: PyPI - License\n.. image:: https://heptapod.host/saajns/wilt/badges/branch/default/pipeline.svg\n :target: https://heptapod.host/saajns/wilt/-/commits/branch/default\n :alt: Pipeline status\n.. image:: https://heptapod.host/saajns/wilt/badges/branch/default/coverage.svg\n :target: https://heptapod.host/saajns/wilt/-/commits/branch/default\n :alt: Test code coverage\n.. image:: https://badge.fury.io/py/Wilt.svg\n :target: https://pypi.python.org/pypi/Wilt\n :alt: PyPI\n\n****\nWilt\n****\nWilt is an architect's collection of codebase health probes. The name of the\npackage is inspired by the simplest possible code metric::\n\n W Whitespace\n I Integrated over\n L Lines of\n T Text\n\nIt comes from a great talk by Robert Smallshire called Confronting Complexity\n[1]_ [2]_. In the talk there are a few other ideas for codebase health analysis\nand visualisation that inspire development of this package.\n\nInstall with::\n\n pipx install Wilt\n\nCode quality\n============\nWilt\n----\nAn implementation of WILT itself. The metric can be calculated like::\n\n $ wilt cq.wilt /usr/lib/python3.12/unittest/case.py\n 2677.75\n\n $ wilt cq.wilt '/usr/lib/python3.12/**/*.py'\n 346219.0\n\n $ echo \" foo\" | wilt cq.wilt -i 2 -\n 2.0\n\nContinuous integration\n======================\nREST HTTP API resource synchronisation\n--------------------------------------\nThis feature allows synchronising collections of CI HTTP API resources in a\nSQLite database for analysis in SQL. The main use case is GitLab CI\npipelines. Create a file called ``resmapfile.py`` like the following:\n\n.. code:: python\n\n from wilt.resdb import resmap_api as rm\n\n\n api = rm.Api(\n base_url='https://gitlab.com/api/v4/projects/4961127',\n default_headers={'PRIVATE-TOKEN': 'S3Cr3t'},\n )\n\n resources = [\n rm.Resmap(\n rm.SourceResourceCollection(\n '/jobs',\n request_params={'per_page': 100, 'sort': 'desc'},\n resource_id_key='id',\n resource_timestamp_key='created_at',\n ),\n rm.TargetTable(\n 'job',\n extract_columns=[\n rm.ExtractColumn(\n 'id', rm.ColumnType.integer, name='job_id', pk=True\n ),\n rm.ExtractColumn('name', rm.ColumnType.text),\n rm.ExtractColumn('created_at', rm.ColumnType.datetime),\n rm.ExtractColumn('duration', rm.ColumnType.numeric),\n rm.ExtractColumn('status', rm.ColumnType.text),\n rm.ExtractColumn('pipeline.id', rm.ColumnType.integer),\n ],\n ),\n load_interval=rm.timedelta(days=2 * 365),\n sync_lookbehind=rm.timedelta(hours=6),\n ),\n ]\n\nThen run ``wilt -v ci.rest sync-db`` to create and then synchronise a SQLite\ndatabase with the HTTP API resources according to the mapping.\n\n.. note::\n\n Each table is expected to have ``{table_name}_id`` and ``created_at``\n columns.\n\nGitLab CI visualisation\n-----------------------\nAssuming the following pipeline synchronisation:\n\n.. code:: python\n\n resources = [\n rm.Resmap(\n rm.SourceResourceCollection(\n '/pipelines',\n request_params={'per_page': 10, 'sort': 'desc'},\n page_size=10,\n ),\n rm.TargetTable(\n 'pipeline_short',\n extract_columns=[\n rm.ExtractColumn(\n 'id', rm.ColumnType.integer, name='pipeline_short_id', pk=True\n ),\n rm.ExtractColumn('created_at', rm.ColumnType.datetime),\n ],\n ),\n subresources=[\n rm.SubResmap(\n rm.SourceSubresource('/pipelines/{id}', 'pipeline_id'),\n rm.TargetTable(\n 'pipeline',\n extract_columns=[\n rm.ExtractColumn(\n 'id', rm.ColumnType.integer, name='pipeline_id', pk=True\n ),\n rm.ExtractColumn('created_at', rm.ColumnType.datetime),\n rm.ExtractColumn('duration', rm.ColumnType.numeric),\n rm.ExtractColumn('ref', rm.ColumnType.text),\n ],\n ),\n ),\n ],\n ),\n ]\n\nthe pipeline runtime can be visualised with a command like::\n\n wilt ci.gitlab pipeline-runtime --clamp-max 3600 --after 2023-01-01T00:00:00\n\nThis produces ``plot.html`` file with interactive Plotly visualisation. See\n``wilt ci.gitlab pipeline-runtime --help`` for more details.\n\n____\n\n.. [1] https://www.youtube.com/watch?v=W44Ub5ykBY4\n.. [2] https://web.archive.org/web/20170331000730/http://ticosa.org/output/Robert%20Smallshire-Confronting%20Complexity-%20TICOSA%202014.pdf\n",
"bugtrack_url": null,
"license": "GPL-3.0-or-later",
"summary": "Architect's collection of codebase health probes",
"version": "0.0.2",
"project_urls": {
"Homepage": "https://heptapod.host/saajns/wilt"
},
"split_keywords": [
"code-metrics",
"code-quality",
"continuous-integration"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1feb17e5751a3f2ddd124f3aba41c45a07325f898429300eeba7470c1fdb1dba",
"md5": "381180968ab6bd7d47d1196042209c6c",
"sha256": "720cd6467fc60084fb7d76714c5f8f014732b0019043a74a157a08d3844b6894"
},
"downloads": -1,
"filename": "Wilt-0.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "381180968ab6bd7d47d1196042209c6c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 21062,
"upload_time": "2024-07-18T16:31:46",
"upload_time_iso_8601": "2024-07-18T16:31:46.861354Z",
"url": "https://files.pythonhosted.org/packages/1f/eb/17e5751a3f2ddd124f3aba41c45a07325f898429300eeba7470c1fdb1dba/Wilt-0.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c9e5e22f03e228eb4076e745a0659f1d4e4c6ba19ad935ac18a73faa20bd24a6",
"md5": "8a97014808c487b1daf54b32a6634fd8",
"sha256": "3fc455e155a1fd8c7e888ced0f5c45096ff3ab93d219d36eccc9dea1139e5b0f"
},
"downloads": -1,
"filename": "Wilt-0.0.2.tar.gz",
"has_sig": false,
"md5_digest": "8a97014808c487b1daf54b32a6634fd8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 18761,
"upload_time": "2024-07-18T16:31:48",
"upload_time_iso_8601": "2024-07-18T16:31:48.289862Z",
"url": "https://files.pythonhosted.org/packages/c9/e5/e22f03e228eb4076e745a0659f1d4e4c6ba19ad935ac18a73faa20bd24a6/Wilt-0.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-18 16:31:48",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "wilt"
}