Skip to content

Commit

Permalink
finshed makefile for starter_kit
Browse files Browse the repository at this point in the history
  • Loading branch information
amandaha8 committed Oct 31, 2024
1 parent 04443d3 commit b0d1841
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 44 deletions.
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,25 @@ build_district_digest:
make build_portfolio_site
git add portfolio/$(site)/district_*/*.ipynb

build_starterkit_ha:
$(eval export site = ha_starterkit_district)
pip install -r portfolio/requirements.txt
make build_portfolio_site
git add portfolio/$(site)/district_*/ portfolio/$(site)/*.yml portfolio/$(site)/*.md
python portfolio/portfolio.py index --deploy --prod

build_starterkit_LASTNAME:
$(eval export site = YOUR_SITE_NAME)
pip install -r portfolio/requirements.txt
make build_portfolio_site
git add portfolio/$(site)/district_*/ portfolio/$(site)/*.yml portfolio/$(site)/*.md
python portfolio/portfolio.py index --deploy --prod

add_precommit:
pip install pre-commit
pre-commit install
#pre-commit run --all-files


# Add to _.bash_profile outside of data-analyses
#alias go='cd ~/data-analyses/portfolio && pip install -r requirements.txt && cd #../_shared_utils && make setup_env && cd ..'

Expand Down
7 changes: 0 additions & 7 deletions ha_portfolio/Makefile

This file was deleted.

Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
52 changes: 40 additions & 12 deletions starter_kit/2024_basics_05.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
"* We often present our work on our portfolio because it retains the interactivity of the `Altair` charts and `Geopandas` maps we make.\n",
"* Additionally, it is very streamlined to update our work when it needs to be updated. \n",
"* Spend some time exploring our portfolio above. \n",
"\n",
"**How does the portfolio work?**\n",
"* For the majority of the sites on the portfolio are using **one** notebook essentially as a template that is looped one or more variables. \n",
" * This [National Transit Dataset Monthly Ridership by Regional Transit Planning Authority (RTPA)](https://ntd-monthly-ridership--cal-itp-data-analyses.netlify.app/readme) takes [this notebook](https://github.com/cal-itp/data-analyses/blob/main/ntd/monthly_ridership_report.ipynb) and reruns it for every \n",
"* For the majority of the sites on the portfolio are using a single notebook essentially as a template that is looped one or more variables. \n",
" * This [National Transit Dataset Monthly Ridership by Regional Transit Planning Authority (RTPA) portfolio](https://ntd-monthly-ridership--cal-itp-data-analyses.netlify.app/readme) takes [this notebook](https://github.com/cal-itp/data-analyses/blob/main/ntd/monthly_ridership_report.ipynb) and reruns it for every \n",
"RTPA in this [yml file](https://github.com/cal-itp/data-analyses/blob/main/portfolio/sites/ntd_monthly_ridership.yml). \n",
" * This process of looping over a parameter is called parameterizing a notebook!\n",
" * This process of looping over variables to generate new notebooks is called parameterizing a notebook.\n",
" \n",
"**Resources**\n",
" * You may wish to read these resources before making the portfolio.\n",
" * [Preparing notebooks for the portfolio](https://docs.calitp.org/data-infra/publishing/sections/4_notebooks_styling.html)\n",
" * [Publishing to the portfolio](https://docs.calitp.org/data-infra/publishing/sections/5_analytics_portfolio_site.html)\n",
"\n",
Expand All @@ -38,7 +39,6 @@
"* Right click -> rename this notebook as `lastname_portfolio.ipynb`\n",
"* Use `git mv` to move the Python file that holds your functions to the `lastname_portfolio`.\n",
"* Right click -> copy the `starterkit_district.yml` file to the folder `data-analyses/portfolio/sites`. Rename `starterkit_district.yml` to `lastname_starterkit_district`\n",
"* Right click -> copy the `Makefile` file to your new folder folder `lastname_portfolio`.\n",
"* Close this original `2024_basics_05.ipynb` and begin working on your new `lastname_portfolio.ipynb`"
]
},
Expand All @@ -50,7 +50,7 @@
"**Step 2: Netlify Setup**\n",
"* Follow the instructions [here](https://docs.calitp.org/data-infra/publishing/sections/5_analytics_portfolio_site.html#netlify-setup).\n",
"* You only need to do this step **once** for the entirety of your career at DDS. \n",
"* Once you have your key setup, you can publish limitless portfolios."
"* Once you have your key setup, you can publish countless portfolios."
]
},
{
Expand Down Expand Up @@ -247,24 +247,52 @@
},
{
"cell_type": "markdown",
"id": "fc0fde8b-7671-43cf-b1ac-66730e436d11",
"id": "36567eba-a5d4-4a38-b67e-ffbf8fe74035",
"metadata": {},
"source": [
"**Step 11: Something not right?**\n",
"**Step 11: View**\n",
"* Your portfolio should be up and running. \n",
"* You can view your portfolio using the draft URL. It'll look something like this: `https://ha-starterkit-district--cal-itp-data-analyses.netlify.app`.\n",
"* You can view your portfolio using the draft URL. It'll look something like this: `https://your-site-name--cal-itp-data-analyses.netlify.app`.\n",
"* If everything looks great, commit your work. \n",
" * Parameterizing a notebook creates a lot of new files. Make sure you've committed everything.\n",
" * This is tedious and will involve many directory changes."
]
},
{
"cell_type": "markdown",
"id": "41c923e8-4d79-424b-9e28-50ae4924cc24",
"metadata": {},
"source": [
"**Step 12: Something not right?**\n",
"* What if something is a little off? After updating your code, rerun this line of code to redo your portfolio. You must always `clean` your portfolio before regenerating new notebooks. \n",
"` python portfolio/portfolio.py clean REPLACE_YML_NAME && python portfolio/portfolio.py build REPLACE_YML_NAME --deploy`\n",
"* **Resource**: [DDS Other Specifications](https://docs.calitp.org/data-infra/publishing/sections/5_analytics_portfolio_site.html#other-specifications)"
"* There are many other specifications you can add to `python portfolio/portfolio.py build` and they are all detailed on [DDS Other Specifications](https://docs.calitp.org/data-infra/publishing/sections/5_analytics_portfolio_site.html#other-specifications). "
]
},
{
"cell_type": "markdown",
"id": "9c8f91a0-e0b5-465d-8f95-be8e3fc036ea",
"metadata": {},
"source": [
"**Step 12: Commit your code**\n",
"* You"
"**Step 13: Run a Makefile**\n",
"* You can generate all 12 of your notebooks in one swift line of code instead of running the same couple of lines over and over again using a `Makefile`. \n",
"* You can think of a `Makefile` as a coffee machine that does the same thing day in and day out. \n",
" * You always install the same packages.\n",
" * You always clean out the repo.\n",
" * You generally will rerun the notebook in its entirety.\n",
" * You always add the `md,yml,ipynb` and other files that the parameterization process creates.\n",
"* Makefiles are great for automating tasks and saving time. \n",
"\n",
"**Instructions** \n",
"* Make sure you are still at the root of our repo `~/data-analyses`.\n",
"* Under `data-analyses` you'll see a file called `Makefile`.\n",
"* Open up the `Makefile`. Scroll down to lines 68-72. \n",
"* Copy and paste the entire block of 68-72. \n",
"* Replace LASTNAME in `build_starterkit_LASTNAME:` with your name.\n",
"* Replace YOUR_SITE_NAME with the name of your .yml file in `/portfolio/sites` in `$(eval export site = YOUR_SITE_NAME)`\n",
" * My `yml` is named `ha_starterkit_district.yml` so my line is `$(eval export site = ha_starterkit_district)`\n",
"* Make sure you retain all the `\t` spaces! \n",
"* At the root of the repo run `Make build_starterkit_LASTNAME`.\n"
]
}
],
Expand Down
6 changes: 0 additions & 6 deletions starter_kit/Makefile

This file was deleted.

0 comments on commit b0d1841

Please sign in to comment.