During my PhD study, I've been questioning about, what is research?
It seems to me that research is about
During these iteractions, we may
and land new discovery.
So research is more like re-search.
Reproducibility is the ground base that all sciences are built on.
It is intuitive so that many of us have adopted or are going to use Python and Jupyter for research.
Okay. Python is great.
But it is no better than C, or ForTran without Jupyter!
Today, I would like to share my 2 cents after my graduation from
What are containers?
Why should I use it?
We will hear and learn more in the afternoon sessions, so here is what I'm going to demo.
How to put an elephant into a refrigerator deploy a basic jupyter environment
$ docker pull jupyter/base-notebook
, documentationsTa-da!
The essential way
# Copyright (C) 2018 by Dongming Jin
# Licensed under the Academic Free License version 3.0
# This program comes with ABSOLUTELY NO WARRANTY.
# You are free to modify and redistribute this code as long
# as you do not remove the above attribution and reasonably
# inform recipients that you have modified the original work
FROM jupyter/base-notebook
MAINTAINER Dongming Jin "dongming.jin@mavs.uta.edu"
# Switch account to root and adding user accounts and password. or not
USER root
RUN echo "root:Docker!" | chpasswd
USER jovyan
# add necessary ingredients
RUN conda install -y \
matplotlib \
seaborn \
pandas \
Pillow \
missingno \
scikit-learn
$ docker build -t jupyslides path/to/Dockerfile
Ta-da!
How to use it
$ docker run -it [--rm] -p 10000:8888 jupyslides
$ docker run -it [--rm] -p 10000-10010:8888-8898 jupyslides /bin/bash
-v path/to/notebooks:/home/jovyan/notebooks
-v path/to/data:/home/jovyan/data
Briefs to master Docker, TLDR
Concepts
docker pull
command to download the busybox image.docker run
which we did using the busybox image that we downloaded. A list of running containers can be seen using the docker ps
command.Usages
# manage command
docker build [--no-cache] -t img_name path/to/Dockerfile # build image based on dockerfile
docker images # all images
docker ps [-a] # show [all] running containers
docker start/attach con_id # restart excited container
stop con_id # stop container
rm con_id # rm container
rmi img_id # rm image
docker cp path/to/local con_id:path/to/target # copy file to container
# execution command
docker run -it # interactive
--rm # rm container when exit, use with caution
-d # detached, need to ssh to access
-p 8888:80 # port fwd to host
-e DISPLAY=$DISPLAY # set environment variable
-u docker # username/uid
-v <data_location>:~/data # mount data directory
--name="rdev" # container name
ubuntu # image name
/bin/bash # command
Okay. Docker is easy. Jupyter is awesome. What's the caveat?
Pain in the data exploration and cleaning
Pain in data loading and execution
jupyter/base-notebook
, note down dependencies to Dockerfile
Another example!
Now
Declaration: This is not the only method, but I really hope someone can give me a lecture at my first year.
I'm lucky to learn from
The main course in today's menu:
$ jupyter nbconvert --to FORMAT notebook.ipynb
¶nbconvert
: readthedocs
--to html
--to latex
--to pdf
--to slides
Many of us are familiar with that already. But what is reveal.js for?
My motivation is hiding the codes.
Why?
Ways to cover-up the code
HTML!
<a href="javascript:code_toggle()"> [Toggle Code]</a>
to each cellnbextension
codefolding
: $ jupyter nbextension enable codefolding/main
nbconvert
with --template template.tpl
While editing the cells and checking the results,
I find,
RISE: in-situ, good for dev./workshop
reveal.js: post-process, good for prod./presentation
How to?
My practical experience:
$ jupyter nbconvert notebook.ipynb --to slides --reveal-prefix reveal.js [--template hidecode/rmcode.tpl]
$ wget https://github.com/hakimel/reveal.js/archive/3.6.0.tar.gz | tar -xvzf -
styling
notebook.slides.html
with text editorstart the Slideshow in browser / html server
An example of the initialization.
<!--reveal.js initilization-->
<script>
require(
{
// it makes sense to wait a little bit when you are loading
// reveal from a cdn in a slow connection environment
waitSeconds: 10
},
[
"reveal.js/lib/js/head.min.js",
"reveal.js/js/reveal.js"
],
function(head, Reveal){
// Full list of configuration options available here: https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: "slide",
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: "reveal.js/lib/js/classList.js",
condition: function() { return !document.body.classList; } },
{ src: 'reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: "reveal.js/plugin/notes/notes.js",
async: true,
condition: function() { return !!document.body.classList; } },
{ src: 'reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'reveal.js/plugin/zoom-js/zoom.js', async: true }, // using zoom.js
]
});
var update = function(event){
if(MathJax.Hub.getAllJax(Reveal.getCurrentSlide())){
MathJax.Hub.Rerender(Reveal.getCurrentSlide());
}
};
Reveal.addEventListener('slidechanged', update);
function setScrollingSlide() {
var scroll = true
if (scroll === true) {
var h = $('.reveal').height() * 0.95;
$('section.present').find('section')
.filter(function() {
return $(this).height() > h;
})
.css('height', 'calc(95vh)')
.css('overflow-y', 'scroll')
.css('margin-top', '20px');
}
}
// check and set the scrolling slide every time the slide change
Reveal.addEventListener('slidechanged', setScrollingSlide);
}
);
</script>
RISE
+ nbconvert
+ reveal.js
+ template
= quick and neat SlideshowWorkflow
docker pull jupyter/base-notebook
docker run -it --rm -p 10000:8888 -v local/notebook:/work jupyter/base-notebook
# resolve dependency; do research with iPython in terminal + notebook
# New Text File for template.tpl
jovyan/terminal: jupyter nbconvert notebook.ipynb --to slides --reveal-prefix reveal.js [--template hidecode/rmcode.tpl]
jovyan/terminal: wget https://github.com/hakimel/reveal.js/archive/3.6.0.tar.gz | tar -xvzf -
jovyan/terminal: vi notebook.slides.html # edit the initialization script
# open notebook.slides.html
Jupyter Slideshow should be re-organized for serious Presentation
Suggestion For Giving Talks by Robert Geroch
Talk on Talks by Lucianne Walkowicz
The order of work is not necessary the order of talk!