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

feat: support generic metric hooks to replace specific external parser one #3929

Merged
merged 4 commits into from May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions vowpalwabbit/core/include/vw/core/global_data.h
Expand Up @@ -9,6 +9,7 @@
#include "vw/core/constant.h"
#include "vw/core/error_reporting.h"
#include "vw/core/interactions_predict.h"
#include "vw/core/metric_sink.h"
#include "vw/core/version.h"
#include "vw/core/vw_fwd.h"
#include "vw/io/logger.h"
Expand Down Expand Up @@ -167,6 +168,9 @@ struct workspace
#ifdef BUILD_EXTERNAL_PARSER
std::unique_ptr<VW::external::parser> external_parser;
#endif
// This field is experimental and subject to change.
// Used to implement the external binary parser.
std::vector<std::function<void(VW::metric_sink&)>> metric_output_hooks;
std::string data_filename;

bool daemon;
Expand Down
2 changes: 2 additions & 0 deletions vowpalwabbit/core/src/reductions/metrics.cc
Expand Up @@ -148,6 +148,8 @@ void VW::reductions::output_metrics(VW::workspace& all)
if (all.external_parser) { all.external_parser->persist_metrics(list_metrics); }
#endif

for (auto& metric_hook : all.metric_output_hooks) { metric_hook(list_metrics); }

list_metrics.set_uint("total_log_calls", all.logger.get_log_count());

std::vector<std::string> enabled_reductions;
Expand Down