From d6b32436ad9648a755e378861a080a54df3c8aa8 Mon Sep 17 00:00:00 2001 From: Nate Parsons <4307001+thehomebrewnerd@users.noreply.github.com> Date: Tue, 19 Mar 2024 12:14:56 -0500 Subject: [PATCH] Restrict Dask and Fix Serialization Tests (#2694) * restrict dask in pyproject.toml * update release notes * fix indent * fix tests * update release notes * lint * lint * try to remove dask * undo --- .pre-commit-config.yaml | 2 +- docs/source/release_notes.rst | 13 +++--- featuretools/entityset/entityset.py | 6 +-- featuretools/feature_base/cache.py | 1 + .../feature_base/features_serializer.py | 10 ++--- .../test_transform_primitive.py | 5 ++- featuretools/tests/profiling/dfs_profile.py | 1 + .../tests/synthesis/test_dfs_method.py | 43 ++++++++++--------- pyproject.toml | 4 +- 9 files changed, 46 insertions(+), 39 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b89b67125b..ba7f7cbe2b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: - id: add-trailing-comma name: Add trailing comma - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.1.6' + rev: 'v0.3.3' hooks: - id: ruff types_or: [ python, pyi, jupyter ] diff --git a/docs/source/release_notes.rst b/docs/source/release_notes.rst index 6cbaea6e3f..20c648195d 100644 --- a/docs/source/release_notes.rst +++ b/docs/source/release_notes.rst @@ -3,15 +3,18 @@ Release Notes ------------- -.. Future Release - ============== +Future Release +============== * Enhancements * Fixes * Changes + * Temporarily restrict Dask version :pr:`2694` * Documentation Changes * Testing Changes + * Fix serialization test to work with pytest 8.1.1 :pr:`2694` -.. Thanks to the following people for contributing to this release: + Thanks to the following people for contributing to this release: + :user:`thehomebrewnerd` v1.30.0 Feb 26, 2024 ==================== @@ -21,8 +24,8 @@ v1.30.0 Feb 26, 2024 * Testing Changes * Update ``make_ecommerce_entityset`` to work without Dask (:pr:`2677`) - Thanks to the following people for contributing to this release: - :user:`tamargrey`, :user:`thehomebrewnerd` + Thanks to the following people for contributing to this release: + :user:`tamargrey`, :user:`thehomebrewnerd` v1.29.0 Feb 16, 2024 ==================== diff --git a/featuretools/entityset/entityset.py b/featuretools/entityset/entityset.py index dacde2ff7d..68c8d49bcb 100644 --- a/featuretools/entityset/entityset.py +++ b/featuretools/entityset/entityset.py @@ -1115,9 +1115,9 @@ def add_last_time_indexes(self, updated_dataframes=None): child_cols = defaultdict(dict) for r in self.relationships: children[r._parent_dataframe_name].append(r.child_dataframe) - child_cols[r._parent_dataframe_name][ - r._child_dataframe_name - ] = r.child_column + child_cols[r._parent_dataframe_name][r._child_dataframe_name] = ( + r.child_column + ) updated_dataframes = updated_dataframes or [] if updated_dataframes: diff --git a/featuretools/feature_base/cache.py b/featuretools/feature_base/cache.py index d765472a4f..88588dc73e 100644 --- a/featuretools/feature_base/cache.py +++ b/featuretools/feature_base/cache.py @@ -3,6 +3,7 @@ Custom caching class, currently used for FeatureBase """ + # needed for defaultdict annotation if < python 3.9 from __future__ import annotations diff --git a/featuretools/feature_base/features_serializer.py b/featuretools/feature_base/features_serializer.py index 33990074db..fc125ed3ba 100644 --- a/featuretools/feature_base/features_serializer.py +++ b/featuretools/feature_base/features_serializer.py @@ -123,12 +123,12 @@ def _feature_definitions(self): # being converted to strings, but integer dict values are not. primitives_dict_key = str(primitive_number) primitive_id_to_key[primitive_id] = primitives_dict_key - self._primitives_dict[ + self._primitives_dict[primitives_dict_key] = ( + serialize_primitive(primitive) + ) + self._features_dict[name]["arguments"]["primitive"] = ( primitives_dict_key - ] = serialize_primitive(primitive) - self._features_dict[name]["arguments"][ - "primitive" - ] = primitives_dict_key + ) primitive_number += 1 else: # Primitive we have seen already - use existing primitive_id key diff --git a/featuretools/tests/primitive_tests/transform_primitive_tests/test_transform_primitive.py b/featuretools/tests/primitive_tests/transform_primitive_tests/test_transform_primitive.py index 3f7986e128..7191f5f930 100644 --- a/featuretools/tests/primitive_tests/transform_primitive_tests/test_transform_primitive.py +++ b/featuretools/tests/primitive_tests/transform_primitive_tests/test_transform_primitive.py @@ -1,3 +1,4 @@ +import warnings from datetime import datetime import numpy as np @@ -388,10 +389,10 @@ def test_week_no_deprecation_message(): datetime(2019, 6, 17, 11, 10, 50), datetime(2019, 11, 30, 19, 45, 15), ] - with pytest.warns(None) as record: + with warnings.catch_warnings(): + warnings.simplefilter("error") week = Week() week(dates).tolist() - assert not record def test_url_to_domain_urls(): diff --git a/featuretools/tests/profiling/dfs_profile.py b/featuretools/tests/profiling/dfs_profile.py index 3541adef71..b0aab79eaf 100644 --- a/featuretools/tests/profiling/dfs_profile.py +++ b/featuretools/tests/profiling/dfs_profile.py @@ -12,6 +12,7 @@ - max_depth > 2 is very slow (currently) - stats output can be viewed online with https://nejc.saje.info/pstats-viewer.html """ + import cProfile from pathlib import Path diff --git a/featuretools/tests/synthesis/test_dfs_method.py b/featuretools/tests/synthesis/test_dfs_method.py index 91c5b06bc0..ed7056bc87 100644 --- a/featuretools/tests/synthesis/test_dfs_method.py +++ b/featuretools/tests/synthesis/test_dfs_method.py @@ -1,3 +1,4 @@ +import warnings from unittest.mock import patch import composeml as cp @@ -87,10 +88,13 @@ def test_dfs_empty_features(): features_only=True, ) assert features == [] - with pytest.raises(AssertionError, match=error_text), patch.object( - DeepFeatureSynthesis, - "build_features", - return_value=[], + with ( + pytest.raises(AssertionError, match=error_text), + patch.object( + DeepFeatureSynthesis, + "build_features", + return_value=[], + ), ): dfs( dataframes, @@ -447,7 +451,8 @@ def test_warns_with_unused_primitives(es): assert record[0].message.args[0] == warning_text # Should not raise a warning - with pytest.warns(None) as record: + with warnings.catch_warnings(): + warnings.simplefilter("error") dfs( entityset=es, target_dataframe_name="customers", @@ -457,13 +462,12 @@ def test_warns_with_unused_primitives(es): features_only=True, ) - assert not record - def test_no_warns_with_camel_and_title_case(es): for trans_primitive in ["isNull", "IsNull"]: # Should not raise a UnusedPrimitiveWarning warning - with pytest.warns(None) as record: + with warnings.catch_warnings(): + warnings.simplefilter("error") dfs( entityset=es, target_dataframe_name="customers", @@ -472,11 +476,10 @@ def test_no_warns_with_camel_and_title_case(es): features_only=True, ) - assert not record - for agg_primitive in ["numUnique", "NumUnique"]: # Should not raise a UnusedPrimitiveWarning warning - with pytest.warns(None) as record: + with warnings.catch_warnings(): + warnings.simplefilter("error") dfs( entityset=es, target_dataframe_name="customers", @@ -485,11 +488,10 @@ def test_no_warns_with_camel_and_title_case(es): features_only=True, ) - assert not record - def test_does_not_warn_with_stacking_feature(pd_es): - with pytest.warns(None) as record: + with warnings.catch_warnings(): + warnings.simplefilter("error") dfs( entityset=pd_es, target_dataframe_name="régions", @@ -501,8 +503,6 @@ def test_does_not_warn_with_stacking_feature(pd_es): features_only=True, ) - assert not record - def test_warns_with_unused_where_primitives(es): if es.dataframe_type == Library.SPARK: @@ -549,7 +549,8 @@ def test_warns_with_unused_groupby_primitives(pd_es): assert record[0].message.args[0] == warning_text # Should not raise a warning - with pytest.warns(None) as record: + with warnings.catch_warnings(): + warnings.simplefilter("error") dfs( entityset=pd_es, target_dataframe_name="customers", @@ -558,8 +559,6 @@ def test_warns_with_unused_groupby_primitives(pd_es): features_only=True, ) - assert not record - def test_warns_with_unused_custom_primitives(pd_es): class AboveTen(TransformPrimitive): @@ -589,7 +588,8 @@ class AboveTen(TransformPrimitive): assert record[0].message.args[0] == warning_text # Should not raise a warning - with pytest.warns(None) as record: + with warnings.catch_warnings(): + warnings.simplefilter("error") dfs( entityset=pd_es, target_dataframe_name="customers", @@ -625,7 +625,8 @@ class MaxAboveTen(AggregationPrimitive): assert record[0].message.args[0] == warning_text # Should not raise a warning - with pytest.warns(None) as record: + with warnings.catch_warnings(): + warnings.simplefilter("error") dfs( entityset=pd_es, target_dataframe_name="sessions", diff --git a/pyproject.toml b/pyproject.toml index 53b7bff00f..51a2bb362e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,8 +65,8 @@ test = [ "pytest-timeout >= 2.1.0" ] dask = [ - "dask[dataframe] >= 2023.2.0", - "distributed >= 2023.2.0", + "dask[dataframe] >= 2023.2.0, <2024.3.0", + "distributed >= 2023.2.0, <2024.3.0", "woodwork[dask] >= 0.28.0", ] spark = [