Skip to content

Commit 0df0159

Browse files
Build: Bump luigi-tools and fix results with Pandas>=3
1 parent 6b845b3 commit 0df0159

4 files changed

Lines changed: 24 additions & 7 deletions

File tree

data_validation_framework/util.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ def _apply_to_df_internal(data):
7373
return num, df.apply(_tqdm_wrapper, axis=1, args=args, **kwargs)
7474

7575

76+
def _restore_object_nulls(result_df, template_df):
77+
"""Restore None values for columns that were object-typed in the input."""
78+
for col, dtype in template_df.dtypes.items():
79+
if col in result_df.columns and pd.api.types.is_object_dtype(dtype):
80+
result_df[col] = result_df[col].astype(object)
81+
result_df.loc[result_df[col].isna(), col] = None
82+
return result_df
83+
84+
7685
def tqdm_worker(progress_bar, tqdm_queue):
7786
"""Update progress bar using the Queue."""
7887
while True:
@@ -155,7 +164,7 @@ def apply_to_df(df, func, *args, nb_processes=None, redirect_stdout=None, **kwar
155164
progress_bar.close()
156165

157166
# Return the results
158-
return all_res
167+
return _restore_object_nulls(all_res, df)
159168

160169

161170
def try_operation(row, func, *args, **kwargs):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
reqs = [
99
"luigi>=3.1",
10-
"luigi-tools>=0.0.18",
10+
"luigi-tools>=0.3.5",
1111
"numpy>=1.21",
1212
"pandas>=1.3",
1313
"rst2pdf>=0.99",

tests/test_task.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
SKIP_IF_NO_LATEXMK = not which("latexmk")
3333
REASON_NO_LATEXMK = "The command latexmk is not available."
34+
# Newer Sphinx/TeX stacks slightly shift pagination while keeping the report content intact.
35+
LATEXPDF_DIFF_THRESHOLD = 15
3436

3537

3638
@pytest.fixture
@@ -2107,7 +2109,9 @@ def test_latexpdf(
21072109
assert (root / "TestWorkflow" / "report.csv").exists()
21082110
assert (root / "report_TestWorkflow.pdf").exists()
21092111
assert pdfdiff(
2110-
root / "report_TestWorkflow.pdf", data_dir / "test_report" / "report_latexpdf.pdf"
2112+
root / "report_TestWorkflow.pdf",
2113+
data_dir / "test_report" / "report_latexpdf.pdf",
2114+
threshold=LATEXPDF_DIFF_THRESHOLD,
21112115
)
21122116

21132117
def test_fail_element_no_exception(
@@ -2443,7 +2447,7 @@ def test_latexpdf(self, tmpdir, dataset_df_path, data_dir, TestWorkflow):
24432447
assert pdfdiff(
24442448
root / "TestWorkflow_specifications.pdf",
24452449
data_dir / "test_report_before_run" / "report_latexpdf.pdf",
2446-
threshold=15,
2450+
threshold=LATEXPDF_DIFF_THRESHOLD,
24472451
)
24482452

24492453
@pytest.fixture
@@ -2502,6 +2506,7 @@ def test_latexpdf_with_config(
25022506
assert pdfdiff(
25032507
root / "TestWorkflow_specifications.pdf",
25042508
data_dir / "test_report_before_run" / "report_latexpdf_with_config.pdf",
2509+
threshold=LATEXPDF_DIFF_THRESHOLD,
25052510
)
25062511

25072512
def test_nested_workflows(

tox.ini

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ commands =
5656
basepython = python3.9
5757
deps =
5858
uv
59+
allowlist_externals =
60+
uv
5961
commands_pre =
6062
uv pip compile \
63+
--python {envpython} \
6164
--resolution lowest-direct \
6265
--extra test \
6366
--output-file {envtmpdir}/requirements_min.txt \
6467
setup.py
65-
pip install -r {envtmpdir}/requirements_min.txt
66-
pip freeze
68+
uv pip install --python {envpython} -r {envtmpdir}/requirements_min.txt
69+
uv pip freeze --python {envpython}
6770

6871
[testenv:lint]
6972
basepython = python3.9
@@ -85,7 +88,7 @@ commands =
8588
pre-commit run --all-files
8689

8790
[testenv:docs]
88-
basepython = python3.9
91+
basepython = python3.11
8992
changedir = docs
9093
extras = docs
9194
allowlist_externals =

0 commit comments

Comments
 (0)