Repository: data-8/datascience (language: python)

Issue:
Docs are not getting automatically built
With the death of Travis CI, docs are not automatically getting built and pushed to the readthedocs website.  I guess we should figure out how to recreate that with Github Actions.

Separately, running `make docs` locally doesn't work for me.  When I try, I get the following error:

```
$ make docs
[...]
Running Sphinx v4.1.2
[...]
ModuleNotFoundError: No module named 'folium'
```

but `folium` is installed inside my venv:

```
$ python
Python 3.10.4 (main, Mar 25 2022, 00:00:00) [GCC 11.2.1 20220127 (Red Hat 11.2.1-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import folium
>>> 
```

so I'm a bit stuck there.  Perhaps Sphinx is somehow escaping the venv that I'm using for local development.


Discussion / hints:
Hmm...I'm not able to reproduce your local `make docs` issue. It's running fine for me, especially after upgrading to the latest `Sphinx` and `nbsphinx` versions:

```
(datascience) Adnans-MacBook-Pro:datascience ahemani$ make docs
cd docs ; make html
mkdir -p _build/html/_images
sphinx-build -b html -d _build/doctrees   . _build/html
Running Sphinx v5.0.1

Bad key "text.kerning_factor" on line 4 in
/Users/ahemani/anaconda3/envs/datascience/lib/python3.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test_patch.mplstyle.
You probably need to get an updated matplotlibrc file from
https://github.com/matplotlib/matplotlib/blob/v3.1.3/matplotlibrc.template
or from the matplotlib source distribution
WARNING: Invalid configuration value found: 'language = None'. Update your configuration to a valid langauge code. Falling back to 'en' (English).
WARNING: The config value `ipython_mplbackend' has type `NoneType', defaults to `str'.
loading pickled environment... failed
failed: __new__() missing 1 required positional argument: 'aliased'
[autosummary] generating autosummary for: _autosummary/datascience.tables.Table.__init__.rst, _autosummary/datascience.tables.Table.append.rst, _autosummary/datascience.tables.Table.append_column.rst, _autosummary/datascience.tables.Table.apply.rst, _autosummary/datascience.tables.Table.as_html.rst, _autosummary/datascience.tables.Table.as_text.rst, _autosummary/datascience.tables.Table.bar.rst, _autosummary/datascience.tables.Table.barh.rst, _autosummary/datascience.tables.Table.bin.rst, _autosummary/datascience.tables.Table.boxplot.rst, ..., _autosummary/datascience.tables.Table.with_row.rst, _autosummary/datascience.tables.Table.with_rows.rst, formats.rst, index.rst, maps.rst, predicates.rst, reference-nb/datascience-reference.ipynb, tables.rst, tutorial.rst, util.rst
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 80 source files that are out of date
updating environment: [new config] 80 added, 0 changed, 0 removed
reading sources... [100%] util                                                                                                                                                                              
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] util                                                                                                                                                                               
generating indices... genindex py-modindex done
copying notebooks ... [100%] reference-nb/datascience-reference.ipynb                                                                                                                                       
highlighting module code... [100%] datascience.util                                                                                                                                                         
writing additional pages... search done
copying images... [100%] _images/m_smoker_weights.png                                                                                                                                                       
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 2 warnings.

The HTML pages are in _build/html.

Build finished. The HTML pages are in _build/html.
(datascience) Adnans-MacBook-Pro:datascience ahemani$ 
```

In the meantime, let me see what we can do about push the docs!

Fix patch:
diff --git a/DEVELOPERS.md b/DEVELOPERS.md
index 3cc01b7f4..0ca80114b 100644
--- a/DEVELOPERS.md
+++ b/DEVELOPERS.md
@@ -59,48 +59,6 @@ locally, use these commands:
     make docs       # Generates docs inside doc/ folder
     make serve_docs # Starts a local server to view docs
 
