Skip to content

Commit

Permalink
Add building notebooks and a github-page (#29)
Browse files Browse the repository at this point in the history
* Test notebook building + deployment on gh-pages

* Fix branch name

* Make sure jupyter is installed

* Comment out change checks while testing

* Try setting the kernel name

* Update deployment version?

* test set up using deployment with pages and jekyll

* Avoid mkdir for docs

* Try setting the folder to deploy

* First attempt to link to built notebook and binder

* Bump python version now that casa works with >3.6

* Attempt to install without libgfortran3 in binder

* Initial working version of decent enough formatting per tutorial

* Move all logos to images

* Test executing multiple notebooks

* Previously working build now fails? Revert as a quick check

* Issue from the pipe for some reason?

* Skip matplotlib style for 2nd notebook build

* Remove old build

* Add casadata to requirements

* CASA's plotbandpass function calls a deprecated matplotlib warning. Pin to older version

* Causes other issues. Pin to last matplotlib version before warning was removed

* Copy all generated html files to the site

* Download the data for the Dame map in the notebook

* Ensure PV example from MAPS is still running and clear outputs

* Clear all outputs

* Add all notebooks to pages and build them

* Clear notebook outputs

* Missing import

* Add regions to requirements

* Add astroquery to requirements.txt

* Known issue with the reprojection tutorials. Ensure rest of builds work for now

* Fix copy cmd
  • Loading branch information
e-koch authored Nov 10, 2023
1 parent 87f7fcf commit 11d4e1b
Show file tree
Hide file tree
Showing 30 changed files with 5,415 additions and 1,601 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/build_and_deploy_site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Github Pages

on:
push:
branches:
- master
# paths:
# - 'spectral_fitting/*.ipynb'
# - '*.json'
# - '.github/**'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up python
id: setup-python
uses: actions/setup-python@v2
with:
python-version: '3.10'
cache: 'pip'

- name: Install requirements
run: pip install -r requirements.txt

- name: Export notebooks
run: |
JUPYTER_CONFIG_DIR=./.jupyter jupyter nbconvert spectral_fitting/*.ipynb --execute --to html --ExecutePreprocessor.kernel_name=python
JUPYTER_CONFIG_DIR=./.jupyter jupyter nbconvert casa_to_spectralcube_guide/*.ipynb --execute --to html --ExecutePreprocessor.kernel_name=python
JUPYTER_CONFIG_DIR=./.jupyter jupyter nbconvert masking_and_moments/*.ipynb --execute --to html --ExecutePreprocessor.kernel_name=python
JUPYTER_CONFIG_DIR=./.jupyter jupyter nbconvert parallel_spectral_fitting/*.ipynb --execute --to html --ExecutePreprocessor.kernel_name=python
JUPYTER_CONFIG_DIR=./.jupyter jupyter nbconvert DameCube.ipynb --execute --to html --ExecutePreprocessor.kernel_name=python
JUPYTER_CONFIG_DIR=./.jupyter jupyter nbconvert PVDiagramPlotting.ipynb --execute --to html --ExecutePreprocessor.kernel_name=python
JUPYTER_CONFIG_DIR=./.jupyter jupyter nbconvert DiskPVExample.ipynb --execute --to html --ExecutePreprocessor.kernel_name=python
# JUPYTER_CONFIG_DIR=./.jupyter jupyter nbconvert SpectralCubeReprojectExample.ipynb --execute --to html --ExecutePreprocessor.kernel_name=python
# JUPYTER_CONFIG_DIR=./.jupyter jupyter nbconvert SpectralCubeReprojectMaskExample_v4p1.ipynb.ipynb --execute --to html --ExecutePreprocessor.kerne]l_name=python
- name: Prepare public folder
id: folder
run: |
cp spectral_fitting/*.html docs
cp casa_to_spectralcube_guide/*.html docs
cp masking_and_moments/*.html docs
cp parallel_spectral_fitting/*.html docs
cp *.html docs
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: docs
destination: docs/_site

- name: Setup Pages
id: pages
uses: actions/configure-pages@v3

- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: docs

deploy:
permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
14 changes: 14 additions & 0 deletions .jupyter/custom/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
For this file to be processed by jupyter,
ensure you export JUPYTER_CONFIG_DIR, for example:
JUPYTER_CONFIG_DIR=jupyter jupyter nbconvert --to html
https://blog.derlin.ch/share-your-jupyter-notebooks-like-a-pro
*/

/** Make jupyter HTML export more responsive. */
@media (max-width: 600px) {
.jp-InputPrompt.jp-InputArea-prompt,
.jp-OutputPrompt.jp-OutputArea-prompt {
display: none !important;
}
}
78 changes: 39 additions & 39 deletions DameCube.ipynb

Large diffs are not rendered by default.

296 changes: 52 additions & 244 deletions DiskPVExample.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions PVDiagramPlotting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "py39",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "py39"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -545,7 +545,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.6"
"version": "3.8.10"
}
},
"nbformat": 4,
Expand Down
12 changes: 8 additions & 4 deletions SpectralCubeReprojectExample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,11 @@
"outputs": [],
"source": [
"import radio_beam\n",
"common_beam = radio_beam.commonbeam.common_2beams(radio_beam.Beams(beams=[cube1vel.beam, cube2vel.beam]))\n",
"common_beam = cube1vel.beam.commonbeam_with(cube2vel.beam)\n",
"\n",
"# This works with older versions of radio-beam:\n",
"# common_beam = radio_beam.commonbeam.common_2beams(radio_beam.Beams(beams=[cube1vel.beam, cube2vel.beam]))\n",
"\n",
"common_beam"
]
},
Expand Down Expand Up @@ -618,9 +622,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Py 3.9",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python39"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -632,7 +636,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.2"
"version": "3.8.10"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 11d4e1b

Please sign in to comment.