-
Notifications
You must be signed in to change notification settings - Fork 1.7k
dataclass_compat: track initial tag metadata #3512
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
Conversation
Summary: We initially used `dataclass_compat` to perform filtering of large graphs as a stopgap mechanism. This commit moves that filtering into the uploader, which is the only surface in which it’s actually used. As a result, `dataclass_compat` no longer takes extra arguments and so can be moved into `EventFileLoader` in a future change. Test Plan: Unit tests added to the uploader for the small graph, large graph, and corrupt graph cases. wchargin-branch: uploader-graph-filtering wchargin-source: 00af6ebe200fe60aacbc23f468eb44126d2d33f7
Summary: The `data_compat` and `dataclass_compat` transforms are now effected by the `EventFileLoader` class. The event accumulator and uploader therefore no longer need to effect these transformations manually. Test Plan: Unit tests that use mocking have been updated to apply compat transforms manually. Using the uploader with `--plugin scalars,graphs` still works as intended. wchargin-branch: efl-compat-transforms wchargin-source: d5b86d851f5dff6f24ddc8cfac52c740ab8af1b3
Summary: The `dataclass_compat` transform dispatches on plugin name, which is stored in the summary metadata. But the semantics of summary metadata is that it need only be set in the first event of each time series. Thus, until now, events past the first step of a time series have not been modified by `dataclass_compat`. This has been fine because all transformations have been either (a) only metadata transforms (which don’t matter after the first step anyway) or (b) tensor transforms to hparams data (which only ever has one step anyway). But an upcoming change will need to transform every step of each audio time series, so we need to identify which summaries have audio data even when they don’t have plugin name set on the same event. To do so, we let `dataclass_compat` update a stateful map from tag name to the first `SummaryMetadata` seen for that time series (scoped to a particular run). Test Plan: Some unit tests included now; the tests for migration of audio summaries will be more complete because they have more interesting things to test. wchargin-branch: dataclass-compat-initial-metadata wchargin-source: 364d3b33f32452e8d3ac9468e6bcca4de876963a
wchargin-branch: uploader-graph-filtering wchargin-source: 9179acc76158380d9f254df1d0a0aae1ec82df6c
wchargin-branch: efl-compat-transforms wchargin-source: 4fa593a34147c7b05c7f4c55f3ce9279242a7414
wchargin-branch: uploader-graph-filtering wchargin-source: b89f6da9cd740080aefecec49194752b0de85dd4
wchargin-branch: efl-compat-transforms wchargin-source: 8abfd3ec5c7394e7b1930b4bf42d2de816e67da4 # Conflicts: # tensorboard/uploader/uploader.py
wchargin-branch: efl-compat-transforms wchargin-source: 8abfd3ec5c7394e7b1930b4bf42d2de816e67da4
wchargin-branch: dataclass-compat-initial-metadata wchargin-source: cfd81441162803b6bab104bc76d93c3b00e8c381
Summary: Fixes an oversight in #3507: we can’t assert that the raw bytes are what was expected because the code under test does a proto serialization roundtrip, which is permitted to permute keys. Test Plan: Tests still pass, and this should fix an internal sync error. wchargin-branch: uploader-test-proto-equal
wchargin-branch: uploader-graph-filtering wchargin-source: 30f0764698d66cdaf481c797dc56bf6a34ae3ae0
wchargin-branch: efl-compat-transforms wchargin-source: f18ea5648a96010b48237fe7743e5f5d0d535acb
wchargin-branch: dataclass-compat-initial-metadata wchargin-source: 9f516c3b25569b4e007bb929bb456541e5433f52
wchargin-branch: uploader-graph-filtering wchargin-source: 63adea8ca2f0a85bd9f061aee72435f04d1d56d8 # Conflicts: # tensorboard/uploader/uploader_test.py
wchargin-branch: uploader-graph-filtering wchargin-source: 63adea8ca2f0a85bd9f061aee72435f04d1d56d8
wchargin-branch: efl-compat-transforms wchargin-source: 4fdc21c37611fab6a00384e9e824cd60302f6def
wchargin-branch: efl-compat-transforms wchargin-source: 124d838ae368a9d9c9f061a39a72056554c89790 # Conflicts: # tensorboard/uploader/uploader.py # tensorboard/uploader/uploader_test.py
wchargin-branch: efl-compat-transforms wchargin-source: 124d838ae368a9d9c9f061a39a72056554c89790
wchargin-branch: efl-compat-transforms wchargin-source: 41caa7efc7790458360d47924ce80e0d8f0ef248
wchargin-branch: dataclass-compat-initial-metadata wchargin-source: 9bceb864dae1a69432349daf80ebb4db6e19278b
wchargin-branch: dataclass-compat-initial-metadata wchargin-source: 9bceb864dae1a69432349daf80ebb4db6e19278b
wchargin-branch: dataclass-compat-initial-metadata wchargin-source: e87f73c1f892413fb38f913c3da0db230f9d8c61 # Conflicts: # tensorboard/backend/event_processing/event_file_loader.py # tensorboard/backend/event_processing/plugin_event_accumulator_test.py # tensorboard/uploader/uploader_test.py
wchargin-branch: dataclass-compat-initial-metadata wchargin-source: e87f73c1f892413fb38f913c3da0db230f9d8c61
|
|
||
| def __init__(self, file_path): | ||
| super(EventFileLoader, self).__init__(file_path) | ||
| # Track initial metadata for each tag, for `dataclass_compat`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for documenting this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Hopefully no one ever has to read it.
| metadata = summary_pb2.SummaryMetadata() | ||
| metadata.CopyFrom(value.metadata) | ||
| initial_metadata[value.tag] = metadata | ||
| if metadata.data_class != summary_pb2.DATA_CLASS_UNKNOWN: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to check my understanding, our assumption is that any summary that natively sets the data class on the initial metadata will already be using the dataclass-aware format (so to later summaries with that tag will require value conversions)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. In some sense there’s a bit of awkward coupling: one could imagine
factoring the migrations more finely as
data_compat(v1 → v2 summaries)- audio summary projection (label removal)
- hparams tensor fix
dataclass_compat(addmetadata.data_classonly)
where there are some dependencies (4 depends on 2, 2 depends on 1) but
the dependency graph is not (an orientation of) a complete graph. Then
if we needed to add more read-time migrations later even after summaries
natively write data_class we’d still be able to do so.
For now, at least, I thought that it was simpler to keep everything in
this layer so that there are fewer moving pieces.
| self.assertLen(new_events, 1) | ||
| self.assertIs(new_events[0], old_event) | ||
|
|
||
| def test_doesnt_add_metadata_to_later_steps(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I guess this behavior is fine, but it would also seem fine to me to populate the dataclass in the metadata if the metadata is present on non-initial steps (i.e. base it just on whether that summary has metadata or not) which seems a little less stateful and thus perhaps slightly simpler to reason about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, that’s fine with me. It’s important that we not populate the
metadata where it didn’t previously exist, because (e.g.) this triggers
a “mismatching plugin names” ("" != "scalars") warning in the
uploader. But if the metadata already exists I don’t see any harm in
populating the data class field. Done, and removed initial args.
wchargin-branch: dataclass-compat-initial-metadata wchargin-source: ba0efc9d5159b2f74982e63b6ca884c7f2380495
Summary: The `dataclass_compat` transform dispatches on plugin name, which is stored in the summary metadata. But the semantics of summary metadata is that it need only be set in the first event of each time series. Thus, until now, events past the first step of a time series have not been modified by `dataclass_compat`. This has been fine because all transformations have been either (a) only metadata transforms (which don’t matter after the first step anyway) or (b) tensor transforms to hparams data (which only ever has one step anyway). But an upcoming change will need to transform every step of each audio time series, so we need to identify which summaries have audio data even when they don’t have plugin name set on the same event. To do so, we let `dataclass_compat` update a stateful map from tag name to the first `SummaryMetadata` seen for that time series (scoped to a particular run). Test Plan: Some unit tests included now; the tests for migration of audio summaries will be more complete because they have more interesting things to test. wchargin-branch: dataclass-compat-initial-metadata
Summary: The `dataclass_compat` transform dispatches on plugin name, which is stored in the summary metadata. But the semantics of summary metadata is that it need only be set in the first event of each time series. Thus, until now, events past the first step of a time series have not been modified by `dataclass_compat`. This has been fine because all transformations have been either (a) only metadata transforms (which don’t matter after the first step anyway) or (b) tensor transforms to hparams data (which only ever has one step anyway). But an upcoming change will need to transform every step of each audio time series, so we need to identify which summaries have audio data even when they don’t have plugin name set on the same event. To do so, we let `dataclass_compat` update a stateful map from tag name to the first `SummaryMetadata` seen for that time series (scoped to a particular run). Test Plan: Some unit tests included now; the tests for migration of audio summaries will be more complete because they have more interesting things to test. wchargin-branch: dataclass-compat-initial-metadata
Summary:
The
dataclass_compattransform dispatches on plugin name, which isstored in the summary metadata. But the semantics of summary metadata is
that it need only be set in the first event of each time series. Thus,
until now, events past the first step of a time series have not been
modified by
dataclass_compat. This has been fine because alltransformations have been either (a) only metadata transforms (which
don’t matter after the first step anyway) or (b) tensor transforms to
hparams data (which only ever has one step anyway). But an upcoming
change will need to transform every step of each audio time series, so
we need to identify which summaries have audio data even when they don’t
have plugin name set on the same event.
To do so, we let
dataclass_compatupdate a stateful map from tag nameto the first
SummaryMetadataseen for that time series (scoped to aparticular run).
Test Plan:
Some unit tests included now; the tests for migration of audio summaries
will be more complete because they have more interesting things to test.
wchargin-branch: dataclass-compat-initial-metadata