Quellcode durchsuchen

Fix flaky test_remote_module_call, extract requirements for docs/tests (#118)

* Fix flaky test_remote_module_call, extract requirements for docs/tests

* Simplify CircleCI config
Max Ryabinin vor 4 Jahren
Ursprung
Commit
c450a43fd0
8 geänderte Dateien mit 37 neuen und 21 gelöschten Zeilen
  1. 10 11
      .circleci/config.yml
  2. 1 1
      .readthedocs.yml
  3. 3 3
      docs/user/contributing.md
  4. 1 1
      hivemind/__init__.py
  5. 6 0
      requirements-dev.txt
  6. 0 0
      requirements-docs.txt
  7. 15 4
      setup.py
  8. 1 1
      tests/test_moe.py

+ 10 - 11
.circleci/config.yml

@@ -1,23 +1,22 @@
 version: 2.1
 
-orbs:
-  python: circleci/python@0.2.1
-
 jobs:
   build-and-test:
-    executor: python/default
     docker:
       - image: circleci/python:3.8.1
     steps:
       - checkout
-      - python/load-cache
-      - run: pip uninstall -y pytest codecov
-      # note: uninstall is required because otherwise circleci cache will lose track of pytest/codecov executables
-      - run: pip install pytest pytest-forked pytest-asyncio codecov tqdm scikit-learn
-      - python/install-deps
-      - python/save-cache
+      - restore_cache:
+          keys:
+            - v1-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}
+      - run: pip install -r requirements.txt
+      - run: pip install -r requirements-dev.txt
+      - save_cache:
+          key: v1-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}
+          paths:
+            - '~/.cache/pip'
       - run:
-          command: pip install --force-reinstall -e .
+          command: pip install -e .
           name: setup
       - run:
           command: pytest ./tests

+ 1 - 1
.readthedocs.yml

@@ -7,6 +7,6 @@ python:
   version: 3.7
   install:
     - requirements: requirements.txt
-    - requirements: docs/requirements.txt
+    - requirements: requirements-docs.txt
     - method: pip
       path: .

+ 3 - 3
docs/user/contributing.md

@@ -25,15 +25,15 @@ First, install hivemind in the development mode, preferably with python 3.8 on l
 ```
 git clone https://github.com/learning-at-home/hivemind
 cd hivemind
-python setup.py develop
+pip install -e .
 ``` 
 
-To run tests, you will also need to `pip install pytest pytest-forked pytest-asyncio codecov tqdm scikit-learn`.
+To run tests, you will also need to `pip install -e .[dev]`.
 You can run all tests with `pytest ./tests` or choose a specific set, e.g. `pytest ./tests/test_dht.py`.
 
 
 To build docs locally,
-1. `pip install sphinx sphinx_rtd_theme recommonmark`
+1. `pip install -e .[docs]`
 2. make sure you ran setup.py (see above)
 3. `cd ./docs && make html`
 

+ 1 - 1
hivemind/__init__.py

@@ -3,4 +3,4 @@ from hivemind.dht import *
 from hivemind.server import *
 from hivemind.utils import *
 
-__version__ = '0.8.10'
+__version__ = '0.8.11'

+ 6 - 0
requirements-dev.txt

@@ -0,0 +1,6 @@
+pytest
+pytest-forked
+pytest-asyncio
+codecov
+tqdm
+scikit-learn

+ 0 - 0
docs/requirements.txt → requirements-docs.txt


+ 15 - 4
setup.py

@@ -42,20 +42,30 @@ class ProtoCompileDevelop(develop):
 here = os.path.abspath(os.path.dirname(__file__))
 
 with open('requirements.txt') as requirements_file:
-    install_requires = [str(requirement) for requirement in parse_requirements(requirements_file)]
+    install_requires = list(map(str, parse_requirements(requirements_file)))
 
 # loading version from setup.py
 with codecs.open(os.path.join(here, 'hivemind/__init__.py'), encoding='utf-8') as init_file:
     version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", init_file.read(), re.M)
     version_string = version_match.group(1)
 
+extras = {}
+
+with open('requirements-dev.txt') as dev_requirements_file:
+    extras['dev'] = list(map(str, parse_requirements(dev_requirements_file)))
+
+with open('requirements-docs.txt') as docs_requirements_file:
+    extras['docs'] = list(map(str, parse_requirements(docs_requirements_file)))
+
+extras['all'] = extras['dev'] + extras['docs']
+
 setup(
     name='hivemind',
     version=version_string,
     cmdclass={'install': ProtoCompileInstall, 'develop': ProtoCompileDevelop},
-    description='Decentralized deep learning framework in pytorch.',
-    long_description='Decentralized deep learning framework in pytorch. Built to train giant models on '
-                     'thousands on volunteers across the world. ',
+    description='Decentralized deep learning in PyTorch',
+    long_description='Decentralized deep learning in PyTorch. Built to train giant models on '
+                     'thousands of volunteers across the world.',
     author='Learning@home & contributors',
     author_email='mryabinin@hse.ru',
     url="https://github.com/learning-at-home/hivemind",
@@ -64,6 +74,7 @@ setup(
     include_package_data=True,
     license='MIT',
     install_requires=install_requires,
+    extras_require=extras,
     classifiers=[
         'Development Status :: 4 - Beta',
         'Intended Audience :: Developers',

+ 1 - 1
tests/test_moe.py

@@ -86,7 +86,7 @@ def test_remote_module_call():
         out3 = real_expert(dummy_x)
         assert out3.shape == (3, 1024)
         out3_again = real_expert(dummy_x[1:])
-        assert torch.allclose(out3_again, out3[1:])
+        assert torch.allclose(out3_again, out3[1:], atol=1e-6, rtol=0)
         out3_again.norm().backward()
         assert dummy_x.grad is not None and dummy_x.grad.norm() > 0