Skip to content

Commit 592b2b5

Browse files
committed
Update migration guide
1 parent 1bf14cb commit 592b2b5

File tree

3 files changed

+218
-35
lines changed

3 files changed

+218
-35
lines changed

doc/developer_guide/plugins.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
.. _plugin support:
2+
13
Plugin Support
24
==============
35

4-
Our tool currently provides plugin support for Nox tasks. The plugins dedicated to Nox tasks can be found
5-
within the :code:`exasol.toolbox.nox.plugins` namespace. To facilitate the implementation of this feature,
6+
Our tool currently provides plugin support for Nox tasks. The plugins dedicated to Nox tasks can be found
7+
within the :code:`exasol.toolbox.nox.plugins` namespace. To facilitate the implementation of this feature,
68
we utilize `pluggy <https://pluggy.readthedocs.io/en/stable/>`_, an extensible plugin system for Python.
79
At present, our usage of `pluggy` is confined to a selection of its capabilities.
8-
We mandate that plugins define and implement hooks, following which they must register their hook
10+
We mandate that plugins define and implement hooks, following which they must register their hook
911
implementations with the configuration object.
1012
For more information on hook configuration, refer to the :ref:`plugins` section in our User Guide.
1113

1214
It is essential for plugins to operate without raising exceptions. Plans are in place to handle exceptions more robustly in future releases.
1315
This entails capturing and logging any exceptions raised within the plugins, without disrupting the continued execution of the task at hand.
1416
The only exception to this rule applies to instances derived from `nox.error`, which are handled as specified.
15-
For additional insights into the handling of plugin exceptions, review the section on
17+
For additional insights into the handling of plugin exceptions, review the section on
1618
`hook wrappers <https://pluggy.readthedocs.io/en/stable/#wrappers>`_ in the `pluggy` documentation.

doc/user_guide/getting_started.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Your usage of the `exasol-toolbox` will likely fall into one of two scenarios:
99

1010
#. Creation of a new project.
1111

12-
If you are starting a new project, please read the section :ref:`Create a New Project with Exasol-Toolbox Support <new>`.
12+
If you are starting a new project, please read the section :ref:`Create a New Project with Exasol-Toolbox Support <new project>`.
1313

14-
.. _new:
14+
.. _new project:
1515

1616
Create a New Project with Exasol-Toolbox Support
1717
-------------------------------------------------
@@ -177,6 +177,8 @@ forward and you just can use the example *noxfile.py* bellow.
177177
178178
poetry run pre-commit install --hook-type pre-commit --hook-type pre-push
179179
180+
.. _toolbox tasks:
181+
180182
7. Go 🥜
181183
+++++++++++++
182184
You are ready to use the toolbox. With *nox -l* you can list all available tasks.
@@ -206,3 +208,7 @@ You are ready to use the toolbox. With *nox -l* you can list all available tasks
206208
207209
208210
Enjoy!
211+
212+
.. note::
213+
214+
The targets and their names may change over time, so the list below may not be up to date, as it is not automatically generated yet. Therefore, if you find discrepancies, please `submit a quick PR <https://github.com/exasol/python-toolbox/compare>`_ to address them.

doc/user_guide/migrating.rst

Lines changed: 204 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,141 @@ What a Project Should Have Before You Migrate
1414
* The project documentation should be :code:`sphinx` based **[Required]**.
1515
* Automated tasks within the project should be available as Python code or `Nox`_ tasks. **[Helpful]**
1616

17+
.. hint::
18+
19+
If you are interested or want to get a good idea of what a bare standard project based on the toolbox should have, excluding the workflows, it is always good to have a look at the `cookiecutter template <https://github.com/exasol/python-toolbox/tree/main/project-template>`_ provided by the toolbox. If the template parts are confusing, you can generate an "empty" project based on it. For details, refer to the :ref:`new project` section.
20+
1721

1822
Iterative Migration Guide
1923
++++++++++++++++++++++++++
2024

21-
Ensure you comply with the basic requirements for your project. Follow these steps for a smooth migration process.
25+
Ensure you comply with the :ref:`basic requirements <before_you_migrate>` for your project. Follow these steps for a smooth migration process.
2226

2327
1. Introduce Nox
2428
----------------
2529
As a first step, it is generally advisable to introduce `Nox`_ as a task runner if it is not already in use. Since the :code:`python-toolbox` uses `Nox`_ as its foundation, this simplifies the migration to the toolbox and enhances the user's understanding of `Nox`_.
2630

