Skip to content

Commit

Permalink
Fix reportables not using correct name in render function
Browse files Browse the repository at this point in the history
Fixes #46
  • Loading branch information
WarmCyan committed Apr 26, 2023
1 parent fbab3aa commit c13560c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.13.1] - 2023-04-26

### Fixed
* Reportables that implement render using the old `name` instead of `qualified_name`, causing
unintended figure image overwrites.




## [0.13.0] - 2023-04-21

### Added
Expand Down
2 changes: 1 addition & 1 deletion curifactory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
stage,
)

__version__ = "0.13.0"
__version__ = "0.13.1"
8 changes: 4 additions & 4 deletions curifactory/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,11 @@ def render(self):
if "format" not in self.kwargs:
self.kwargs["format"] = "png"
self.fig.savefig(
f"{self.path}/{self.name}.{self.kwargs['format']}", **self.kwargs
f"{self.path}/{self.qualified_name}.{self.kwargs['format']}", **self.kwargs
)

def html(self):
return f"<img src='{self.path}/{self.name}.{self.kwargs['format']}'>"
return f"<img src='{self.path}/{self.qualified_name}.{self.kwargs['format']}'>"


class LinePlotReporter(Reportable):
Expand Down Expand Up @@ -315,13 +315,13 @@ def render(self):
if "format" not in self.savefig_kwargs:
self.savefig_kwargs["format"] = "png"
fig.savefig(
f"{self.path}/{self.name}.{self.savefig_kwargs['format']}",
f"{self.path}/{self.qualified_name}.{self.savefig_kwargs['format']}",
**self.savefig_kwargs,
)
plt.close()

def html(self):
return f"<img src='{self.path}/{self.name}.{self.savefig_kwargs['format']}'>"
return f"<img src='{self.path}/{self.qualified_name}.{self.savefig_kwargs['format']}'>"


def render_report_head(manager) -> list[str]:
Expand Down
2 changes: 2 additions & 0 deletions examples/minimal/experiments/newsgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def train_model(record, training_data):
clf = MLPClassifier(args.layers, activation=args.activation).fit(
training_data[0], training_data[1]
)

record.report(LinePlotReporter(clf.loss_curve_, name="loss"))
return clf


Expand Down

0 comments on commit c13560c

Please sign in to comment.