aiidateam / aiida-workgraph

Efficiently design and manage flexible workflows with AiiDA, featuring an interactive GUI, checkpoints, provenance tracking, and remote execution capabilities.
https://aiida-workgraph.readthedocs.io/en/latest/
MIT License
9 stars 5 forks source link

Speed up unit test and skip unstable test #205

Closed superstar54 closed 1 month ago

superstar54 commented 1 month ago

In the previous unit test, one needed to sleep for a time manually to wait for a task state. The sleep time needs to be chosen carefully to make sure the state is reached. This PR allows the WorkGraph to wait for the particular states of a task.

# wait add1 to be finished.
wg.wait(tasks={"add1": ["FINISHED"]}, timeout=20)
# wait for the workgraph to launch add1
wg.wait(tasks={"add1": ["CREATED", "WAITING", "RUNNING", "FINISHED"]}, timeout=20)

This speeds up the test and makes the test more robust.

To speed up the test, I also

Skip unstable test

I skipped the test for playing the paused task; it seems the daemon is not responding to the play signal. This should be a problem of AiiDA test fixtures.

Time for the pytest

python version AiiDA version Time (This PR) Time (Previous)
3.9 2.6 13 s 17 s
3.11 2.6 11 s 14 s
3.12 2.6 17 s 23 s

TODO: find why Python 3.12 is slow.

codecov-commenter commented 1 month ago

Codecov Report

Attention: Patch coverage is 98.36066% with 1 line in your changes missing coverage. Please review.

Project coverage is 75.96%. Comparing base (5937b88) to head (6423864). Report is 7 commits behind head on main.

Files Patch % Lines
aiida_workgraph/workgraph.py 93.33% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #205 +/- ## ========================================== + Coverage 75.75% 75.96% +0.20% ========================================== Files 70 70 Lines 4615 4709 +94 ========================================== + Hits 3496 3577 +81 - Misses 1119 1132 +13 ``` | [Flag](https://app.codecov.io/gh/aiidateam/aiida-workgraph/pull/205/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiidateam) | Coverage Δ | | |---|---|---| | [python-3.11](https://app.codecov.io/gh/aiidateam/aiida-workgraph/pull/205/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiidateam) | `75.96% <98.36%> (+0.29%)` | :arrow_up: | | [python-3.9](https://app.codecov.io/gh/aiidateam/aiida-workgraph/pull/205/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiidateam) | `?` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiidateam#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.