Blog from jupyter notebook

how to setup fastpages to blog from jupyter notebook
fastpages
jupyter
notebooks
Published

September 10, 2020

That will be great if I can simply write blog entries using Jupyter Notebook.

I usually paste inner images into jupyter cells. But this feature is not available yet into fastpages. So for the moment I won’t include images into these posts.

That way I could simply use markdown and insert images

And directly see rendered impact before commiting and pushing to my blog.

get local repo from github

As I am behind a proxy most of my time when working from office, the easiest way for me is to work from WSL.

WSL

I won’t detail how to install WSL on Windows.

I use ubuntu images (18.04) on my PC.

set unset proxy in WSL

I have just added some bash commands at the end of my .bashrc file.

# Set Proxy
function setproxy() {
    export {http,https,ftp}_proxy="http://<my proxy ip address>:80"
    export {HTTP,HTTPS,FTP}_PROXY="http://<my proxy ip address>:80"
}

# Unset Proxy
function unsetproxy() {
    unset {http,https,ftp}_proxy
    unset {HTTP,HTTPS,FTP}_PROXY
}

git clone castorfou.github.io

I keep most of my local repos under ~/git/

cd ~/git
setproxy
git clone https://github.com/castorfou/castorfou.github.io.git

create a blog entry with Jupyter Notebook

commit and push to github

(base) guillaume@LL11LPC0PQARQ:~$ cd git
(base) guillaume@LL11LPC0PQARQ:~/git$ cd castorfou.github.io/
(base) guillaume@LL11LPC0PQARQ:~/git/castorfou.github.io$ git add .
(base) guillaume@LL11LPC0PQARQ:~/git/castorfou.github.io$ git commit -m 'new blog entry: blog from jupyter'
[master 6b7460a] new blog entry: blog from jupyter
 4 files changed, 516 insertions(+)
 create mode 100644 _posts/.ipynb_checkpoints/2020-09-10-blog-from-jupyter-checkpoint.ipynb
 create mode 100644 _posts/2020-09-10-blog-from-jupyter.ipynb
 create mode 100644 _posts/2020-09-10-blog-from-jupyter.py
 create mode 100644 _posts/Untitled.txt
(base) guillaume@LL11LPC0PQARQ:~/git/castorfou.github.io$ git push
fatal: unable to access 'https://github.com/castorfou/castorfou.github.io.git/': gnutls_handshake() failed: The TLS connection was non-properly terminated.

error: gnutls_handshake() failed: The TLS connection was non-properly terminated.

Just googling this error gives some insight: https://github.community/t/unable-to-push-to-repo-gnutls-handshake-failed/885

It is likely some local firewell issue.

{% include alert.html text=“To be fixed later” %}

switch to mobile wifi without need of proxy

(base) guillaume@LL11LPC0PQARQ:~/git/castorfou.github.io$ unsetproxy
(base) guillaume@LL11LPC0PQARQ:~/git/castorfou.github.io$ git push
Username for 'https://github.com': castorfou
Password for 'https://castorfou@github.com':
Counting objects: 7, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (7/7), 141.26 KiB | 10.09 MiB/s, done.
Total 7 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
remote:
remote: GitHub found 3 vulnerabilities on castorfou/castorfou.github.io's default branch (2 high, 1 moderate). To find out more, visit:
remote:      https://github.com/castorfou/castorfou.github.io/network/alerts
remote:
To https://github.com/castorfou/castorfou.github.io.git
   6adeb02..6b7460a  master -> master

check entries into blog

double entries

Double entries: one for the notebook (.ipynb) and one for the auto python export (.py). I will have to update my jupyter settings to avoid this python file creation. In the meantime I can just delete the python file, and commit.

{% include alert.html text=“Change settings of jupyter + .gitignore to avoid these double entries” %}

cannot open notebook into browser

Clicking just ask me to download the notebook, it doesn’t display it into the browser.

checking .gitignore

Just by looking into .gitignore, there is an interesting entry:

*.swp
~*
*~
_site
.sass-cache
.jekyll-cache
.jekyll-metadata
vendor
_notebooks/.ipynb_checkpoints

Wait what is in this last line.

Let’s create _notebooks directory and move my notebook in that directory.

notebooks from _notebooks not rendered

No entries, I guess there is some additional settings to do…

{% include alert.html text=“Why notebooks are not rendered by Jekyl” %}

test entry from md using local repo

There is no problem with that.

Creating a local md file in _poststhen pushing to github is creating the right entry blog.

following fastpages troubleshooting guide

upgrade fastpages

Try the automated upgrade as described in https://github.com/fastai/fastpages/blob/master/_fastpages_docs/UPGRADE.md

Unfortunately I don’t see

I have to follow the manual upgrade.

manual fastpages upgrade

I am surprised because the 1st step from manual upgrade is to copy the fastpages repo. It is what I did 2 days ago. I doubt having an outdated version of fastpages.

fastai forum: fastpages category

I will browse through nbdev & faspages category in fastai forums. I should see people with the same issue.

I have created an entry, into fastai forums: Fastpages - cannot see build process of GitHub Actions

And quite immediately Hamel Hussain answered guiding to the write direction:

I misread the Settings instruction: my github repo should explicitely NOT include my github username and I did exactly the opposite.

{% include alert.html text=“I have to create a new repo: guillaume_blog” %}

nothing visible from Actions tab

And another surprising subject: at github in Actions tab. I have a kind of default page. I expect something like an execution journal of Actions.

Page build failure

Received a notification by email:

The page build failed for the master branch with the following error:

Page build failed. For more information, see https://docs.github.com/github/working-with-github-pages/troubleshooting-jekyll-build-errors-for-github-pages-sites#troubleshooting-build-errors.

For information on troubleshooting Jekyll see:

https://docs.github.com/articles/troubleshooting-jekyll-builds

If you have any questions you can submit a request on the Contact GitHub page at https://support.github.com/contact?repo_id=293820308&page_build_id=202240535

Move to another repo

repo creation

It was just a matter of creating a new repo:

actions monitoring

Monitoring is effective

merge pull request

actions around ssh keys

Following the steps: - Create keys using ssh utility - Enter Secret Key - Enter Deploy Key

merge PR

There are conflicts to be fixed before that.

And it works: https://castorfou.github.io/guillaume_blog/

Get local repo

cd ~/git
unsetproxy
git clone https://github.com/castorfou/guillaume_blog.git