Skip to content

Commit 0829868

Browse files
docs: add instructions for test coverage in integration tests (#967)
This update adds a new section to the troubleshooting documentation explaining how to collect code coverage from worker subprocesses when using executorlib. It also adds a link to this new section in the main README. The solution involves configuring coverage.py with the subprocess patch and using 'coverage combine' to merge results from the main process and workers. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: jan-janssen <3854739+jan-janssen@users.noreply.github.com>
1 parent df8a12a commit 0829868

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ as hierarchical job scheduler within the allocations.
150150
* [Filesystem Usage](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#filesystem-usage)
151151
* [Firewall Issues](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#firewall-issues)
152152
* [Message Passing Interface](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#message-passing-interface)
153+
* [Test Coverage for Integration Tests](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#test-coverage-for-integration-tests)
153154
* [Python Version](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#python-version)
154155
* [Resource Dictionary](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#resource-dictionary)
155156
* [SSH Connection](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#ssh-connection)

docs/trouble_shooting.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ Typical error messages related to missing dependencies are `ModuleNotFoundError`
3131
* `ModuleNotFoundError: No module named 'h5py'` - Install [h5py](https://www.h5py.org/) as explained in the [Caching](https://executorlib.readthedocs.io/en/latest/installation.html#caching) section of the installation.
3232
* `ModuleNotFoundError: No module named 'networkx'` - Install [networkx](https://networkx.org/) as explained in the [Visualisation](https://executorlib.readthedocs.io/en/latest/installation.html#visualisation) section of the installation.
3333

34+
## Test Coverage for Integration Tests
35+
When Python functions are executed with executorlib, they run in subprocesses started via `sys.executable`. As a result, `coverage run`
36+
only tracks the main test process by default and can miss function execution inside executorlib workers.
37+
38+
To collect coverage from both the main process and executorlib subprocesses, enable the subprocess patch in your project configuration:
39+
```toml
40+
[tool.coverage.run]
41+
patch = ["subprocess"]
42+
```
43+
44+
Then execute:
45+
```bash
46+
coverage run -m unittest discover
47+
coverage combine
48+
coverage report
49+
```
50+
51+
The `coverage combine` command merges the data from the main process and subprocesses.
52+
3453
## Python Version
3554
Executorlib supports all current Python version ranging from 3.9 to 3.13. Still some of the dependencies and especially
3655
the [flux](http://flux-framework.org) job scheduler are currently limited to Python 3.12 and below. Consequently for high

0 commit comments

Comments
 (0)