Silly question perhaps, but how can my Python/Jupyter notebook check to see if it’s running on binder? I’d like to disable certain feature for that case.
Hmm maybe you could check the username? I think it’s jovyan
Thanks for the reply - yes, I did see that username, but I didn’t know if it was a “permanent” thing. But maybe my question was naive - once I build a Binder instance of my repo, does it remain unchanged until I explicitly re-build? Or do future commits to the repo auto-rebuild my Binder instance? Apologies for probably butchering terminology and for not RTFM.
That might not be true in all cases as I believe a few projects or docker-stacks containers all uses Jovyan as the default user.
Yes and no. When you visit (say) https://mybinder.org/v2/gh/binder-examples/requirements/master we figure out which commit
master is currently pointing to and build that. So if
master changes a visit to http://mybinder.org/v2/gh/binder-examples/requirements/master will trigger a rebuild. If
master hasn’t changed there won’t be a rebuild.
master resolves to the commit fa84f12b0cd8062ca68ad4ffe1ba440b0bff5840 so visiting https://mybinder.org/v2/gh/binder-examples/requirements/master or https://mybinder.org/v2/gh/binder-examples/requirements/fa84f12b0cd8062ca68ad4ffe1ba440b0bff5840 will get you exactly the same build. However if you visit https://mybinder.org/v2/gh/binder-examples/requirements/a73ba121c9847fa38b7c4153230b9bfa9eecfaa7 you will get the build/state of the repo from February 2019.
You can also use a branch name or tag instead of a commit SHA. There are a few repositories that have a
binder tag that they link to which they update once in a while when there is a “new version that is ready for users”.
“on binder” (and not specifically on mybinder):
$ grep Binder /etc/jupyter/templates/login.html <h1>Binder inaccessible</h1>
I think most BinderHub deployments will end up having
BINDER_SERVICE_HOST set as an environment variable. So I’d check for that.