Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Suggestion: improve MyBinder-served sessions with some minor changes #1122

Open
@fomightez

Description

@fomightez

I would suggest you improve your offering to the MyBinder-serves sessions by having things work right away when launched and open a specific example notebook.


DETAILS:

A. Set things to already be installed

You can make the provided MyBinder-served session more user friendly by making a directory named 'binder' and placing a configuration file named requirements.txt in it with the following contents:

numpy
matplotlib
scipy
control
ipympl

This will make the sessions that open already have these packages installed.

You even already had an example of stepping someone through the set up here that you could eliminate that friction for everyone.

(Note the binder directory in root allows you to put configuration files in it that MyBinder will use and not interfere with other places the repo gets used. This binder directory option is currently covered in the documentation here.)

B. Have the user already be presented an open notebook & the examples directory when the session comes up

I would even suggest maybe opening a particular notebook from that link. Maybe the one named python-control_tutorial.ipynb?

You just need to extend the URL used from:

https://mybinder.org/v2/gh/python-control/python-control/HEAD

to

https://mybinder.org/v2/gh/python-control/python-control/HEAD?urlpath=%2Flab%2Ftree%2Fexamples%2Fpython-control_tutorial.ipynb

In fact, you can paste that URL in your address bar already to see it works to start with that one already open with all the other options already viewable in the file browser pane on the left. (Of course, without doing the step of adding the configuration file(s) suggested above it will need further work to run.)


EDIT TO ADDRESS ONE ADVANCED ISSUE I NOTED:
I see in the bode-and-nyquist-plots.ipynb notbeook file you use, %matplotlib nbagg in the second code cell. In the MyBinder-served launches that should be changed to %matplotlib ipympl. I have already tested in launches from here where ipympl is installed before the session starts that it adds the note functionality: "Enable interactive figures (panning and zooming)". That edit can be done on-the-fly via a postBuild or start file in the binder directory as well. (In fact, I have an example here where I use postBuild to completely remove a cell. Replacing some text is even easier. I have an example using sed to do find & replace in a start file here. Since you may be using sed, you can use here as a model of the postBuild content to have a bash shell situation.) Note that the change is only done downstream where MyBinder-served sessions will use it and so it doesn't affect the notebook on the repo, or what people get when they clone the python-control repo.
Note: in this case the option to use postBuild or start won't really matter as you only need to do one thing & it isn't a time consuming step. Code in start basically runs right before the user gets to see the session. It is the last thing done as the session spins up. postBuild would make the change in the image that Docker will use later to make the session. start files have a special command they need at the end to make the entrypoint still work right, and so I find in general postBuild is easiest. Plus if it is already done in the docker image then it isn't a step that has to get done later when the session starts, saving a fraction of a second in this case but potentially much longer if the step were time consuming. Another caveat that makes this part trickier is that the permissions on these files have to be preserved. Unlike most things I suggested, you cannot do this in the GitHub browser as it will mess up being able to execute start or postBuild in my experience.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions