Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Python 3.12 #775

Merged
merged 9 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/minimum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
os: [ubuntu-latest, macos-latest] # skip windows bc rundoc fails
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Requirements

**RDT** has been developed and tested on
[Python 3.8, 3.9, 3.10 and 3.11](https://www.python.org/downloads/)
[Python 3.8, 3.9, 3.10, 3.11 and 3.12](https://www.python.org/downloads/)

Also, although it is not strictly required, the usage of a [virtualenv](
https://virtualenv.pypa.io/en/latest/) is highly recommended in order to avoid
Expand Down
17 changes: 10 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,28 @@ classifiers = [
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
]
keywords = ['machine learning', 'synthetic data generation', 'benchmark', 'generative models']
dynamic = ['version']
license = { text = 'BSL-1.1' }
requires-python = '>=3.8,<3.12'
requires-python = '>=3.8,<3.13'
readme = 'README.md'
dependencies = [
"numpy>=1.20.0;python_version<'3.10'",
"numpy>=1.23.3;python_version>='3.10'",
"numpy>=1.23.3;python_version>='3.10' and python_version<'3.12'",
"numpy>=1.26.0;python_version>='3.12'",
"pandas>=1.1.3;python_version<'3.10'",
"pandas>=1.3.4;python_version>='3.10' and python_version<'3.11'",
"pandas>=1.5.0;python_version>='3.11'",
"scipy>=1.5.4;python_version<'3.10'",
"scipy>=1.9.2;python_version>='3.10'",
"scipy>=1.9.2;python_version>='3.10' and python_version<'3.12'",
"scipy>=1.12.0;python_version>='3.12'",
"scikit-learn>=0.24;python_version<'3.10'",
"scikit-learn>=1.1.0;python_version>='3.10' and python_version<'3.11'",
"scikit-learn>=1.1.3;python_version>='3.11'",
"scikit-learn>=1.1.3;python_version>='3.11' and python_version<'3.12'",
"scikit-learn>=1.3.0;python_version>='3.12'",
'Faker>=17',
]

Expand All @@ -44,7 +48,7 @@ dependencies = [
rdt = { main = 'rdt.cli.__main__:main' }

[project.optional-dependencies]
copulas = ['copulas>=0.10.0',]
copulas = ['copulas@git+https://[email protected]/sdv-dev/copulas.git',]
test = [
'rdt[copulas]',

Expand All @@ -63,7 +67,7 @@ dev = [
'build>=1.0.0,<2',
'bump-my-version>=0.18.3,<1',
'pip>=9.0.1',
'watchdog>=0.8.3,<0.11',
'watchdog>=1.0.1,<5',

# style check
'pycodestyle<2.8.0,>=2.7.0',
Expand Down Expand Up @@ -133,7 +137,6 @@ namespaces = false
'*.png',
'*.gif'
]
'tests' = ['*']

[tool.setuptools.exclude-package-data]
'*' = [
Expand Down
10 changes: 8 additions & 2 deletions rdt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

import sys
import warnings
from importlib.metadata import entry_points
from operator import attrgetter
from types import ModuleType

import numpy as np
import pandas as pd
from pkg_resources import iter_entry_points

from rdt import transformers
from rdt.hyper_transformer import HyperTransformer
Expand Down Expand Up @@ -149,7 +149,13 @@ def _find_addons():
from top_module.addon_module import x
"""
group = 'rdt_modules'
for entry_point in iter_entry_points(group=group):
try:
eps = entry_points(group=group) # pylint: disable=E1123
except TypeError:
# Load-time selection requires Python >= 3.10 or importlib_metadata >= 3.6
eps = entry_points().get(group, [])

for entry_point in eps:
try:
addon = entry_point.load()
except Exception: # pylint: disable=broad-exception-caught
Expand Down
32 changes: 25 additions & 7 deletions tests/unit/test___init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_get_demo_many_rows():
pd.testing.assert_frame_equal(demo, expected)


@patch.object(rdt, 'iter_entry_points')
@patch.object(rdt, 'entry_points')
def test__find_addons_module(entry_points_mock, mock_rdt):
"""Test loading an add-on."""
# Setup
Expand All @@ -75,7 +75,25 @@ def test__find_addons_module(entry_points_mock, mock_rdt):
assert sys.modules['rdt.submodule.entry_name'] == add_on_mock


@patch.object(rdt, 'iter_entry_points')
@patch.object(rdt, 'entry_points')
def test__find_addons_type_error(entry_points_mock):
"""Test it when entry_points raises a TypeError (happens for py38, py39)."""
# Setup
def side_effect(arg=None):
if arg == 'rdt_modules':
raise TypeError()
return {arg: []}

entry_points_mock.side_effect = side_effect

# Run
_find_addons()

# Assert
entry_points_mock.assert_called_with()


@patch.object(rdt, 'entry_points')
def test__find_addons_object(entry_points_mock, mock_rdt):
"""Test loading an add-on."""
# Setup
Expand All @@ -93,7 +111,7 @@ def test__find_addons_object(entry_points_mock, mock_rdt):


@patch('warnings.warn')
@patch('rdt.iter_entry_points')
@patch('rdt.entry_points')
def test__find_addons_bad_addon(entry_points_mock, warning_mock):
"""Test failing to load an add-on generates a warning."""
# Setup
Expand All @@ -116,7 +134,7 @@ def entry_point_error():


@patch('warnings.warn')
@patch('rdt.iter_entry_points')
@patch('rdt.entry_points')
def test__find_addons_wrong_base(entry_points_mock, warning_mock):
"""Test incorrect add-on name generates a warning."""
# Setup
Expand All @@ -137,7 +155,7 @@ def test__find_addons_wrong_base(entry_points_mock, warning_mock):


@patch('warnings.warn')
@patch('rdt.iter_entry_points')
@patch('rdt.entry_points')
def test__find_addons_missing_submodule(entry_points_mock, warning_mock):
"""Test incorrect add-on name generates a warning."""
# Setup
Expand All @@ -158,7 +176,7 @@ def test__find_addons_missing_submodule(entry_points_mock, warning_mock):


@patch('warnings.warn')
@patch('rdt.iter_entry_points')
@patch('rdt.entry_points')
def test__find_addons_module_and_object(entry_points_mock, warning_mock):
"""Test incorrect add-on name generates a warning."""
# Setup
Expand All @@ -179,7 +197,7 @@ def test__find_addons_module_and_object(entry_points_mock, warning_mock):


@patch('warnings.warn')
@patch.object(rdt, 'iter_entry_points')
@patch.object(rdt, 'entry_points')
def test__find_addons_missing_object(entry_points_mock, warning_mock, mock_rdt):
"""Test incorrect add-on name generates a warning."""
# Setup
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py39-lint, py39-performance, py3{8,9,10,11}-{readme,unit,integration,minimum}
envlist = py39-lint, py39-performance, py3{8,9,10,11,12}-{readme,unit,integration,minimum}

[testenv]
skipsdist = false
Expand Down
Loading