Skip to content

Commit 37e65f5

Browse files
authored
Merge pull request #3338 from cal-itp/ah_docs
Updated Parameterized Notebook Docs.
2 parents c812318 + d79003c commit 37e65f5

File tree

2 files changed

+37
-17
lines changed

2 files changed

+37
-17
lines changed

docs/publishing/sections/4_analytics_portfolio_site.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ You can find the Cal-ITP Analytics Portfolio at [analysis.calitp.org](https://an
1515

1616
Before executing the build, there are a few prior steps you need to do.
1717

18-
1. Set up netlify key:
18+
1. Set up netlify key/make sure your Netlify token is up to date:
1919

2020
- Install netlify: `npm install -g netlify-cli`
2121
- Navigate to your main directory
@@ -30,7 +30,15 @@ Before executing the build, there are a few prior steps you need to do.
3030
- For the changes to take effect, open a new terminal or run `source ~/.bash_profile`
3131
- Back in your terminal, enter `env | grep NETLIFY` to see that your Netlify token is there
3232

33-
2. Create a `.yml` file in [data-analyses/portfolio/sites](https://github.com/cal-itp/data-analyses/tree/main/portfolio/sites). Each `.yml` file is a site, so if you have separate research topics, they should each have their own `.yml` file.
33+
2. Create a `README.md` file in the repo where your work lies.
34+
35+
- Your file should always be titled as `README.md` and not other variants such as `README_gtfs.md` because the portfolio can only take a `README.md` file.
36+
- If you do accidentally create a `README.md` file with extra strings, you can fix this by taking the following steps:
37+
- `git rm portfolio/my_analysis/README_accidentally_named_something_else.md`
38+
- `rm portfolio/my_analysis/_build/html/README_accidentally_named_something.html`. We use `rm` because \_build/html folder is not checked into GitHub
39+
- `python portfolio/portfolio.py build my_report --no-execute-papermill --deploy` to rerun the portfolio to incorporate only the new changes to your `README.md` if the other pages are correct.
40+
41+
3. Create a `.yml` file in [data-analyses/portfolio/sites](https://github.com/cal-itp/data-analyses/tree/main/portfolio/sites). Each `.yml` file is a site, so if you have separate research topics, they should each have their own `.yml` file.
3442

3543
- This `.yml` file will include the directory to the notebook(s) you want to publish.
3644
- Name your `.yml` file. For now we will use `my_report.yml` as an example.
@@ -130,7 +138,7 @@ Before executing the build, there are a few prior steps you need to do.
130138
131139
- By running `--deploy`, you are deploying the changes to display in the Analytics Portfolio.
132140
- **Note:** The `my_report` will be replaced by the name of your `.yml` file in [data-analyses/portfolio/sites](https://github.com/cal-itp/data-analyses/tree/main/portfolio/sites).
133-
- If you have already deployed but want to make changes to the README, run: `python portfolio/portfolio.py build my_report --papermill-no-execute`
141+
- If you have already deployed but want to make changes to the README, run: `python portfolio/portfolio.py build my_report --no-execute-papermill --deploy`
134142
- Running this is helpful for larger outputs or if you are updating the README.
135143
136144
3. Once this runs, you can check the preview link at the bottom of the output. It should look something like:

docs/publishing/sections/5_notebooks_styling.md

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
11
# Getting Notebooks Ready for the Portfolio
22

3+
- [See a sample parameterized notebook here.](https://github.com/cal-itp/data-analyses/blob/main/starter_kit/parameterized_notebook.ipynb)
4+
5+
## Packages to include
6+
7+
- Order matters, %%capture must go first.
8+
- `warnings.filterwarnings('ignore')` warnings from displaying in the portfolio site (`shared_utils`).
9+
10+
```
11+
# Include this in the cell where packages are imported
12+
13+
%%capture
14+
15+
import warnings
16+
warnings.filterwarnings('ignore')
17+
18+
import calitp_data_analysis.magics
19+
```
20+
321
## Headers
422

523
### Parameterized Titles
624

7-
- If you're parameterizing the notebook, the first Markdown cell must include parameters to inject.
25+
- When parameterizing a notebook, the first Markdown cell must include parameters to inject.
826
- Ex: If `district` is one of the parameters in your `sites/my_report.yml`, a header Markdown cell could be `# District {district} Analysis`.
927
- Note: The site URL is constructed from the original notebook name and the parameter in the JupyterBook build: `0_notebook_name__district_x_analysis.html`
1028

1129
### Consecutive Headers
1230

13-
- Headers must move consecutively in Markdown cells. No skipping!
31+
- Headers must move consecutively in Markdown cells or the parameterized notebook will not generate. No skipping!
1432

1533
```
1634
# Notebook Title
@@ -27,6 +45,12 @@
2745

2846
### Capturing Parameters
2947

48+
- Create a code cell in which your parameter will be captured. Make sure the `parameter` tag for the cell is turned on.
49+
50+
```
51+
district_number = "4"
52+
```
53+
3054
- If you're using a heading, you can either use HTML or capture the parameter and inject.
3155

3256
- HTML - this option works when you run your notebook locally.
@@ -55,18 +79,6 @@
5579
## District {district_number}
5680
```
5781

58-
### Suppress Warnings
59-
60-
- Suppress warnings from displaying in the portfolio site (`shared_utils`).
61-
62-
```
63-
# Include this in the cell where packages are imported
64-
65-
%%capture
66-
import warnings
67-
warnings.filterwarnings('ignore')
68-
```
69-
7082
## Narrative
7183

7284
- Narrative content can be done in Markdown cells or code cells.

0 commit comments

Comments
 (0)