-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* pin numpy and scipy versions for running tests I suspect the latest numpy and/or scipy wheels are the cause of the recent slowdown, because the tests that ran on 2023/06/01 against the versions that I'm pinning in this commit were much faster. * pin cython as well * add some more diagnostic steps to workflow * adjust tests.yml * git add test_wheel.py * increase pytest verbosity * fixup * fixup * fixup * adjust cython version in pin * output cython output as artifacts * update tests.yml, show numpy libs for all platforms * show Cython version during build_ext step * add more diagnostics to setup.py and tests.yml * force cythonization * still more diagnostics * increase test scope to entire suite * clean up, add helpful comments * update test.yml * remove cython magic from setup.py, that gets handled by pyproject.toml * fixup * git mv test_wheel.py .github/workflows/ * reduce timeout to 15 minutes * make that 20 minutes
- Loading branch information
Showing
4 changed files
with
119 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env python | ||
"""Test a Gensim wheel stored on S3. | ||
Downloads the wheel, installs it into a fresh working environment, and then runs gensim tests. | ||
usage: | ||
python test_wheel.py <url> $(which python3.10) | ||
where the URL comes from http://gensim-wheels.s3-website-us-east-1.amazonaws.com/ | ||
""" | ||
|
||
import argparse | ||
import io | ||
import os | ||
import subprocess | ||
import tempfile | ||
import urllib.parse | ||
import urllib.request | ||
import shutil | ||
import sys | ||
|
||
curr_dir = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
|
||
def run(*command, **kwargs): | ||
print("-" * 70, file=sys.stderr) | ||
print(" ".join(command), file=sys.stderr) | ||
print("-" * 70, file=sys.stderr) | ||
subprocess.check_call(command, **kwargs) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("wheel_path", help="The location of the wheel. May be a URL or local path") | ||
parser.add_argument("python", help="Which python binary to use to test the wheel") | ||
parser.add_argument("--gensim-path", default=os.path.expanduser("~/git/gensim"), help="Where the gensim repo lives") | ||
parser.add_argument("--keep", action="store_true", help="Do not delete the sandbox after testing") | ||
parser.add_argument("--test", default="test", help="Specify which tests to run") | ||
args = parser.parse_args() | ||
|
||
_, python_version = subprocess.check_output([args.python, "--version"]).decode().strip().split(" ", 1) | ||
|
||
try: | ||
tmpdir = tempfile.mkdtemp(prefix=f"test_wheel-py{python_version}-") | ||
|
||
tmp_test_path = os.path.join(tmpdir, "test") | ||
shutil.copytree(os.path.join(args.gensim_path, "gensim/test"), tmp_test_path) | ||
|
||
if args.wheel_path.startswith("http://") or args.wheel_path.startswith("https://"): | ||
parsed = urllib.parse.urlparse(args.wheel_path) | ||
filename = parsed.path.split('/')[-1] | ||
wheel_path = os.path.join(tmpdir, filename) | ||
urllib.request.urlretrieve(args.wheel_path, wheel_path) | ||
else: | ||
wheel_path = args.wheel_path | ||
|
||
env_path = os.path.join(tmpdir, "env") | ||
run("virtualenv", "-p", args.python, env_path) | ||
|
||
python_exe = os.path.join(tmpdir, "env/bin/python") | ||
run(python_exe, "-m", "pip", "install", wheel_path) | ||
run(python_exe, "-m", "pip", "install", "mock", "pytest", "testfixtures") | ||
|
||
pytest_exe = os.path.join(tmpdir, "env/bin/pytest") | ||
run(pytest_exe, "-vvv", args.test, "--durations", "0", cwd=tmpdir) | ||
finally: | ||
if args.keep: | ||
print(f"keeping {tmpdir}, remove it yourself when done") | ||
else: | ||
shutil.rmtree(tmpdir) | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
[build-system] | ||
requires = [ | ||
"Cython>=0.29.32", | ||
# oldest supported Numpy for this platform is 1.17 but the oldest supported by Gensim | ||
# is 1.18.5, remove the line when they increase oldest supported Numpy for this platform | ||
"numpy==1.18.5; python_version=='3.8' and platform_machine not in 'arm64|aarch64'", | ||
"oldest-supported-numpy; python_version>'3.8' or platform_machine in 'arm64|aarch64'", | ||
"scipy", | ||
"setuptools", | ||
"wheel", | ||
] | ||
# | ||
# If we build our extensions with Cython 3.0.0, then they will be an | ||
# order of magnitude slower, so avoid it for now. | ||
# | ||
"Cython>=0.29.32,<3.0.0", | ||
# oldest supported Numpy for this platform is 1.17 but the oldest supported by Gensim | ||
# is 1.18.5, remove the line when they increase oldest supported Numpy for this platform | ||
"numpy==1.18.5; python_version=='3.8' and platform_machine not in 'arm64|aarch64'", | ||
"oldest-supported-numpy; python_version>'3.8' or platform_machine in 'arm64|aarch64'", | ||
"scipy", | ||
"setuptools", | ||
"wheel", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters