Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/pypa/cibuildwheel-…
Browse files Browse the repository at this point in the history
…2.17
  • Loading branch information
XuehaiPan committed Mar 19, 2024
2 parents ef6d755 + d439ea3 commit 52e2974
Show file tree
Hide file tree
Showing 112 changed files with 152 additions and 135 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ repos:
- id: debug-statements
- id: double-quote-string-fixer
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
rev: v18.1.1
hooks:
- id: clang-format
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
rev: v0.3.3
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -39,11 +39,11 @@ repos:
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.3.0
hooks:
- id: black-jupyter
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.15.1
hooks:
- id: pyupgrade
args: [--py38-plus] # sync with requires-python
Expand All @@ -52,7 +52,7 @@ repos:
^examples/
)
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-20.04
os: ubuntu-lts-latest
tools:
python: mambaforge-4.10
python: mambaforge-latest
jobs:
post_install:
- python -m pip install --upgrade pip setuptools
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [2022-2023] [MetaOPT Team. All Rights Reserved.]
Copyright [2022-2024] [MetaOPT Team. All Rights Reserved.]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
print-% : ; @echo $* = $($*)
print-%: ; @echo $* = $($*)
PROJECT_NAME = torchopt
COPYRIGHT = "MetaOPT Team. All Rights Reserved."
PROJECT_PATH = $(PROJECT_NAME)
Expand All @@ -22,7 +22,7 @@ install:
install-editable:
$(PYTHON) -m pip install --upgrade pip
$(PYTHON) -m pip install --upgrade setuptools wheel
$(PYTHON) -m pip install torch numpy pybind11
$(PYTHON) -m pip install torch numpy pybind11 cmake
USE_FP16=ON TORCH_CUDA_ARCH_LIST=Auto $(PYTHON) -m pip install -vvv --no-build-isolation --editable .

install-e: install-editable # alias
Expand Down Expand Up @@ -112,6 +112,7 @@ addlicense-install: go-install
# Tests

pytest: test-install
$(PYTHON) -m pytest --version
cd tests && $(PYTHON) -c 'import $(PROJECT_PATH)' && \
$(PYTHON) -m pytest --verbose --color=yes --durations=0 \
--cov="$(PROJECT_PATH)" --cov-config=.coveragerc --cov-report=xml --cov-report=term-missing \
Expand All @@ -122,30 +123,39 @@ test: pytest
# Python linters

pylint: pylint-install
$(PYTHON) -m pylint --version
$(PYTHON) -m pylint $(PROJECT_PATH)

flake8: flake8-install
$(PYTHON) -m flake8 --version
$(PYTHON) -m flake8 --count --show-source --statistics

py-format: py-format-install
$(PYTHON) -m isort --version
$(PYTHON) -m black --version
$(PYTHON) -m isort --project $(PROJECT_PATH) --check $(PYTHON_FILES) && \
$(PYTHON) -m black --check $(PYTHON_FILES) tutorials

ruff: ruff-install
$(PYTHON) -m ruff --version
$(PYTHON) -m ruff check .

ruff-fix: ruff-install
$(PYTHON) -m ruff --version
$(PYTHON) -m ruff check . --fix --exit-non-zero-on-fix

mypy: mypy-install
$(PYTHON) -m mypy --version
$(PYTHON) -m mypy $(PROJECT_PATH) --install-types --non-interactive

pre-commit: pre-commit-install
$(PYTHON) -m pre_commit --version
$(PYTHON) -m pre_commit run --all-files

# C++ linters

cmake-configure: cmake-install
cmake --version
cmake -S . -B cmake-build-debug \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
Expand All @@ -157,13 +167,16 @@ cmake-build: cmake-configure
cmake: cmake-build

cpplint: cpplint-install
$(PYTHON) -m cpplint --version
$(PYTHON) -m cpplint $(CXX_FILES) $(CUDA_FILES)

clang-format: clang-format-install
$(CLANG_FORMAT) --version
$(CLANG_FORMAT) --style=file -i $(CXX_FILES) $(CUDA_FILES) -n --Werror

