Skip to content

Commit

Permalink
Merge pull request #258 from lvgig/257-bug-datetimeinfoextractor-prev…
Browse files Browse the repository at this point in the history
…ents-pipeline-from-being-saved-using-joblib-or-pickle

🐛 set mappings_provided to list type so object is picklable
  • Loading branch information
davidhopkinson26 authored Jul 1, 2024
2 parents a7ff0e7 + cf55df0 commit 5546831
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ Subsections for each version can be one of the following;
- ``Security`` in case of vulnerabilities.

Each individual change should have a link to the pull request after the description of the change.
1.3.1 (unreleased)
------------------

Changed
^^^^^^^
- DatetimeInfoExtractor.mappings_provided changed from a dict.keys() object to list so transformer is serialisable. `#258 <https://github.com/lvgig/tubular/pull/258>`_

1.3.0 (2024-06-13)
------------------
Expand Down
7 changes: 7 additions & 0 deletions tests/base_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import copy
import re

import joblib
import numpy as np
import pandas as pd
import pytest
Expand Down Expand Up @@ -816,3 +817,9 @@ class OtherBaseBehaviourTests(
Class to collect and hold tests for BaseTransformerBehaviour outside the three standard methods.
Note this deliberately avoids starting with "Tests" so that the tests are not run on import.
"""

def test_is_serialisable(self, initialized_transformers, tmp_path):
path = tmp_path / "transformer.pkl"

# serialise without raising error
joblib.dump(initialized_transformers[self.transformer_name], path)
10 changes: 10 additions & 0 deletions tests/dates/test_DateTimeInfoExtractor.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import joblib
import numpy as np
import pandas as pd
import pytest
Expand Down Expand Up @@ -391,3 +392,12 @@ def test_correct_df_returned_datetime_input(self):
expected,
"incorrect dataframe returned",
)

def test_is_serialisable(self, tmp_path):
transformer = DatetimeInfoExtractor(columns=["b"], include=["timeofyear"])

# pickle transformer
path = tmp_path / "transformer.pkl"

# serialise without raising error
joblib.dump(transformer, path)
2 changes: 1 addition & 1 deletion tubular/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.3.0"
__version__ = "1.3.1"
2 changes: 1 addition & 1 deletion tubular/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ def __init__(

self.include = include
self.datetime_mappings = datetime_mappings
self.mappings_provided = self.datetime_mappings.keys()
self.mappings_provided = list(self.datetime_mappings.keys())

self._process_provided_mappings()

Expand Down

0 comments on commit 5546831

Please sign in to comment.