-
Notifications
You must be signed in to change notification settings - Fork 323
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
Custom actions #700
Custom actions #700
Conversation
I'm add to add documentation to the README and test cases if this is the right design. Thought I'd bring this up for feedback first |
@mlucool Thanks for this PR. Using server configuration is safe enough - managed installation will keep control 😉 Regarding the implementation, I suggest to not be as generic for two reasons:
So I propose to use the following configuration to a list of subprocess commands to be executed in the repository folder: {
"JupyterLabGit": {
"actions": {
"postInit": [{
"command": Array<string>, // subprocess command
"args": Dict[string, string] // subprocess args
}]
}
}
} Some comments on the schema:
What do you think?
|
I don't totally agree, but I'm happy to oblige. One key reason is that the API is very hard to establish - but maybe we just promise to give the script nothing and we call it in the right cwd. I also find in process error handling mostly easier. Still, we ca go with arbitary shell commands only, but I think we just support anything a user puts and use
These all seem reasonable |
Good point, this will ease the setting. |
@fcollonval updated. Any more feedback or I will finish cleaning this up (more doc, seeing if its easy enough to test). I can add this to places besides init (e.g. clone) as well. |
@fcollonval did you have further feedback? |
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.
Thanks @mlucool
I left a few questions in your proposal.
For the test, could you test also a failure of execute
with a non-zero code and with the emission of an exception? This is quite critical and will help use ensuring robustness of the extension.
jupyterlab_git/git.py
Outdated
# After any failure, stop | ||
if code != 0: | ||
break | ||
return code, stdout, stderr |
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.
Opened question: Should the stdout be concatenate for all actions?
jupyterlab_git/git.py
Outdated
) | ||
if code == 0: | ||
code, _, error = await self._maybe_run_actions('post_init', cwd) |
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.
Opened question: Should stdout logged to help debugging?
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.
Do we have any examples of logging? For now, I sent all data (stdout/stderr/code/command) back to the front end where we can later show whatever we'd like to the user.
@fcollonval this is ready for re-review.
Tested no post_init, post_init that works, and post_init that fails |
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.
@mlucool Thanks for the addition of the tests. I saw one error. And then we should be good to go.
About the logging, you can drop it for now - I'm looking into this without the need to pass a logger object from the notebook application.
@fcollonval I believe all review feedback is taken care of |
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.
LGTM !
Thanks a lot @mlucool
@meeseeksdev backport to 0.11.x |
…on-0.11.x Backport PR #700 on branch 0.11.x (Custom actions)
Fixes: #584
This adds the ability for users to set a custom class to take actions. As of now, we only have a post_init action, but this can be trivially extended to give more power to end users who have non-generic needs.
Example
~/.jupyter/jupyter_notebook_config.json
: