Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
projector: fix
RunPaths
result aliasing (#4479)
Summary: The projector uses `multiplexer.RunPaths()` to find each run’s logdir on disk, but it’s not clear from the code how this stays up to date as more runs are loaded. The answer is insidious: `RunPaths` returns the raw underlying dictionary, not a shallow copy of it, so changes to the internal structures of the multiplexer are immediately reflected in the projector plugin. This is a bit terrifying, since it means both that the code is wildly non-threadsafe and that it’s hard to tell when the data has actually changed. (The terror is somewhat abated by remembering that concurrency safety around dicts in Python is all just pretend, anyway.) This patch modifies the projector plugin to always shallow-copy the result of `RunPaths`, and makes the necessary follow-up changes to observe updates to the data. The result is that `RunPaths` is called more times, up to once on each HTTP handler or `is_active` call. This is fine: it’s expected that plugin routes may hit the multiplexer or data provider, and since the projector plugin only really works locally, this should be fast enough to not matter. In doing so, we also improve the update semantics, since we can test precisely for cache invalidation rather than just looking at the count of runs. There are almost certainly still observable concurrency issues; this patch doesn’t try to fix them all. The eventual goal of this series of patches is to remove the dependency on the multiplexer entirely, so the call to `RunPaths` will become a call to a data provider’s `list_runs` and merging in `flags.logdir`. Test Plan: The projector plugin still works in the normal case (shows embeddings with sprites, etc.). Edge cases to check: - Point TensorBoard at a logdir containing only non-projector data. Launch TensorBoard and wait a bit for the projector to finish determining that it has no data. Then add one projector run to the logdir and refresh TensorBoard (but do not restart the server). Note that the projector plugin properly picks up the new run. Repeat, and note that it picks up the newer run, too (i.e., the cache can be updated even when it’s non-empty). - Point TensorBoard at a logdir where the `projector_config.pbtxt` is inside a logdir’s plugin assets directory: ``` logs/run/plugins/org_tensorflow_tensorboard_projector/projector_config.pbtxt ``` Note that the config is still resolved properly. You can tell that it’s using the plugin assets because if you comment out the `_append_plugin_asset_directories` call, the embeddings will still be displayed but will lack sprite information. wchargin-branch: projector-fix-aliasing
- Loading branch information