27-
2. Introduce Python-Toolbox Nox Tasks
28-
-------------------------------------
29-
This can be done incrementally for different checks of your project, such as linting, typing, documentation, and other tasks.
31+
2. Introduce the Standard Nox Tasks
32+
-----------------------------------
33+
This can be done incrementally for different checks of your project, such as *project*, *test*, *linting*, *documentation*, and *other* tasks.
34+
As the tasks can be split into roughly five groups, it likely makes sense to integrate at least one group at a time.
35+
For more details on the current tasks and groups, refer to: :ref:`toolbox tasks`.
36+
37+
38+
Overloading a Task
39+
__________________
40+
41+
In certain cases, it may not be trivial to use the nox task defined within the `python-toolbox`_. In those cases, overloads can be used to provide a smoother or faster transition or to cope with project-specific constraints or needs.
42+
43+
For example, if test execution isn't performed in the standard way (e.g., :code:`pytest test/unit`, :code:`pytest test/integration`, :code:`pytest test`).
44+
45+
.. warning::
46+
47+
While overwriting can be handy and seem like the simplest way to integrate with the toolbox, please take care when making this decision. In the long run, we want to harmonize projects, their builds, execution, testing, and reporting, etc. If you create an overwrite, you are likely to run into troubles later on, e.g., when reporting is required, because you may lack specific artifacts a specific task was creating, etc.
48+
49+
So while overwriting can be a good temporary solution, for the long term, it should be considered where to add or use a configuration point within the toolbox to make the standard task work for *all* projects.
50+
51+
**Potential options here are:**
52+
53+
* Add additional :ref:`plugin extension <plugin support>` points to the toolbox
54+
* Implement functionality for an :ref:`existing extension point <plugins>` in the `python-toolbox`_
55+
* Add additional configuration parameters in :code:`noxconfig.py` or :code:`pyproject.toml`
56+
* Add additional parameterization to tasks
57+
* :code:`pytest plugins` can take care of a specific test preparation need, e.g., `pytest-backend <https://github.com/exasol/pytest-plugins/tree/main/pytest-backend>`_
58+
59+
60+
.. code-block:: python
61+
62+
import nox
63+
64+
# imports all nox task provided by the toolbox
65+
from exasol.toolbox.nox.tasks import * # pylint: disable=wildcard-import disable=unused-wildcard-import
66+
67+
# default actions to be run if nothing is explicitly specified with the -s option
68+
nox.options.sessions = ["project:fix"]
69+
70+
@nox.session(name="project:fix", python=False)
71+
def my_project_fix_overwrite(session) -> None:
72+
"""Runs all automated fixes on the code base"""
73+
74+
# ATTENTION:
75+
# In cases where it is reasonable to use "internal" functions, please do those imports
76+
# within the function to keep them isolated and simplify future removal or replacement.
77+
from exasol.toolbox.nox._shared import python_files
78+
79+
py_files = [f"{file}" for file in python_files(PROJECT_CONFIG.root)]
80+
print("The original 'project:fix' task has been taken hostage by this overwrite")
81+
print("Files:\n{files}".format(files="\n".join(py_files))
3082
31-
.. note::
32-
If test execution isn't performed in the standard way (e.g., :code:`pytest test/unit`, :code:`pytest test/integration`, :code:`pytest test`), you will need to overwrite the test-specific Nox tasks and will not be able to use the default ones.
3383
3484
3. Establish a Baseline
3585
-----------------------
36-
Configure code quality and settings in the :code:`pyproject.toml` and establish a baseline for your project. If necessary, create tickets for further improvements, especially if major parts of your code need suppression, e.g., in the mypy configuration.
86+
Configure code quality settings in the :code:`pyproject.toml` file to establish a baseline for your project. If necessary, create tickets for further improvements, especially if major parts of your code require suppression, e.g., in the mypy configuration.
87+
88+
**:code:`pyproject.toml` sections to include/consider:**
89+
90+
* [tool.coverage.run]
91+
* [tool.coverage.report]
92+
* [tool.black]
93+
* [tool.isort]
94+
* [tool.pylint.format]
95+
* [[tool.mypy.overrides]]
96+
97+
Example
98+
_______
99+
100+
.. code-block:: toml
101+
102+
# Adjust this section if you want fine-grained control
103+
# over what is considered for code coverage
104+
[tool.coverage.run]
105+
relative_files = true
106+
source = [
107+
"exasol",
108+
]
109+
110+
# Adjust this section to define the minimum required
111+
# code coverage for your project
112+
[tool.coverage.report]
113+
fail_under = 15
114+
115+
116+
# Adjust control maximum line length in your project
117+
#
118+
# NOTE:
119+
# As a rule of thumb, you should not exceed 120 characters,
120+
# because overly long lines usually accompany higher cyclomatic complexity,
121+
# as complex functions tend to shift right.
122+
[tool.black]
123+
line-length = 88
124+
include = "\\.pyi?$"
125+
126+
127+
# Adjust to modify the behavior of import sorting
128+
[tool.isort]
129+
profile = "black"
130+
force_grid_wrap = 2
131+
132+
133+
# Adjust to define the minimum linting score considered acceptable for your project
134+
[tool.pylint.master]
135+
fail-under = 7.5
136+
137+
# Maximum line length should match what is configured for black.
138+
# Additionally, a maximum module size can be defined here.
139+
[tool.pylint.format]
140+
max-line-length = 88
141+
max-module-lines = 800
142+
143+
144+
# Configure exceptions for the type checker
145+
[[tool.mypy.overrides]]
146+
module = [
147+
"test.unit.*",
148+
"test.integration.*",
149+
]
150+
ignore_errors = true
37151
38-
TODO: Add config examples and links to config
39152
40153
4. Introduce GitHub Workflows
41154
-----------------------------
@@ -44,13 +157,15 @@ Install the GitHub workflows provided by the :code:`python-toolbox` for futher d
44157
.. attention::
45158
This is just guidance. If you have a good understanding of the standard project setup, technologies, and tools used, feel free to diverge at any point or exercise your own judgment.
46159
47-
.. _Nox: https://github.com/exasol/python-toolbox/pull/289
48-
49160
50161
Migration Progess
51162
+++++++++++++++++
52163
53-
Could be tracked in a format and based on the information listed in the example bellow.
164+
Could be tracked in a format and based on the information listed in the real life example bellow.
165+
166+
.. hint::
167+
168+
This table does not provide any information about the specific `python-toolbox`_ used in the respective projects.
54169
55170
.. list-table:: Migration Progress
56171
:widths: 20 15 15 15 15 15 15 15
@@ -64,46 +179,106 @@ Could be tracked in a format and based on the information listed in the example
64179
- nox
65180
- toolbox-tasks
66181
- toolbox-workflows
67-
* - Project 1
182+
* - `python-toolbox`_
183+
-
184+
-
185+
-
186+
-
68187
-
69188
-
70189
-
190+
* - `error-reporting-python <https://github.com/exasol/error-reporting-python>`_
71191
-
72192
-
73193
-
74194
-
75-
* - Project 2
195+
-
196+
-
197+
-
198+
* - `pyexasol <https://github.com/exasol/pyexasol>`_
199+
-
200+
-
201+
-
202+
-
203+
-
76204
-
77205
-
206+
* - `sqlalchemy-exasol <https://github.com/exasol/sqlalchemy-exasol>`_
207+
-
208+
-
209+
-
210+
-
211+
-
78212
-
79213
-
214+
* - `bucketfs-python <https://github.com/exasol/bucketfs-python/tree/main>`_
215+
-
216+
-
217+
-
218+
-
219+
-
220+
-
221+
-/✗ partialy
222+
* - `ITDE <https://github.com/exasol/integration-test-docker-environment>`_
223+
-
224+
-
225+
-
226+
-
227+
-
228+
-/✗ partialy
229+
-/✗ partialy
230+
* - `schemas <https://github.com/exasol/schemas>`_
231+
-
232+
-
80233
-
81234
-
82235
-
83-
* - Project 3
84-
- ✓
85236
-
86237
-
238+
* - `pytest-plugins <https://github.com/exasol/pytest-plugins>`_
87239
-
88240
-
241+
-
242+
-/✗ partialy
243+
-
244+
-/✗ partialy
89245
-
90-
- ✗
91-
* - Project 4
246+
* - `harlequin-exasol <https://github.com/Nicoretti/harlequin-exasol>`_
247+
-
248+
-
249+
-
92250
-
93251
-
94252
-
95253
-
96-
- ✗
97-
- ✗
98-
- ✗
99254
100-
Legend
101255
102-
* Project
103-
* pyproject.toml
104-
* poetr
105-
* PyPI
106-
* Sphinx Docs
107-
* nox
108-
* toolbox-tasks
109-
* toolbox-workflows
256+
.. list-table:: Legend
257+
:widths: 20 80
258+
:header-rows: 1
259+
260+
* - Column
261+
- Description
262+
* - Project
263+
- Name of the project
264+
* - pyproject.toml
265+
- Project configuration and setup is `pyproject.toml`_ based
266+
* - poetry
267+
- Project configuration and build is `Poetry`_ based
268+
* - PYPI
269+
- Project can be build and published to `PyPi`_
270+
* - Sphinx Docs
271+
- The project doumentation is `Sphinx`_ based
272+
* - nox
273+
- The projects automated tasks are executed using the `Nox`_ task runner
274+
* - toolbox-tasks
275+
- All nox tasks provided by the `python-toolbox`_ are available and fully functional
276+
* - toolbox-workflows
277+
- All :ref:`GitHub Workflows` provided by the `python-toolbox`_ are available and fully functional
278+
279+
.. _pyproject.toml: https://peps.python.org/pep-0621/
280+
.. _Nox: https://nox.thea.codes/en/stable/
281+
.. _Poetry: https://python-poetry.org/
282+
.. _PyPi: https://pypi.org/
283+
.. _Sphinx: https://www.sphinx-doc.org/en/master/
284+
.. _python-toolbox: https://github.com/exasol/python-toolbox

0 commit comments

Comments
 (0)