-
Notifications
You must be signed in to change notification settings - Fork 308
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
Add resource_dir to KernelSpecHandler model #818
Conversation
Thanks for submitting your first pull request! You are awesome! 🤗 |
Hi @mlhenderson - thanks for opening the PR and the great description. I believe this would constitute an API change since it's altering the model returned from the server. That said, we're on the cusp of a major release, so if such a change were to be made, the timing of this isn't bad. I do have some difficulty seeing general utility in this since the value of Given you'd like this available via the REST API, are you planning on developing a front-end extension to launch the other applications that rely on the co-located scripts? If so, there would likely be code necessary to launch those applications and I wonder if it would be better for that code to use the |
674cc0c
to
27a1067
Compare
Codecov Report
@@ Coverage Diff @@
## main #818 +/- ##
==========================================
+ Coverage 70.16% 70.18% +0.02%
==========================================
Files 63 63
Lines 7480 7486 +6
Branches 1253 1254 +1
==========================================
+ Hits 5248 5254 +6
Misses 1851 1851
Partials 381 381
Continue to review full report at Codecov.
|
@kevin-bates I am coordinating with @rcthomas to be able to explain the use case more and discuss this further on a jupyter-server call. Happy to get feedback on different/better ways to approach this. |
hi @mlhenderson - thank you for raising this PR and #932 in today's Server meeting. Since the general feeling was that introducing So, in essence, we'd merely be including |
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 addition of resource_dir
should also be included in the KernelSpec
definition of the Open API doc - presumably as a sibling to resources
.
Thanks for opening this PR, @mlhenderson—and apologies for the slow response here. My share the concerns that @vidartf raised at last week's Server meeting. The resource_dir returned in the model's response is an absolute path from the server's filesystem—which could be deemed sensitive information. We shouldn't require an item in our core REST API that includes sensitive data; I suspect this is the historical reason behind why this item is stripped out of the kernel spec response model in the first place. To get around this limitation of the core APIs, you could build a server extension that returns the resource dir. |
We're triaging PRs in the Server Meeting today. Because there hasn't been activity on this PR in a little while, I'm going to close this PR for now. If this work is still in-progress, feel free to re-open anytime. Thank you! |
For the case where a user has the template "{resource_dir}" in their kernel.json argv, the server api for api/kernelspecs returns the raw kernel.json spec contents (with the template string in place) but does not also include the resource_dir path that could be used to substitute the template string.
The use case for this PR is locating a script co-located with the kernel.json that is used to launch the kernel and has some custom setup that the user needs that is hard to pack into kernel.json argv directly and wants to be able to request remote tasks that utilize the same script. Using the same launch script would help to make sure that the task environment can be compatible with (libraries/dependencies, etc) the kernel environment. You can of course use the resource_dir for any resource co-located with the kernel, but in particular, my use case is a launch script. Using resource_dir instead of an absolute path is less error-prone for users, it makes the kernel files easier to copy for sharing or just replication, and there are other potential benefits. It's a nice feature, but unfortunately, when you use it, you do run into the problem of not being able to find that kernel easily on disk from the server api.
The change here (which should be straightforward) is to add a key to the KernelSpecHandler model for resource_dir, and then include that as a required key to validate that a dict represents a kernelspec model. In practice, this would mean that for a "standard" deployment with no subclassing, the KernelSpecManager would return the specs to the KernelSpecHandler, and then each spec dict would be instantiated as a new model that also includes the resource_dir key and value. Any KernelSpecManager subclass that already included resource_dir with the model dict would not have this model conversion take place.
The test_gateway sample kernelspec was modified slightly to adopt the added key, and I created a sample kernel that has a launch script colocated with the kernel.json and referred to with "{resource_dir}/" in the kernel.json.
If there are any issues with this PR, happy to discuss and or iterate as needed.