clang-tidy: clang-tidy-install cmake-configure
clang-tidy -p=cmake-build-debug $(CXX_FILES)
clang-tidy --version
clang-tidy --extra-arg="-v" -p=cmake-build-debug $(CXX_FILES)

# Documentation

Expand Down
2 changes: 1 addition & 1 deletion conda-recipe-minimal-cpu.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion conda-recipe-minimal.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion conda-recipe.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion docs/conda-recipe.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -66,7 +66,7 @@ def filter(self, record: logging.LogRecord) -> bool:
# -- Project information -------------------------------------------------------

project = 'TorchOpt'
copyright = '2022-2023 MetaOPT Team'
copyright = '2022-2024 MetaOPT Team'
author = 'TorchOpt Contributors'

# The full version, including alpha/beta/rc tags
Expand Down
2 changes: 1 addition & 1 deletion examples/FuncTorch/maml_omniglot_vmap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion examples/L2R/helpers/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion examples/LOLA/helpers/agent.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion examples/MAML-RL/func_maml.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion examples/distributed/few-shot/maml_omniglot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion examples/few-shot/maml_omniglot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion examples/iMAML/imaml_omniglot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion examples/iMAML/imaml_omniglot_functional.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion include/adam_op/adam_op.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
// Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion include/adam_op/adam_op_impl_cpu.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
// Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion include/adam_op/adam_op_impl_cuda.cuh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
// Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion include/common.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
// Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion include/utils.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
// Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
21 changes: 11 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ test-command = """
# Linter tools #################################################################

[tool.black]
safe = true
line-length = 100
skip-string-normalization = true
# Sync with requires-python
Expand All @@ -194,15 +193,15 @@ multi_line_output = 3

[tool.mypy]
# Sync with requires-python
python_version = 3.8
python_version = "3.8"
pretty = true
show_error_codes = true
show_error_context = true
show_traceback = true
allow_redefinition = true
check_untyped_defs = true
disallow_incomplete_defs = false
disallow_untyped_defs = false
disallow_incomplete_defs = true
disallow_untyped_defs = true
ignore_missing_imports = true
no_implicit_optional = true
strict_equality = true
Expand All @@ -226,9 +225,11 @@ ignore-words = "docs/source/spelling_wordlist.txt"
# Sync with requires-python
target-version = "py38"
line-length = 100
show-source = true
output-format = "full"
src = ["torchopt", "tests"]
extend-exclude = ["examples"]

[tool.ruff.lint]
select = [
"E", "W", # pycodestyle
"F", # pyflakes
Expand Down Expand Up @@ -271,7 +272,7 @@ ignore = [
]
typing-modules = ["torchopt.typing"]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = [
"F401", # unused-import
]
Expand All @@ -294,18 +295,18 @@ typing-modules = ["torchopt.typing"]
"F811", # redefined-while-unused
]

[tool.ruff.flake8-annotations]
[tool.ruff.lint.flake8-annotations]
allow-star-arg-any = true

[tool.ruff.flake8-quotes]
[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double"
multiline-quotes = "double"
inline-quotes = "single"

[tool.ruff.flake8-tidy-imports]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"

[tool.ruff.pylint]
[tool.ruff.lint.pylint]
allow-magic-value-types = ["int", "str", "float"]

[tool.pytest.ini_options]
Expand Down
2 changes: 1 addition & 1 deletion src/adam_op/adam_op.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
// Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/adam_op/adam_op_impl_cpu.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
// Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/adam_op/adam_op_impl_cuda.cu
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
// Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
3 changes: 2 additions & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ torch >= 1.13

jax[cpu] >= 0.3; platform_system != 'Windows'
jaxopt; platform_system != 'Windows'
optax; platform_system != 'Windows'
optax < 0.1.8a0; platform_system != 'Windows' and python_version < '3.9'
optax >= 0.1.8; platform_system != 'Windows' and python_version >= '3.9'

pytest
pytest-cov
Expand Down
2 changes: 1 addition & 1 deletion tests/test_accelerated_op.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_alias.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_clip.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 MetaOPT Team. All Rights Reserved.
# Copyright 2022-2024 MetaOPT Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit 52e2974

Please sign in to comment.