Skip to content

Commit

Permalink
Clarify local debugging with uv and encourage unit tests in PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
thalassemia committed Dec 13, 2024
1 parent e186bc2 commit c9daf6c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
17 changes: 13 additions & 4 deletions doc/ci.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,19 @@ tasks are:
Logs from these tests can be viewed on the GitHub website and we strongly
recommend that you get all of these tests passing before merging a PR.

Additionally, we would appreciate if you added tests to improve our test coverage
and improve the likelihood that we catch bugs. This could be as simple as a Python
function with the ``test_`` prefix that ensures some bit of code changed in your
PR works as intended with a few test cases.
When you submit a pull request (PR), a bot will comment with a table showing the current code
coverage of the ``pytest`` suite. As of December 2024, coverage is less than 30%
and even that is misleading because many of the tests are "migration" tests
that compare vEcoli to a snapshot of the original whole cell model. These tests will
be removed in the future as vEcoli is further developed. Additionally, these tests do
not tell us whether the code is working as intended, only that it is working the same
way it worked in the original model. Ideally, we would like to increase test coverage
by adding unit tests which actually test edge cases and ensure the code does what it
is supposed to do.

To that end, we would appreciate if you added tests as part of your pull requests.
This could be as simple as a Python function with the ``test_`` prefix that ensures
the code added or modified in your PR works as intended using a few test cases.

-------
Jenkins
Expand Down
20 changes: 12 additions & 8 deletions doc/workflows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -740,9 +740,8 @@ the output directory specified via ``out_dir`` or ``out_uri`` under the
- ``nextflow_workdirs``: Contains all working directories for Nextflow jobs.
Required for resume functionality described in :ref:`fault_tolerance`. Can
also go to work directory for a job (consult files described in :ref:`progress`
or ``{experiment ID}_report.html``) and run ``bash .command.sh`` with
breakpoints set in the relevant code (``import ipdb; ipdb.set_trace()``)
for debugging.
or ``{experiment ID}_report.html``) for debugging. See :ref:`make_and_test`
for more information.

.. tip::
To save space, you can safely delete ``nextflow_workdirs`` after you are finished
Expand Down Expand Up @@ -795,6 +794,8 @@ in a workflow called ``agitated_mendel``::
nextflow log agitated_mendel -f name,stderr,workdir -F "status == 'FAILED'"


.. _make_and_test:

Make and Test Fixes
===================

Expand All @@ -810,11 +811,14 @@ Add breakpoints to any Python file with the following line::
import ipdb; ipdb.set_trace()

Then, navigate to the working directory (see :ref:`troubleshooting`) for a
failing process. ``bash .command.run`` should re-run the job and pause upon
reaching the breakpoints you set. You should now be in an ipdb shell which
you can use to examine variable values or step through the code.
failing process. Invoke ``uv run --env-file {} .command.run``, replacing
the curly braces with the path to the ``.env`` file in your cloned repository.
This should re-run the job and pause upon reaching the breakpoints you set.
You should now be in an ipdb shell which you can use to examine variable values
or step through the code.

After fixing the issue, you can resume the workflow (avoid re-running
already successful jobs) by navigating back to the directory in which you
originally started the workflow and issuing the same command with the
``--resume`` option (see :ref:`fault_tolerance`).
originally started the workflow and issuing the same command
(:py:mod:`runscripts.workflow`) with the ``--resume`` option
(see :ref:`fault_tolerance`).

0 comments on commit c9daf6c

Please sign in to comment.