Description
in ploomber/jupysql#734, I noticed that JupySQL's unit tests were taking too long to run, after running some profiling I realized that this was because of the logic in this package that checks whether there are new updates:
core/src/ploomber_core/telemetry/telemetry.py
Line 363 in f0d346a
Here's what was happening (10 seconds to run a test!)
(jupysql) eduardo@macbookair dev/jupysql (ci-speed) » pytest src/tests/test_magic.py::test_memory_db
================================================================================ test session starts ================================================================================
platform darwin -- Python 3.10.12, pytest-7.4.0, pluggy-1.2.0
rootdir: /Users/eduardo/dev/jupysql
configfile: pyproject.toml
plugins: anyio-3.7.1, profiling-1.7.0
collected 1 item
src/tests/test_magic.py . [100%]
================================================================================= 1 passed in 9.86s =================================================================================
After disabling the version check via the env variable (<1 second!):
(jupysql) eduardo@macbookair dev/jupysql (ci-speed) » export PLOOMBER_VERSION_CHECK_DISABLED=true 2 ↵
(jupysql) eduardo@macbookair dev/jupysql (ci-speed) » pytest src/tests/test_magic.py::test_memory_db
================================================================================ test session starts ================================================================================
platform darwin -- Python 3.10.12, pytest-7.4.0, pluggy-1.2.0
rootdir: /Users/eduardo/dev/jupysql
configfile: pyproject.toml
plugins: anyio-3.7.1, profiling-1.7.0
collected 1 item
src/tests/test_magic.py . [100%]
================================================================================= 1 passed in 0.26s =================================================================================
JupySQL's unit tests have been fixed already by setting the environment variable. However, we need to get to the root cause of this because the version check if performed in all our packages, might impact performance. So we have to understand why the version check was delaying the tests so much and if this is affecting the user experience.
tools we can use for profiling:
https://github.com/man-group/pytest-plugins/blob/master/pytest-profiling/README.md
https://github.com/pyutils/line_profiler