-## Using Zenhub
-
-We use [Zenhub](https://www.zenhub.io/) to organize development on this library.
-To get started, go ahead and install the [Zenhub Chrome Extension][zenhub-extension].
-
-[zenhub-extension]: https://chrome.google.com/webstore/detail/zenhub-for-github/ogcgkffhplmphkaahpmffcafajaocjbd?hl=en-US
-
-Then navigate to [the issue board](#boards) or press `b`. You'll see a screen
-that looks something like this:
-
-![screenshot 2015-09-24 23 03 57](https://cloud.githubusercontent.com/assets/2468904/10094128/ddc05b92-6310-11e5-9a23-d51216370e89.png)
-
-* **New Issues** are issues that are just created and haven't been prioritized.
-* **Backlogged** issues are issues that are not high priority, like nice-to-have
-  features.
-* **To Do** issues are high priority and should get done ASAP, such as
-  breaking bugs or functionality that we need to lecture on soon.
-* Once someone has been assigned to an issue, that issue should be moved into
-  the **In Progress** column.
-* When the task is complete, we close the related issue.
-
-### Example Workflow
-
-1. John creates an issue called "Everything is breaking". It goes into the New
-   Issues pipeline at first.
-2. This issue is important, so John immediately moves it into the To Do
-   pipeline. Since he has to go lecture for 61A, he doesn't assign it to himself
-   right away.
-3. Sam sees the issue, assigns himself to it, and moves it into the In Progress
-   pipeline.
-4. After everything is fixed, Sam closes the issue.
-
-Here's another example.
-
-1. Ani creates an issue asking for beautiful histograms. Like before, it goes
-   into the New Issues pipeline.
-2. John decides that the issue is not as high priority right now because other
-   things are breaking, so he moves it into the Backlog pipeline.
-3. When he has some more time, John assigns himself the issue and moves it into
-   the In Progress pipeline.
-4. Once the issue is finished, he closes the issue.
-
 ## Publishing
 
 ```
diff --git a/Makefile b/Makefile
index bac488a66..8af460284 100644
--- a/Makefile
+++ b/Makefile
@@ -27,16 +27,3 @@ clean_docs:
 
 serve_docs:
 	cd $(DOCS_DIR)/_build/html ; python -m http.server
-
-deploy_docs:
-	rm -rf doc_build
-
-	git clone --quiet --branch=gh-pages $(GH_REMOTE) doc_build
-	cp -r docs/_build/html/* doc_build
-
-	cd doc_build && \
-		git add -A && \
-		git commit -m "$(DEPLOY_DOCS_MESSAGE)" && \
-		git push -f $(GH_REMOTE) gh-pages
-
-	rm -rf doc_build
diff --git a/docs/tutorial.rst b/docs/tutorial.rst
index 9a5a2e7a9..6f9c00298 100644
--- a/docs/tutorial.rst
+++ b/docs/tutorial.rst
@@ -217,6 +217,7 @@ Operate on table data with :meth:`~datascience.tables.Table.sort`,
     t.select(['count', 'points']).group('count', collect=sum)
 
 .. ipython:: python
+    :okwarning:
 
     other_table = Table().with_columns(
         'mar_status',  ['married', 'married', 'partner', 'partner', 'married'],
diff --git a/tools/deploy_docs.sh b/tools/deploy_docs.sh
deleted file mode 100755
index f57963d61..000000000
--- a/tools/deploy_docs.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-
-# This script is used by Travis to automatically build and push the docs to the
-# gh-pages branch of the datascience repo.
-
-set -e # exit with nonzero exit code if anything fails
-
-# Only build docs on master branch
-if [[ $TRAVIS_PULL_REQUEST == false && $TRAVIS_BRANCH == "master" ]] ; then
-
-	# https://docs.travis-ci.com/user/gui-and-headless-browsers/#Using-xvfb-to-Run-Tests-That-Require-a-GUI
-	# sam: The DISPLAY env variable needs to be set for matplotlib charts to be
-	# generated on Travis. I don't know why just matplotlib.use doesn't work.
-	export DISPLAY=:99.0
-	# sh -e /etc/init.d/xvfb start
-	# sleep 3 # give xvfb some time to start
-
-	echo "-- building docs --"
-
-	make docs
-
-	echo "-- pushing docs --"
-
-
-	git config --global user.name "Travis CI"
-	git config --global user.email "travis@travis.com"
-
-	commitHash=`git rev-parse HEAD`
-
-	make deploy_docs \
-	  DEPLOY_DOCS_MESSAGE="Generated by commit $commitHash, pushed by Travis build $TRAVIS_BUILD_NUMBER." \
-	  GH_REMOTE="https://${GH_TOKEN}@${GH_REPO}"
-fi


Test patch:
diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml
index 3f7e30bce..c897ce353 100644
--- a/.github/workflows/run_tests.yml
+++ b/.github/workflows/run_tests.yml
@@ -8,7 +8,7 @@ jobs:
     runs-on: ubuntu-latest
 
     steps:
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
 
     # Note that miniconda is installed by default in environments
     - name: Set up conda environment
@@ -48,4 +48,25 @@ jobs:
       env:
         GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 
-    # TODO: Add Docs deployment to run
+    - name: Push docs
+      if: github.ref_name == 'master' && github.event_name == 'push'
+      run: |
+        source activate datascience
+        python -m pip install -r docs/requirements.txt
+        python -m pip uninstall pandoc
+        conda install pandoc
+        git config --global user.name github-actions
+        git config --global user.email github-actions@github.com
+        echo "-- building docs --"
+        make docs
+        echo "-- pushing docs --"
+        rm -rf doc_build
+        git clone --quiet --branch=gh-pages $GITHUB_SERVER_URL/$GITHUB_REPOSITORY doc_build
+        cp -r docs/_build/html/* doc_build
+        cd doc_build
+        git add -A
+        git commit -m "Generated by commit $GITHUB_SHA, pushed by GitHub run $GITHUB_RUN_ID."
+        echo "-- try to push --"
+        git push "https://${{github.actor}}:${{github.token}}@github.com/${{github.repository}}.git"
+
+        rm -rf doc_build