Skip to content

Commit

Permalink
Merge pull request #513 from SauravMaheshkar:master
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 532784452
  • Loading branch information
OptaxDev committed May 17, 2023
2 parents e5f910e + e25c56c commit 7155cf2
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Check consistency between the package version and release tag
Expand All @@ -24,11 +24,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install setuptools wheel twine build
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
python -m build
twine upload dist/*
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
python-version: "${{ matrix.python-version }}"
cache: "pip"
cache-dependency-path: '**/requirements*.txt'
cache-dependency-path: 'pyproject.toml'
- name: Run CI tests
run: bash test.sh
shell: bash
87 changes: 85 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,85 @@
# Empty file in preparation for PR #513.
# See https://github.com/deepmind/optax/pull/513 for more information.
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "optax"
dynamic = ["version"]
description = "A gradient processing and optimisation library in JAX."
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.8"
authors = [
{name = "DeepMind", email = "optax-dev@google.com"},
]
keywords = [
"python",
"machine learning",
"reinforcement-learning"
]
classifiers = [
"Environment :: Console",
"Programming Language :: Python",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Intended Audience :: Science/Research",
"Development Status :: 4 - Beta",
"License :: OSI Approved :: Apache Software License",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"absl-py>=0.7.1",
"chex>=0.1.5",
"jax>=0.1.55",
"jaxlib>=0.1.37",
"numpy>=1.18.0",
]

[project.urls]
homepage = "https://github.com/deepmind/optax"
repository = "https://github.com/deepmind/optax"
documentation = "https://optax.readthedocs.io/"

[project.optional-dependencies]
test = [
"dm-haiku>=0.0.3",
"dm-tree>=0.1.7",
"flax==0.5.3"
]

examples = [
"dm-haiku>=0.0.3",
"tensorflow-datasets>=4.2.0",
"tensorflow>=2.4.0"
]

docs = [
"sphinx==4.5.0",
"sphinx-book-theme==0.3.3",
"sphinxcontrib-katex==0.9.0",
"sphinxcontrib-bibtex==2.4.2",
"sphinx-autodoc-typehints==1.11.1",
"IPython==7.16.3",
"ipykernel==5.3.4",
"pandoc==1.0.2",
"myst_nb==0.13.1",
"docutils==0.16",
"matplotlib==3.5.0",
"dm-haiku==0.0.8"
]

dp-accounting = [
"absl-py>=1.0.0",
"attrs>=21.4.0",
"mpmath>=1.2.1",
"numpy>=1.21.4",
"scipy>=1.7.1"
]

[tool.setuptools]
zip_safe = false

[tool.setuptools.packages.find]
exclude = ["*_test.py"]
10 changes: 7 additions & 3 deletions readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ sphinx:
python:
version: 3.8
install:
- requirements: requirements/requirements-docs.txt
- requirements: requirements/requirements.txt
- method: setuptools
# Equivalent to 'pip install .'
- method: pip
path: .
# Equivalent to 'pip install .[docs]'
- method: pip
path: .
extra_requirements:
- docs
11 changes: 5 additions & 6 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ python --version
# Install dependencies.
pip install --upgrade pip setuptools wheel
pip install flake8 pytest-xdist pytype pylint pylint-exit
pip install -r requirements/requirements.txt
pip install -r requirements/requirements-test.txt
pip install -r requirements/requirements-examples.txt
pip install -e ".[test, examples]"

# Dp-accounting specifies exact minor versions as requirements which sometimes
# become incompatible with other libraries optax needs. We therefore install
# dependencies for dp-accounting manually.
# TODO(b/239416992): Remove this workaround if dp-accounting switches to minimum
# version requirements.
pip install -r requirements/minimum-requirements-dp-accounting.txt
pip install -e ".[dp-accounting]"
pip install "dp-accounting>=0.1.1" --no-deps

# Ensure optax was not installed by one of the dependencies above,
Expand All @@ -60,7 +58,8 @@ pylint --rcfile=.pylintrc `find optax examples -name '*_test.py' | xargs` -d W02
rm .pylintrc

# Build the package.
python setup.py sdist
pip install build
python -m build
pip wheel --verbose --no-deps --no-clean dist/optax*.tar.gz
pip install optax*.whl

Expand All @@ -78,7 +77,7 @@ python -m pytest -n auto .
cd ..

# Build Sphinx docs.
pip install -r requirements/requirements-docs.txt
pip install -e ".[docs]"
cd docs && make html
cd ..

Expand Down

0 comments on commit 7155cf2

Please sign in to comment.