diff --git a/.github/workflows/notebook-tests.yml b/.github/workflows/notebook-tests.yml index 921d2197..c34df20c 100644 --- a/.github/workflows/notebook-tests.yml +++ b/.github/workflows/notebook-tests.yml @@ -26,18 +26,12 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Upgrade pip + - name: Install uv run: | - python -m pip install --upgrade pip - - name: Install core dependencies + pip install uv + - name: Install all dependencies run: | - pip install -r requirements.txt - - name: Install deep learning dependencies - run: | - pip install -r requirements-deeplearning.txt - - name: Install test dependencies - run: | - pip install -r requirements-test.txt + uv pip install --system -e .[deeplearning,test] - name: Test with pytest run: | # pytest diff --git a/.github/workflows/python-linting.yml b/.github/workflows/python-linting.yml index 319c147a..e0de417f 100644 --- a/.github/workflows/python-linting.yml +++ b/.github/workflows/python-linting.yml @@ -21,10 +21,12 @@ jobs: uses: actions/setup-python@v5 with: python-version: '3.11' + - name: Install uv + run: | + pip install uv - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install -r requirements-linting.txt + uv pip install --system -e .[linting] - name: Check sorted python imports using isort run: | isort . -c diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 9b6fe54c..465f5b71 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -26,18 +26,12 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Upgrade pip + - name: Install uv run: | - python -m pip install --upgrade pip - - name: Install core dependencies + pip install uv + - name: Install all dependencies run: | - pip install -r requirements.txt - - name: Install deep learning dependencies - run: | - pip install -r requirements-deeplearning.txt - - name: Install test dependencies - run: | - pip install -r requirements-test.txt + uv pip install --system -e .[deeplearning,test] - name: Test with pytest run: | # pytest @@ -62,5 +56,6 @@ jobs: # verbose: true - name: Check package consistency with twine run: | - python setup.py check sdist bdist_wheel + pip install build twine + python -m build twine check dist/* diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 15f8f65c..7c86f5ea 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -18,12 +18,14 @@ jobs: uses: actions/setup-python@v5 with: python-version: '3.x' + - name: Install uv + run: | + pip install uv - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish + uv pip install --system build twine + - name: Build run: | - python setup.py sdist bdist_wheel + python -m build - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..62263d83 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,95 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "dice_ml" +version = "0.11" +authors = [ + {name = "Ramaravind Mothilal", email = "raam.arvind93@gmail.com"}, + {name = "Amit Sharma"}, + {name = "Chenhao Tan"} +] +description = "Generate Diverse Counterfactual Explanations for any machine learning model." +readme = "README.rst" +requires-python = ">=3.9" +license = {text = "MIT"} +classifiers = [ + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] +keywords = ["machine-learning", "explanation", "interpretability", "counterfactual"] +dependencies = [ + "jsonschema", + "numpy>=1.20.0", + "pandas>=2.0.0", + "scikit-learn", + "tqdm", + "raiutils>=0.4.0", + "xgboost", + "lightgbm", +] + +[project.urls] +"Homepage" = "https://github.com/interpretml/DiCE" +"Download" = "https://github.com/interpretml/DiCE/archive/v0.11.tar.gz" + +[project.optional-dependencies] +deeplearning = [ + "numpy<2.0.0", + "tensorflow>=1.13.1", + "torch", +] +test = [ + "ipython", + "jupyter", + "pytest==8.3.5", + "pytest-cov", + "twine", + "pytest-mock", + "rai_test_utils", +] +linting = [ + "flake8", + "flake8-bugbear", + "flake8-blind-except", + "flake8-breakpoint", + "flake8-builtins", + "flake8-logging-format", + "flake8-pytest-style", + "flake8-all-not-strings", + "isort", + "packaging", +] +dev = [ + "ipython", + "jupyter", + "pytest==8.3.5", + "pytest-cov", + "twine", + "pytest-mock", + "rai_test_utils", + "flake8", + "flake8-bugbear", + "flake8-blind-except", + "flake8-breakpoint", + "flake8-builtins", + "flake8-logging-format", + "flake8-pytest-style", + "flake8-all-not-strings", + "isort", + "packaging", +] + +[tool.setuptools] +packages = {find = {exclude = ["tests*"]}} +include-package-data = true + +[tool.setuptools.package-data] +"*" = ["*.h5", "counterfactual_explanations_v1.0.json", "counterfactual_explanations_v2.0.json"] diff --git a/requirements-deeplearning.txt b/requirements-deeplearning.txt deleted file mode 100644 index 3c0e3c09..00000000 --- a/requirements-deeplearning.txt +++ /dev/null @@ -1,2 +0,0 @@ -tensorflow>=1.13.1 -torch diff --git a/requirements-linting.txt b/requirements-linting.txt deleted file mode 100644 index d7320de7..00000000 --- a/requirements-linting.txt +++ /dev/null @@ -1,10 +0,0 @@ -flake8 -flake8-bugbear -flake8-blind-except -flake8-breakpoint -flake8-builtins -flake8-logging-format -flake8-pytest-style -flake8-all-not-strings -isort -packaging diff --git a/requirements-test.txt b/requirements-test.txt deleted file mode 100644 index 5a7b5bf3..00000000 --- a/requirements-test.txt +++ /dev/null @@ -1,7 +0,0 @@ -ipython -jupyter -pytest -pytest-cov -twine -pytest-mock -rai_test_utils diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 272e006a..00000000 --- a/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -jsonschema -numpy # if you are using tensorflow 1.x, it requires numpy<=1.16 -pandas>=2.0.0 -scikit-learn -tqdm -raiutils>=0.4.0 -xgboost # if you are using xgboost -lightgbm # if you are using lightgbm \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index edaba5f7..00000000 --- a/setup.py +++ /dev/null @@ -1,53 +0,0 @@ -import setuptools - -VERSION_STR = "0.11" - -with open("README.rst", "r") as fh: - long_description = fh.read() - -# Get the required packages -with open('requirements.txt', encoding='utf-8') as f: - install_requires = f.read().splitlines() - -# Deep learning packages are optional to install -extras = ["deeplearning"] -extras_require = dict() -for e in extras: - req_file = "requirements-{0}.txt".format(e) - with open(req_file) as f: - extras_require[e] = [line.strip() for line in f] - -setuptools.setup( - name="dice_ml", - version=VERSION_STR, - license="MIT", - author="Ramaravind Mothilal, Amit Sharma, Chenhao Tan", - author_email="raam.arvind93@gmail.com", - description="Generate Diverse Counterfactual Explanations for any machine learning model.", - long_description=long_description, - long_description_content_type="text/x-rst", - url="https://github.com/interpretml/DiCE", - download_url="https://github.com/interpretml/DiCE/archive/v"+VERSION_STR+".tar.gz", - python_requires='>=3.9', - packages=setuptools.find_packages(exclude=['tests*']), - classifiers=[ - "Intended Audience :: Developers", - "Intended Audience :: Science/Research", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - ], - keywords='machine-learning explanation interpretability counterfactual', - install_requires=install_requires, - extras_require=extras_require, - include_package_data=True, - package_data={ - # If any package contains *.h5 files, include them: - '': ['*.h5', - 'counterfactual_explanations_v1.0.json', - 'counterfactual_explanations_v2.0.json'] - } -)