Skip to content

Commit

Permalink
Merge branch 'master' into update-travis
Browse files Browse the repository at this point in the history
  • Loading branch information
jtemporal committed Oct 23, 2018
2 parents eed951b + 55ee431 commit a7ac610
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ cache:
pip: true
directories:
- ./data

python: 3.6
install:
- pip install -r requirements.txt
script: python -m unittest discover notebooks/test
script: python -m unittest discover notebooks/test
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

# Notebooks from [Operação Serenata de Amor](https://github.com/okfn-brasil/serenata-de-amor)

[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/okfn-brasil/notebooks/master?filepath=notebooks)

## What

[Operação Serenata de Amor](https://github.com/okfn-brasil/serenata-de-amor) has been acknowledged as a great AI project in Brazil and other countries. It has become not only a project to audit public expenses but also a space of sharing and collaboration. During its history, Serenata has had many people devoted to exploring its datasets through experimental notebooks which could possibly become a [Rosie](https://github.com/okfn-brasil/serenata-de-amor/blob/master/rosie/README.md)'s classifier.
Expand All @@ -26,13 +28,18 @@ Notebooks have been removed from the main repo, but with this exploratory and ed

### To read

You can clone this repo by typing on your console:
* You can clone this repo by typing on your console:

```
$ git clone https://github.com/okfn-brasil/notebooks.git
```

Alternatively you can download all the notebooks clicking the green "Clone or download" button on your right and choosing "Download ZIP".
* Alternatively you can download all the notebooks clicking the green "Clone or download" button on your right and choosing "Download ZIP".

* Alternatively you can [launch in binder](https://mybinder.org/v2/gh/okfn-brasil/notebooks/master?filepath=notebooks).
> This provides a simple and disposable environment to run and visualize notebooks. Don't use that as your development environment and definitely don't add your credentials on this environment.
* Alternatively you can visualize the notebooks in `read only` mode [using a public version of nbviewer](https://nbviewer.jupyter.org/github/okfn-brasil/notebooks/tree/master/)

### To download the datasets

Expand All @@ -48,4 +55,4 @@ Please remember to export a `.py` and `.html` to facilitate the review process.

## Reminder

The notebooks are available here for educational purposes. So please do not feel ashamed of commenting every step of your analysis, ok? Overusing documentation is better than no documentation at all.
The notebooks are available here for educational purposes. So please do not feel ashamed of commenting every step of your analysis, ok? Overusing documentation is better than no documentation at all.
30 changes: 18 additions & 12 deletions getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ There are six things a newcomer needs to get started:
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**

- [Getting started](#getting-started)
- [Walkthrough](#walkthrough)
- [Python](#python)
- [Jupyter](#jupyter)
- [To run Jupyter using Docker](#to-run-jupyter-using-docker)
- [Data science libraries](#data-science-libraries)
- [`serenata-toolbox` library](#serenata-toolbox-library)
- [`git`](#git)
- [A free or paid GitHub account](#a-free-or-paid-github-account)
- [Walkthrough](#walkthrough)
- [Python](#python)
- [Jupyter](#jupyter)
- [To run Jupyter using Docker](#to-run-jupyter-using-docker)
- [To run Jupyter with one click](#to-run-jupyter-with-one-click)
- [Data science libraries](#data-science-libraries)
- [`serenata-toolbox` library](#serenata-toolbox-library)
- [`git`](#git)
- [A free or paid GitHub account](#a-free-or-paid-github-account)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down Expand Up @@ -84,6 +84,12 @@ docker run --rm -i -t -p 8888:8888 -v "$PWD/data":/notebooks/data serenata-note

After that, open up your browser and access `http://localhost:8888` to interact with the notebooks here.

### To run Jupyter with one click

You could start a new Jupyter instance with one click using [binder](https://mybinder.org).

[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/okfn-brasil/notebooks/master?filepath=notebooks)

### Data science libraries

Python core functions are awesome but limited. To perform data analyses smoothly you need some third-party libraries specially developed for data science.
Expand Down Expand Up @@ -114,7 +120,7 @@ To install them, run:

### `git`

`git` is a version-control system. In other words, it is the tool you need to share your work with us.
`git` is a version-control system. In other words, it is the tool you need to share your work with us.

As this system allows its users to track changes in files, we use `git` to have multiple versions of the same file and "copy and paste" the pieces we want to keep on its final version.

Expand All @@ -126,11 +132,11 @@ To install `git`, go to [git-scm.com/downloads](https://git-scm.com/downloads) a

At last, you need a GitHub account to share your work with us. Follow these steps:

1. Go to [github.com](https://github.com/) and create am account.
1. Go to [github.com](https://github.com/) and create am account.
2. Come to [Serenata's Notebook GitHub repository](https://github.com/okfn-brasil/notebooks) and click "Fork" on the top right of the page.
3. Open your Terminal/Command Prompt.
4. Choose a folder in your computer and run `mkdir notebooks`
5. Run `cd notebooks`
6. Run `git clone https://github.com/<your-name-on-github>/notebooks.git` to download the repository to your machine.

Now you have everything you need to get started. Soon we will write instructions on how to effectively share your work with us, get feedback, cooment changes, collaborate with other users and so on.
Now you have everything you need to get started. Soon we will write instructions on how to effectively share your work with us, get feedback, cooment changes, collaborate with other users and so on.
15 changes: 10 additions & 5 deletions jupyter_notebook_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
dir_name = os.path.dirname(PEM_FILE)
try:
os.makedirs(dir_name)
except OSError as exc: # Python >2.5
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(dir_name):
pass
else: raise
else:
raise
# Generate a certificate if one doesn't exist on disk
subprocess.check_call(['openssl', 'req', '-new',
'-newkey', 'rsa:2048', '-days', '365', '-nodes', '-x509',
Expand All @@ -36,16 +37,20 @@
os.chmod(PEM_FILE, stat.S_IRUSR | stat.S_IWUSR)
c.NotebookApp.certfile = PEM_FILE

# Disable authentication altogether, NOT RECOMMENDED FOR PRODUCTION ENVIRONMENTS
# Disable authentication altogether, NOT RECOMMENDED FOR PRODUCTION
# ENVIRONMENTS
c.NotebookApp.token = ''

### If you want to auto-save .html and .py versions of your notebook:

# If you want to auto-save .html and .py versions of your notebook:
# modified from: https://github.com/ipython/ipython/issues/8009
def post_save(model, os_path, contents_manager):
"""post-save hook for converting notebooks to .py scripts"""
if model['type'] != 'notebook':
return # only do this for notebooks
return # only do this for notebooks
d, fname = os.path.split(os_path)
check_call(['jupyter', 'nbconvert', '--to', 'script', fname], cwd=d)
check_call(['jupyter', 'nbconvert', '--to', 'html', fname], cwd=d)


c.FileContentsManager.post_save_hook = post_save

0 comments on commit a7ac610

Please sign in to comment.