-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
core: remap /data/notifications to static path if present #4887
base: master
Are you sure you want to change the base?
Conversation
3467b67
to
f17e85e
Compare
@@ -90,10 +91,18 @@ def get_plugin_apps(self): | |||
"/histograms": self._redirect_to_index, | |||
"/images": self._redirect_to_index, | |||
} | |||
apps.update(self.get_resource_apps()) | |||
apps.update(self._static_handlers) |
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.
why not just call the function here if self._static_handlers
is not used in other places?
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.
Hmm good point, earlier I was going to need the property but now I don't. Will inline.
apps.update(self._static_handlers) | ||
remappings = { | ||
# Serve notifications from static JSON file if present. | ||
"/data/notifications": "/notifications_note.json", |
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.
I tried to verify the change and
...com/data/notifications_note.json
redirect to .com/data/notifications_note.json
which is not the correct path (omit 'data/')
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.
I don't quite follow, can you provide a little more detail about the exact way you were testing this and exactly what response you got? I'm not sure I understand the ...com
versus .com
part and also I wouldn't expect this remapping to affect an incoming path with notifications_note.json
(since it only maps the path /data/notifications
).
"/data/notifications": "/notifications_note.json", | ||
} | ||
for src, dest in remappings.items(): | ||
handler = apps.get(dest) |
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.
the handler is None
This wires in logic that remaps the path
/data/notifications
at the server side to serve a static asset (found at the pathnotifications_note.json
) if one is available, otherwise it falls back to the existing implementation of returning a JSON response containing no notifications. Effectively this is similar to serving a redirect, but it avoids an extra server-client roundtrip.Test plan: added a unit test, and tested end-to-end by patching in this commit and running TensorBoard locally: nfelt@89597d6