Skip to content

Commit 4a1216f

Browse files
authored
SEOD-1326. Bump fireant to pandas version 2 (#366)
* SEOD-1326. Bump fireant to pandas version 2 - Bump fireant version to 8.0.0 - Drop support for Python3.7 as pandas v2 does not support it - Add Python3.9 support - Use the newest `pandas` (2.0.3 in requirements) and add the minimum version 2.0.0 of `pandas` to pyproject.toml - Use the newest `vertica-python` (1.3.4 in requirements) and add the minimum version 1.0.0 of `vertica-python` to pyproject.toml - Use the newest `snowflake-connector-python` (3.0.4 in requirements) and add the minimum version 3.0.0 of `snowflake-connector-python` to pyproject.toml - Use the newest `coverage` (7.3.0 in requirements) and add the minimum version 7.3.0 of `coverage` to pyproject.toml - Use the newest `watchdog` (3.0.0 in requirements) and add the minimum version 3.0.0 of `watchdiog` to pyproject.toml - Remove `python-dateutil` from dependencies as it is part of other libraries' dependencies - Bump `psycopg-binary==2.9.6` though it seems not needed for the tests - Bump `pymssql==2.2.7` though it seems not needed for the tests - Bump `Cython==3.0.0` though it seems not needed for the tests - Get rid of `SyntaxWarning: "is" with a literal. Did you mean "=="?` - Get rid of `DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working` - Replace `Dataframe.append` to `pd.concat` because `append` does not exist since pandas v2 - Add `group_keys=False` to `DataFrame.groupby()` method because it is no longer ignored since pandas v1.5 - Fix `_apply_share` method for `Share`s with the new libraries. - Rename `TestDatabase` to `MockDatabase` since it is used only for mocking. This is beneficial also because Python testing method will not delve into it to find methods to run - Rename `test_connect` and `test_fetch` to `mock_connect` and `mock_fetch` as these are mocks. This is beneficial also because Python testing method will not delve into it to find methods to run - Rename `TestMySQLDatabase` to `MockMySQLDatabase` for the same reason - When concatenating `DataFrames`, use `.tail(1)` instead of `.iloc[-1]` as it includes indexes - Use static CSVs to get the expected `DataFrames` in tests instead of applying methods of `fireant` to a `DataFrame` to get those expected `DataFrames` - Replace `np.float` to `float` since it was deprecated - Get rid of `None` and `[]` as `ascending` parameters for `Pandas` class - Replace `.iteritems()` with `.items()` as the former method was deprecated
1 parent f10a5c0 commit 4a1216f

File tree

11 files changed

+57
-36
lines changed

11 files changed

+57
-36
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
2023 July
22

3-
#### [7.10.0] - 2023-08-29
4-
- Bump fireant version to 7.10.0
3+
4+
#### [8.0.0] - 2023-08-29
5+
- Bump fireant version to 8.0.0
56
- Drop support for Python3.7 as pandas v2 does not support it
67
- Add Python3.9 support
78
- Use the newest `pandas` (2.0.3 in requirements) and add the minimum version 2.0.0 of `pandas` to pyproject.toml

fireant/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ def __hash__(self) -> int:
5555
Term.__hash__ = __hash__
5656

5757

58-
__version__ = "7.9.0"
58+
__version__ = "8.0.0"

fireant/database/base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,11 @@ def make_slicer_query_with_totals_and_references(
195195
)
196196

197197
for reference_parts, references in reference_groups_and_none:
198-
(dimensions_with_ref, metrics_with_ref, filters_with_ref,) = self.adapt_for_reference_query(
198+
(
199+
dimensions_with_ref,
200+
metrics_with_ref,
201+
filters_with_ref,
202+
) = self.adapt_for_reference_query(
199203
reference_parts,
200204
dimensions_with_totals,
201205
metrics,
@@ -301,7 +305,7 @@ def make_slicer_query(
301305
# In the case that the orders are determined by a field that is not selected as a metric or dimension, then it needs
302306
# to be added to the query.
303307
select_aliases = {el.alias for el in query._selects}
304-
for (orderby_field, orientation) in orders:
308+
for orderby_field, orientation in orders:
305309
orderby_term = self.transform_field_to_query(orderby_field)
306310
query = query.orderby(orderby_term, order=orientation)
307311

fireant/queries/builder/dataset_blender_query_builder.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def _deepcopy_recursive(node):
243243
if hasattr(node, '_cases'):
244244
cloned_cases = []
245245

246-
for (criterion, value) in cloned_node._cases:
246+
for criterion, value in cloned_node._cases:
247247
cloned_cases.append((_deepcopy_recursive(criterion), _deepcopy_recursive(value)))
248248

249249
cloned_node._cases = cloned_cases
@@ -423,7 +423,6 @@ def sql(self):
423423
# First determine the metrics. If a a metric is requested, and the dataset has it, add it for that dataset.
424424
# We include metrics used in filters. We also save for each dataset the mapped metrics and filters
425425
for dataset_index, dataset in enumerate(datasets):
426-
427426
dataset_metrics.append(
428427
map_blender_fields_to_dataset_fields(
429428
selected_metrics_as_dataset_fields,
@@ -478,7 +477,7 @@ def sql(self):
478477
for dimension_dataset_info in dimensions_dataset_info:
479478
dimension_accounted_for = False
480479
first_dataset_that_has_the_dimension = None
481-
for (dataset_index, mapped_dimension, is_selected_dimension) in dimension_dataset_info:
480+
for dataset_index, mapped_dimension, is_selected_dimension in dimension_dataset_info:
482481
# If the dataset is already part of the final query, add this dimension
483482
if dataset_included_in_final_query[dataset_index]:
484483
dimension_accounted_for = True

fireant/tests/dataset/mocks.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,13 +728,19 @@ def _totals(df):
728728

729729
dimx2_date_str_totalsx2_share_over_first_series = pd.read_csv(
730730
os.path.dirname(os.path.realpath(__file__)) + "/mocks/dimx2_date_str_totalsx2_share_over_first_df.csv",
731-
index_col=['$timestamp', '$political_party',],
731+
index_col=[
732+
'$timestamp',
733+
'$political_party',
734+
],
732735
parse_dates=['$timestamp'],
733736
).squeeze()
734737

735738
dimx2_date_str_totalsx2_share_over_second_series = pd.read_csv(
736739
os.path.dirname(os.path.realpath(__file__)) + "/mocks/dimx2_date_str_totalsx2_share_over_second_df.csv",
737-
index_col=['$timestamp', '$political_party',],
740+
index_col=[
741+
'$timestamp',
742+
'$political_party',
743+
],
738744
parse_dates=['$timestamp'],
739745
).squeeze()
740746

@@ -744,7 +750,11 @@ def _totals(df):
744750

745751
dimx3_date_str_str_totals_df = pd.read_csv(
746752
os.path.dirname(os.path.realpath(__file__)) + "/mocks/dimx3_date_str_str_totals_df.csv",
747-
index_col=['$timestamp', '$political_party', '$state',],
753+
index_col=[
754+
'$timestamp',
755+
'$political_party',
756+
'$state',
757+
],
748758
parse_dates=['$timestamp'],
749759
)
750760

fireant/tests/dataset/test_execution.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,12 @@ def test_reduce_single_result_set_with_str_dimension(self):
288288
pandas.testing.assert_frame_equal(expected, result)
289289

290290
def test_reduce_single_result_set_with_dimx2_date_str_totals_date(self):
291-
expected = pd.concat([
292-
dimx2_date_str_totalsx2_df.loc[(slice(None), slice("Democrat", "Republican")), :],
293-
dimx2_date_str_totalsx2_df.tail(1),
294-
])
291+
expected = pd.concat(
292+
[
293+
dimx2_date_str_totalsx2_df.loc[(slice(None), slice("Democrat", "Republican")), :],
294+
dimx2_date_str_totalsx2_df.tail(1),
295+
]
296+
)
295297

296298
raw_df = replace_totals(dimx2_date_str_df)
297299
totals_df = pd.merge(
@@ -351,10 +353,12 @@ def test_reduce_single_result_set_with_dimx2_date_str_str_totals_date(self):
351353
pandas.testing.assert_frame_equal(expected, result)
352354

353355
def test_reduce_single_result_set_with_date_str_str_dimensions_str1_totals(self):
354-
expected = pd.concat([
355-
dimx3_date_str_str_totalsx3_df.loc[(slice(None), slice(None), slice("California", "Texas")), :],
356-
dimx3_date_str_str_totalsx3_df.loc[(slice(None), "~~totals"), :].iloc[:-1],
357-
]).sort_index()
356+
expected = pd.concat(
357+
[
358+
dimx3_date_str_str_totalsx3_df.loc[(slice(None), slice(None), slice("California", "Texas")), :],
359+
dimx3_date_str_str_totalsx3_df.loc[(slice(None), "~~totals"), :].iloc[:-1],
360+
]
361+
).sort_index()
358362

359363
raw_df = replace_totals(dimx3_date_str_str_df)
360364
totals_df = raw_df.groupby("$timestamp").sum().reset_index()
@@ -408,18 +412,17 @@ def test_reduce_single_result_set_with_date_str_str_dimensions_str1_totals_with_
408412
nulls_totals[index_names[1]] = "~~totals"
409413
nulls_totals[index_names[2]] = "~~totals"
410414

411-
expected = pd.concat([
412-
dimx3_date_str_str_totalsx3_df.loc[(slice(None), slice(None), slice("1", "2")), :],
413-
dimx3_date_str_str_totalsx3_df.loc[(slice(None), "~~totals"), :].tail(1),
414-
nulls.set_index(index_names),
415-
nulls_totals.set_index(index_names),
416-
]).sort_index()
415+
expected = pd.concat(
416+
[
417+
dimx3_date_str_str_totalsx3_df.loc[(slice(None), slice(None), slice("1", "2")), :],
418+
dimx3_date_str_str_totalsx3_df.loc[(slice(None), "~~totals"), :].tail(1),
419+
nulls.set_index(index_names),
420+
nulls_totals.set_index(index_names),
421+
]
422+
).sort_index()
417423

418424
raw_df = replace_totals(dimx3_date_str_str_df)
419-
raw_df = pd.concat([
420-
nulls,
421-
raw_df
422-
]).sort_values(["$timestamp", "$political_party", "$state"])
425+
raw_df = pd.concat([nulls, raw_df]).sort_values(["$timestamp", "$political_party", "$state"])
423426

424427
totals_df = raw_df.groupby("$timestamp").sum().reset_index()
425428
null_totals_df = pd.DataFrame([raw_df[raw_df["$timestamp"].isnull()][metrics].sum()])

fireant/tests/dataset/test_filter_totals_from_share_results.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ def test_do_not_remove_totals_for_rollup_dimensions_with_multiindex_and_higher_d
8282
dimx2_date_str_totalsx2_df, [Rollup(mock_dataset.fields.timestamp), mock_dataset.fields.political_party]
8383
)
8484

85-
expected = pd.concat([
86-
dimx2_date_str_totalsx2_df.loc[(slice(None), slice('Democrat', 'Republican')), :],
87-
dimx2_date_str_totalsx2_df.tail(1),
88-
])
85+
expected = pd.concat(
86+
[
87+
dimx2_date_str_totalsx2_df.loc[(slice(None), slice('Democrat', 'Republican')), :],
88+
dimx2_date_str_totalsx2_df.tail(1),
89+
]
90+
)
8991

9092
pandas.testing.assert_frame_equal(result, expected)
9193

fireant/tests/queries/test_build_sets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
],
2626
)
2727

28+
2829
# noinspection SqlDialectInspection,SqlNoDataSourceInspection
2930
class ResultSetTests(TestCase):
3031
maxDiff = None

fireant/tests/widgets/test_matplotlib.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ def test_single_metric_line_chart(self):
2626

2727
self.assertEqual(1, len(result))
2828

29-
3029
except ImportError:
3130
pass

fireant/tests/widgets/test_pandas.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,9 @@ def test_use_first_value_for_ascending_when_arg_has_invalid_length(self):
573573

574574
def test_use_pandas_default_for_ascending_when_arg_empty_list(self):
575575
result = Pandas(
576-
mock_dataset.fields.votes, pivot=[mock_dataset.fields.political_party], sort=[0, 2],
576+
mock_dataset.fields.votes,
577+
pivot=[mock_dataset.fields.political_party],
578+
sort=[0, 2],
577579
).transform(dimx2_date_str_df, [mock_dataset.fields.timestamp, mock_dataset.fields.political_party], [])
578580

579581
expected = dimx2_date_str_df.copy()[[f('votes')]]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "fireant"
3-
version = "7.10.0"
3+
version = "8.0.0"
44
description = ""
55
authors = ["Ąžuolas Krušna <akrusna@kayak.com>"]
66
readme = "README.rst"

0 commit comments

Comments
 (0)