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

Don't assume that resources entries are relative #1182

Merged
merged 4 commits into from
Jan 19, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions jupyter_server/gateway/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,16 @@ def _replace_path_kernelspec_resources(self, kernel_specs):
for resource_name in resources:
original_path = resources[resource_name]
split_eg_base_url = str.rsplit(original_path, sep="/kernelspecs/", maxsplit=1)
new_path = url_path_join(self.parent.base_url, "kernelspecs", split_eg_base_url[1])
kernel_specs["kernelspecs"][kernel_name]["resources"][resource_name] = new_path
if original_path != new_path:
self.log.debug(
f"Replaced original kernel resource path {original_path} with new "
f"path {kernel_specs['kernelspecs'][kernel_name]['resources'][resource_name]}"
if len(split_eg_base_url) > 1:
new_path = url_path_join(
self.parent.base_url, "kernelspecs", split_eg_base_url[1]
)
kernel_specs["kernelspecs"][kernel_name]["resources"][resource_name] = new_path
if original_path != new_path:
self.log.debug(
f"Replaced original kernel resource path {original_path} with new "
f"path {kernel_specs['kernelspecs'][kernel_name]['resources'][resource_name]}"
)
return kernel_specs

def _get_kernelspecs_endpoint_url(self, kernel_name=None):
Expand Down
5 changes: 4 additions & 1 deletion tests/test_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def generate_kernelspec(name):
kernelspec_stanza = {
"name": name,
"spec": spec_stanza,
"resources": {"logo-64x64": f"f/kernelspecs/{name}/logo-64x64.png"},
"resources": {
"logo-64x64": f"f/kernelspecs/{name}/logo-64x64.png",
"url": "https://example.com/example-url",
},
}
return kernelspec_stanza

Expand Down