Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fkml logs object bugfix #234

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [3.0.1] - 2023-12-07
- **Bugfix**
- Fix pipeline logs to actually return learners objects in \_\_fkml__.learners dicts.

## [3.0.0] - 2023-11-08
- **Enhancement**
- Remove support for python 3.6 and 3.7.
Expand Down
2 changes: 1 addition & 1 deletion src/fklearn/resources/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.0
3.0.1
4 changes: 2 additions & 2 deletions src/fklearn/training/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def pipeline(data: pd.DataFrame) -> LearnerReturnType:
current_data = new_data

model_objects = {}
if learner_log.get("obj"):
model_objects["obj"] = learner_log.pop("obj")
if learner_log.get("object"):
model_objects["object"] = learner_log.pop("object")

serialisation[learner_name].append({"fn": learner_fn, "log": learner_log, **model_objects})
logs.append(learner_log)
Expand Down
2 changes: 1 addition & 1 deletion src/fklearn/validation/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def get_perturbed_columns(perturbator: PerturbFnType) -> List[str]:

train_logs, validator_logs = zip(*map(_join_split_log, zipped_logs))
if return_all_train_logs:
train_logs = {"train_log": [log["train_log"] for log in train_logs]}
train_logs = {"train_log": [log["train_log"] for log in train_logs]} # type: ignore
else:
train_logs = first(train_logs)

Expand Down
8 changes: 4 additions & 4 deletions tests/training/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def dummy_learner_2(df, fn, call):

@fp.curry
def dummy_learner_3(df, fn, call):
return fn, df, {f"dummy_learner_{call}": {}, "obj": "a"}
return fn, df, {f"dummy_learner_{call}": {}, "object": "a"}

train_fn = build_pipeline(
dummy_learner(fn=fn, call=1),
Expand All @@ -166,10 +166,10 @@ def dummy_learner_3(df, fn, call):
"features": ['id', 'x1', 'y'],
"learners": {"dummy_learner": {"fn": fn, "log": {"dummy_learner_1": {}}},
"dummy_learner_2": {"fn": fn, "log": {"dummy_learner_2": {}}},
"dummy_learner_3": {"fn": fn, "log": {"dummy_learner_3": {}}, "obj": "a"}}}
"dummy_learner_3": {"fn": fn, "log": {"dummy_learner_3": {}}, "object": "a"}}}

assert log["__fkml__"] == fkml
assert "obj" not in log.keys()
assert "object" not in log.keys()


@pytest.mark.parametrize("has_repeated_learners", [False, True])
Expand Down Expand Up @@ -247,4 +247,4 @@ def dummy_learner_2(df, fn, call):
"dummy_learner_2": [{"fn": fn, "log": {"dummy_learner_2": {}}}]}}

assert log["__fkml__"] == fkml
assert "obj" not in log.keys()
assert "object" not in log.keys()