From f28ee51678202731b74cb1e04e32a459073db937 Mon Sep 17 00:00:00 2001 From: noatamir <6564007+noatamir@users.noreply.github.com> Date: Fri, 7 Oct 2022 10:35:29 +0200 Subject: [PATCH 1/5] DOC: Update xdist to provide more speed-up options and context (#48958) (#48535) --- .../development/contributing_codebase.rst | 54 +++++++++++++++---- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/doc/source/development/contributing_codebase.rst b/doc/source/development/contributing_codebase.rst index c60edd0d1c2b9..2c6fa76f7e53a 100644 --- a/doc/source/development/contributing_codebase.rst +++ b/doc/source/development/contributing_codebase.rst @@ -790,14 +790,11 @@ Or with one of the following constructs:: pytest pandas/tests/[test-module].py::[TestClass] pytest pandas/tests/[test-module].py::[TestClass]::[test_method] -Using `pytest-xdist `_, one can -speed up local testing on multicore machines. To use this feature, you will -need to install ``pytest-xdist`` via:: - - pip install pytest-xdist - -The ``-n`` flag then can be specified when running ``pytest`` to parallelize a test run -across the number of specified cores or ``auto`` to utilize all the available cores on your machine. +Using `pytest-xdist `_, which is +included in our 'pandas-dev' environment, one can speed up local testing on +multicore machines. The -n flag then can be specified when running pytest to +parallelize a test run across the number of specified cores or auto to +utilize all the available cores on your machine. .. code-block:: bash @@ -807,8 +804,45 @@ across the number of specified cores or ``auto`` to utilize all the available co # Utilizes all available cores pytest -n auto pandas -This can significantly reduce the time it takes to locally run tests before -submitting a pull request. +If you'd like to speed things along further a more advanced use of this +command would look like this + +.. code-block:: bash + + pytest pandas --skip-slow --skip-network --skip-db -m "not single_cpu" -n 4 -r sxX + +In addition to the multithreaded performance increase this improves test +speed by skipping some tests: + +- skip-slow: any test that takes long (think seconds rather than milliseconds) +- skip-network: tests that require network connectivity +- skip-db: tests that require a database + +The -r flag will display a short summary info (see `pytest documentation `_) +. Here we are displaying the number of: + +- s: skipped tests +- x: xfailed tests +- X: xpassed tests + +This is optional and can be removed if you don't like the summary. Using this +command can significantly reduce the time it takes to locally run tests +before submitting a pull request. If you require assistance with the results, +which has happened in the past, please set a seed before running the command +and opening a bug report, that way we can reproduce it. Here's an example +for setting a seed on windows + +.. code-block:: bash + + set PYTHONHASHSEED=314159265 + pytest pandas --skip-slow --skip-network --skip-db -m "not single_cpu" -n 4 -r sxX + +On Unix use + +.. code-block:: bash + + export PYTHONHASHSEED=$(python -c 'import random; print(random.randint(1, 4294967295))') + pytest pandas --skip-slow --skip-network --skip-db -m "not single_cpu" -n 4 -r sxX For more, see the `pytest `_ documentation. From 3e55a9eeac19928ceb118b384e2487791145eecf Mon Sep 17 00:00:00 2001 From: noatamir <6564007+noatamir@users.noreply.github.com> Date: Mon, 10 Oct 2022 18:40:19 +0200 Subject: [PATCH 2/5] updated based on feedback --- .../development/contributing_codebase.rst | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/doc/source/development/contributing_codebase.rst b/doc/source/development/contributing_codebase.rst index 2c6fa76f7e53a..df9734b800f90 100644 --- a/doc/source/development/contributing_codebase.rst +++ b/doc/source/development/contributing_codebase.rst @@ -792,8 +792,8 @@ Or with one of the following constructs:: Using `pytest-xdist `_, which is included in our 'pandas-dev' environment, one can speed up local testing on -multicore machines. The -n flag then can be specified when running pytest to -parallelize a test run across the number of specified cores or auto to +multicore machines. The ``-n`` number flag then can be specified when running +pytest to parallelize a test run across the number of specified cores or auto to utilize all the available cores on your machine. .. code-block:: bash @@ -809,25 +809,37 @@ command would look like this .. code-block:: bash - pytest pandas --skip-slow --skip-network --skip-db -m "not single_cpu" -n 4 -r sxX + pytest pandas -n 4 -m "not skip-slow and skip-network and skip-db and not single_cpu" -r sxX In addition to the multithreaded performance increase this improves test -speed by skipping some tests: +speed by skipping some tests using the ``-m`` mark flag: -- skip-slow: any test that takes long (think seconds rather than milliseconds) -- skip-network: tests that require network connectivity -- skip-db: tests that require a database +- skip-slow: any test taking long (think seconds rather than milliseconds) +- skip-network: tests requiring network connectivity +- skip-db: tests requiring a database (mysql or postgres) +- single_cpu: tests that should run on a single cpu only -The -r flag will display a short summary info (see `pytest documentation `_) +You might want to enable the following option if it's relevant for you: + +- arm_slow: any test taking long on arm64 architecture + +These markers are defined `in this toml file `_ +, under ``[tool.pytest.ini_options]`` in a list called ``markers``, in case +you want to check if new ones have been created which are of interest to you. + +The ``-r`` report flag will display a short summary info (see `pytest +documentation `_) . Here we are displaying the number of: - s: skipped tests - x: xfailed tests - X: xpassed tests -This is optional and can be removed if you don't like the summary. Using this -command can significantly reduce the time it takes to locally run tests -before submitting a pull request. If you require assistance with the results, +The summary is optional and can be removed if you don't need the added +information. Using the parallelization option can significantly reduce the +time it takes to locally run tests before submitting a pull request. + +If you require assistance with the results, which has happened in the past, please set a seed before running the command and opening a bug report, that way we can reproduce it. Here's an example for setting a seed on windows @@ -835,14 +847,14 @@ for setting a seed on windows .. code-block:: bash set PYTHONHASHSEED=314159265 - pytest pandas --skip-slow --skip-network --skip-db -m "not single_cpu" -n 4 -r sxX + pytest pandas -n 4 -m "not skip-slow and skip-network and skip-db and not single_cpu" -r sxX On Unix use .. code-block:: bash - export PYTHONHASHSEED=$(python -c 'import random; print(random.randint(1, 4294967295))') - pytest pandas --skip-slow --skip-network --skip-db -m "not single_cpu" -n 4 -r sxX + export PYTHONHASHSEED=314159265 + pytest pandas -n 4 -m "not skip-slow and skip-network and skip-db and not single_cpu" -r sxX For more, see the `pytest `_ documentation. From 49e27be619321b8f275ba39dfea0868aee39d8aa Mon Sep 17 00:00:00 2001 From: noatamir <6564007+noatamir@users.noreply.github.com> Date: Tue, 11 Oct 2022 09:52:52 +0200 Subject: [PATCH 3/5] fix typos in pytest lines --- doc/source/development/contributing_codebase.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/source/development/contributing_codebase.rst b/doc/source/development/contributing_codebase.rst index df9734b800f90..42e99513c5fae 100644 --- a/doc/source/development/contributing_codebase.rst +++ b/doc/source/development/contributing_codebase.rst @@ -809,7 +809,7 @@ command would look like this .. code-block:: bash - pytest pandas -n 4 -m "not skip-slow and skip-network and skip-db and not single_cpu" -r sxX + pytest pandas -n 4 -m "not skip-slow and not skip-network and not skip-db and not single_cpu" -r sxX In addition to the multithreaded performance increase this improves test speed by skipping some tests using the ``-m`` mark flag: @@ -847,14 +847,14 @@ for setting a seed on windows .. code-block:: bash set PYTHONHASHSEED=314159265 - pytest pandas -n 4 -m "not skip-slow and skip-network and skip-db and not single_cpu" -r sxX + pytest pandas -n 4 -m "not skip-slow and not skip-network and not skip-db and not single_cpu" -r sxX On Unix use .. code-block:: bash export PYTHONHASHSEED=314159265 - pytest pandas -n 4 -m "not skip-slow and skip-network and skip-db and not single_cpu" -r sxX + pytest pandas -n 4 -m "not skip-slow and not skip-network and not skip-db and not single_cpu" -r sxX For more, see the `pytest `_ documentation. From 64e66a5c01b3c801f31ada1733db3ec579f6fd90 Mon Sep 17 00:00:00 2001 From: noatamir <6564007+noatamir@users.noreply.github.com> Date: Wed, 12 Oct 2022 02:02:44 +0200 Subject: [PATCH 4/5] corrected markers --- doc/source/development/contributing_codebase.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/source/development/contributing_codebase.rst b/doc/source/development/contributing_codebase.rst index 42e99513c5fae..41ae4adbcb1d7 100644 --- a/doc/source/development/contributing_codebase.rst +++ b/doc/source/development/contributing_codebase.rst @@ -809,14 +809,14 @@ command would look like this .. code-block:: bash - pytest pandas -n 4 -m "not skip-slow and not skip-network and not skip-db and not single_cpu" -r sxX + pytest pandas -n 4 -m "not slow and not network and not db and not single_cpu" -r sxX In addition to the multithreaded performance increase this improves test speed by skipping some tests using the ``-m`` mark flag: -- skip-slow: any test taking long (think seconds rather than milliseconds) -- skip-network: tests requiring network connectivity -- skip-db: tests requiring a database (mysql or postgres) +- slow: any test taking long (think seconds rather than milliseconds) +- network: tests requiring network connectivity +- db: tests requiring a database (mysql or postgres) - single_cpu: tests that should run on a single cpu only You might want to enable the following option if it's relevant for you: @@ -847,14 +847,14 @@ for setting a seed on windows .. code-block:: bash set PYTHONHASHSEED=314159265 - pytest pandas -n 4 -m "not skip-slow and not skip-network and not skip-db and not single_cpu" -r sxX + pytest pandas -n 4 -m "not slow and not network and not db and not single_cpu" -r sxX On Unix use .. code-block:: bash export PYTHONHASHSEED=314159265 - pytest pandas -n 4 -m "not skip-slow and not skip-network and not skip-db and not single_cpu" -r sxX + pytest pandas -n 4 -m "not slow and not network and not db and not single_cpu" -r sxX For more, see the `pytest `_ documentation. From 039b3ed82d4bda74dd4188d22f24fce2ee08d435 Mon Sep 17 00:00:00 2001 From: Noa Tamir <6564007+noatamir@users.noreply.github.com> Date: Thu, 13 Oct 2022 09:42:25 +0200 Subject: [PATCH 5/5] Update doc/source/development/contributing_codebase.rst fixed link to main --- doc/source/development/contributing_codebase.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/development/contributing_codebase.rst b/doc/source/development/contributing_codebase.rst index 41ae4adbcb1d7..41425878ef654 100644 --- a/doc/source/development/contributing_codebase.rst +++ b/doc/source/development/contributing_codebase.rst @@ -823,7 +823,7 @@ You might want to enable the following option if it's relevant for you: - arm_slow: any test taking long on arm64 architecture -These markers are defined `in this toml file `_ +These markers are defined `in this toml file `_ , under ``[tool.pytest.ini_options]`` in a list called ``markers``, in case you want to check if new ones have been created which are of interest to you.