From f105f309645853153e2b350f3a6052a6b9593f7a Mon Sep 17 00:00:00 2001 From: elijahbenizzy Date: Sun, 29 Jan 2023 11:59:47 -0800 Subject: [PATCH 1/3] Deprecated dataclass now passes 3.11 mutability check https://docs.python.org/3/whatsnew/3.11.html#dataclasses --- hamilton/dev_utils/deprecation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hamilton/dev_utils/deprecation.py b/hamilton/dev_utils/deprecation.py index 3e4f12c7..bfa19fc7 100644 --- a/hamilton/dev_utils/deprecation.py +++ b/hamilton/dev_utils/deprecation.py @@ -68,7 +68,7 @@ class parameterized(...): str ] # If this is None, this means that the use_instead is a drop in replacement current_version: Union[Tuple[int, int, int], Version] = dataclasses.field( - default=CURRENT_VERSION + default_factory=lambda: CURRENT_VERSION ) warn_action: Callable[[str], None] = dataclasses.field(default=logger.warning) fail_action: Callable[[str], None] = dataclasses.field( From 6cab4b1c060415b6e28cfc54520526a11c204bc2 Mon Sep 17 00:00:00 2001 From: elijahbenizzy Date: Sun, 29 Jan 2023 15:30:51 -0800 Subject: [PATCH 2/3] Adds python 3.11 support in automated tests --- .circleci/config.yml | 14 +++++++++++++- build_conda.sh | 2 +- setup.py | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9273ac7e..58fb5a23 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ jobs: task: type: string docker: - - image: circleci/python:<< parameters.python-version >> + - image: cimg/python:<< parameters.python-version >> environment: TASK: << parameters.task >> steps: @@ -41,6 +41,10 @@ workflows: name: build-py310 python-version: '3.10' task: tests + - test: + name: build-py311 + python-version: '3.11' + task: tests - test: name: pre-commit python-version: '3.9' @@ -81,6 +85,10 @@ workflows: name: integrations-py310 python-version: '3.10' task: integrations + - test: + name: integrations-py311 + python-version: '3.11' + task: integrations - test: name: asyncio-py39 python-version: '3.9' @@ -89,3 +97,7 @@ workflows: name: asyncio-py310 python-version: '3.10' task: async + - test: + name: asyncio-py311 + python-version: '3.11' + task: async diff --git a/build_conda.sh b/build_conda.sh index e175656d..44613b73 100644 --- a/build_conda.sh +++ b/build_conda.sh @@ -5,7 +5,7 @@ CONDA_HOME=$HOME/anaconda3 # conda activate && anaconda login pkg='sf-hamilton' # adjust the Python versions you would like to build -array=( 3.6 3.7 3.8 3.9 3.10 ) +array=( 3.6 3.7 3.8 3.9 3.10 3.11 ) echo "Building conda package ..." cd ~ # this will create a ~/sf-hamilton directory with metadata to build the package. diff --git a/setup.py b/setup.py index 8247ac6a..3fa41ef3 100644 --- a/setup.py +++ b/setup.py @@ -60,6 +60,7 @@ def load_requirements(): "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ], # Note that this feature requires pep8 >= v9 and a version of setup tools greater than the # default version installed with virtualenv. Make sure to update your tools! From 04afe86b452cd8a5c46d6fc64057f847933fda9c Mon Sep 17 00:00:00 2001 From: elijahbenizzy Date: Sun, 29 Jan 2023 18:20:54 -0800 Subject: [PATCH 3/3] Removes python3.6 support --- .circleci/config.yml | 12 ------------ build_conda.sh | 2 +- graph_adapter_tests/h_async/test_h_async.py | 11 +++-------- graph_adapter_tests/h_dask/test_h_dask.py | 3 --- hamilton/base.py | 6 +----- requirements.txt | 1 - setup.py | 1 - tests/test_end_to_end.py | 3 --- 8 files changed, 5 insertions(+), 34 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 58fb5a23..0b2f9096 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,10 +21,6 @@ jobs: workflows: unit-test-workflow: jobs: - - test: - name: build-py36 - python-version: '3.6' - task: tests - test: name: build-py37 python-version: '3.7' @@ -49,10 +45,6 @@ workflows: name: pre-commit python-version: '3.9' task: pre-commit - - test: - name: dask-py36 - python-version: '3.6' - task: dask - test: name: dask-py37 python-version: '3.7' @@ -65,10 +57,6 @@ workflows: name: spark-py38 python-version: '3.8' task: pyspark - - test: - name: integrations-py36 - python-version: '3.6' - task: integrations - test: name: integrations-py37 python-version: '3.7' diff --git a/build_conda.sh b/build_conda.sh index 44613b73..89abf1b1 100644 --- a/build_conda.sh +++ b/build_conda.sh @@ -5,7 +5,7 @@ CONDA_HOME=$HOME/anaconda3 # conda activate && anaconda login pkg='sf-hamilton' # adjust the Python versions you would like to build -array=( 3.6 3.7 3.8 3.9 3.10 3.11 ) +array=(3.7 3.8 3.9 3.10 3.11 ) echo "Building conda package ..." cd ~ # this will create a ~/sf-hamilton directory with metadata to build the package. diff --git a/graph_adapter_tests/h_async/test_h_async.py b/graph_adapter_tests/h_async/test_h_async.py index fce62780..8d51c9d5 100644 --- a/graph_adapter_tests/h_async/test_h_async.py +++ b/graph_adapter_tests/h_async/test_h_async.py @@ -82,13 +82,8 @@ async def test_driver_end_to_end_telemetry(send_event_json): } # to ensure the last telemetry invocation finishes executing # get all tasks -- and the current task, and await all others. - try: - # only works for 3.7+ - tasks = asyncio.all_tasks() - current_task = asyncio.current_task() - await asyncio.gather(*[t for t in tasks if t != current_task]) - except AttributeError: - # required for 3.6 - await asyncio.sleep(1) + tasks = asyncio.all_tasks() + current_task = asyncio.current_task() + await asyncio.gather(*[t for t in tasks if t != current_task]) assert send_event_json.called assert len(send_event_json.call_args_list) == 2 diff --git a/graph_adapter_tests/h_dask/test_h_dask.py b/graph_adapter_tests/h_dask/test_h_dask.py index 242c8658..e246f8c1 100644 --- a/graph_adapter_tests/h_dask/test_h_dask.py +++ b/graph_adapter_tests/h_dask/test_h_dask.py @@ -1,5 +1,3 @@ -import sys - import pandas as pd import pytest from dask.delayed import delayed @@ -46,7 +44,6 @@ def test_dask_graph_adapter_simple(client): # TODO: do some more asserting? -@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7") def test_smoke_screen_module(client): config = {"region": "US"} dr = driver.Driver(config, smoke_screen_module, adapter=h_dask.DaskGraphAdapter(client)) diff --git a/hamilton/base.py b/hamilton/base.py index f80c3cd9..64a36ed9 100644 --- a/hamilton/base.py +++ b/hamilton/base.py @@ -72,12 +72,8 @@ def index_key_name(pd_object: Union[pd.DataFrame, pd.Series]) -> str: def get_parent_time_index_type(): """Helper to pull the right time index parent class.""" - if hasattr( - pd_extension, "NDArrayBackedExtensionIndex" - ): # for python 3.7+ & pandas >= 1.2 + if hasattr(pd_extension, "NDArrayBackedExtensionIndex"): index_type = pd_extension.NDArrayBackedExtensionIndex - elif hasattr(pd_extension, "ExtensionIndex"): # for python 3.6 & pandas <= 1.2 - index_type = pd_extension.ExtensionIndex else: index_type = None # weird case, but not worth breaking for. return index_type diff --git a/requirements.txt b/requirements.txt index f1314b21..ac8e73d3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -dataclasses; python_version < '3.7' numpy pandas typing_inspect diff --git a/setup.py b/setup.py index 3fa41ef3..d03749cd 100644 --- a/setup.py +++ b/setup.py @@ -55,7 +55,6 @@ def load_requirements(): "Natural Language :: English", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", diff --git a/tests/test_end_to_end.py b/tests/test_end_to_end.py index bc283671..bcdc8cd2 100644 --- a/tests/test_end_to_end.py +++ b/tests/test_end_to_end.py @@ -1,5 +1,3 @@ -import sys - import pytest import hamilton.driver @@ -34,7 +32,6 @@ def test_data_quality_workflow_fails(): ) -@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7") def test_smoke_screen_module(): config = {"region": "US"} dr = hamilton.driver.Driver(config, tests.resources.smoke_screen_module)