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

Verbose config check #483

Merged
merged 3 commits into from
Dec 4, 2018
Merged

Verbose config check #483

merged 3 commits into from
Dec 4, 2018

Conversation

avishekrk
Copy link
Contributor

This PR adds:

  • verbose output for the config validator to better check errors
  • outputs the timechop figure to a png

@@ -328,16 +328,19 @@ def _validate_imputations(self, aggregation_config):
agg_types = ["aggregates", "categoricals", "array_categoricals"]

for agg_type in agg_types:
logging.info('agg_type:{}'.format(agg_type))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use logging variables instead of formatted strings:
logging.info('agg_type: %s', agg_type)

This has two advantanges:

  • logging module doesn't do the interpolation unless the message is actually visible (minor win)
  • and enables log aggregators to more intelligently aggregate logfiles. For instance, if a message gets logged multiple times with different arguments, log aggregators are smart enough to aggregate them together but this is not possible with formatted strings.

And the intros should be a bit more descriptive. 'Checking imputation rules for aggregation type %s', 'Checking imputation rules for aggregation %s', 'Checking imputation rules for metric %s'

@@ -110,4 +112,5 @@ def visualize_chops(chopper, show_as_of_times=True, show_boundaries=True):
ax[0].set_title("Timechop: Temporal cross-validation blocks")
fig.subplots_adjust(hspace=0)
plt.setp([a.get_xticklabels() for a in fig.axes[:-1]], visible=False)
plt.savefig('timechop.png')
Copy link
Contributor

@thcrock thcrock Oct 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this going to break (and never call show) if whatever is running doesn't have write access to whatever directory this ends up being? Furthermore, if this breaks in a notebook setting (when the user is just trying to plot it to the screen), it will break their simple displaying use case for the sake of filesystem saving functionality that they don't even care about.

I think there's a lot that we can do to make this more robust (integrate it with the ProjectStorage via the CLI, etc) but the bare minimum for this pull request I think should be to just plot to an optional target instead of hardcoding a filesystem path. We do this in the audition plotting module for an example.

https://github.com/dssg/triage/blob/master/src/triage/component/audition/plotting.py#L217-L218

Just have the save target be an optional argument, and conditionally save it like this:

if path_to_save:
    plt.savefig(path_to_save)

And we can make the implementation more complete in a future PR

@thcrock thcrock self-assigned this Dec 4, 2018
@thcrock thcrock merged commit fb42275 into master Dec 4, 2018
@thcrock thcrock deleted the verbose_config_check branch December 4, 2018 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants