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

core: remap /data/notifications to static path if present #4887

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nfelt
Copy link
Collaborator

@nfelt nfelt commented Apr 20, 2021

This wires in logic that remaps the path /data/notifications at the server side to serve a static asset (found at the path notifications_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

@@ -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)
Copy link
Contributor

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?

Copy link
Collaborator Author

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",
Copy link
Contributor

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/')

Copy link
Collaborator Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

the handler is None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants