Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update public site #584

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8faa341
only rebuild dockerfile on PR to main
trevorcampbell Dec 23, 2023
efe553c
update build_book workflow to persist dev copy
trevorcampbell Aug 18, 2024
f416a3b
empty commit to trigger dev rebuild
trevorcampbell Aug 18, 2024
425aa91
add workspace ownership reset after build book
trevorcampbell Aug 18, 2024
d13fd80
reset workspace ownership after build main preview
trevorcampbell Aug 18, 2024
150ec43
add build of diff, reset ownership in pr deploy
trevorcampbell Aug 18, 2024
2f75c28
fix version control ref links
trevorcampbell Aug 18, 2024
c8879f4
Merge pull request #580 from UBC-DSCI/fix-vc-links
trevorcampbell Aug 21, 2024
b7a7149
no rebuild book on push to prod
trevorcampbell Aug 21, 2024
ad78100
update so that gh-pages is still orphaned properly
trevorcampbell Aug 21, 2024
caa6104
Merge pull request #582 from UBC-DSCI/no-rebuild-on-prod
trevorcampbell Aug 21, 2024
46383a7
renaming connections in the db reading section
trevorcampbell Aug 21, 2024
6a098d6
title page oer collections
trevorcampbell Aug 21, 2024
966b59d
shrink amazon link
trevorcampbell Aug 21, 2024
faee27f
remove existing diff folder before running websitediff in action
trevorcampbell Aug 21, 2024
10a2607
Merge branch 'main' into title-page-updates-2024
trevorcampbell Aug 21, 2024
376239b
markdown list formatting frontpage fix
trevorcampbell Aug 21, 2024
33e34f5
fix minor spacing issue
trevorcampbell Aug 21, 2024
290c1bb
Merge pull request #583 from UBC-DSCI/title-page-updates-2024
trevorcampbell Aug 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/deploy_main_preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ jobs:
packages: write

steps:
- name: Get Actions user id
id: get_uid
run: |
actions_user_id=`id -u $USER`
echo $actions_user_id
echo "uid=$actions_user_id" >> $GITHUB_OUTPUT

- name: checkout
uses: actions/checkout@v2
with:
Expand All @@ -30,6 +37,11 @@ jobs:
- name: Build the book
run: |
./build_html.sh

- name: Reset ownership of workspace after build
uses: peter-murray/reset-workspace-ownership-action@v1
with:
user_id: ${{ steps.get_uid.outputs.uid }}

# Push the book's HTML to github-pages
- name: GitHub Pages action
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/deploy_pr_preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ jobs:
checkName: "Rebuild docker image"
ref: ${{ github.event.pull_request.head.sha }}
timeoutSeconds: 60000

- name: Get Actions user id
id: get_uid
run: |
actions_user_id=`id -u $USER`
echo $actions_user_id
echo "uid=$actions_user_id" >> $GITHUB_OUTPUT

- name: Checkout the repo
uses: actions/checkout@v2
Expand All @@ -42,6 +49,11 @@ jobs:
run: |
./build_html.sh

- name: Reset ownership of workspace after build
uses: peter-murray/reset-workspace-ownership-action@v1
with:
user_id: ${{ steps.get_uid.outputs.uid }}

# Push the book's HTML to github-pages
- name: GitHub Pages action
uses: peaceiris/[email protected]
Expand All @@ -52,11 +64,35 @@ jobs:
destination_dir: pull${{ github.event.number }}
# force_orphan: true # once peaceiris updates to v4, change this to true and keep_files: true for the PR / main branch deploy previews

- name: Checkout the gh-pages branch
uses: actions/checkout@v2
with:
fetch-depth: '0'
ref: 'gh-pages'

- name: Run website diff
run: |
rustup update
pip install --upgrade pip
pip install website_diff
rm -rf diff${{ github.event.number }}
website_diff --old dev --new pull${{ github.event.number }} --diff diff${{ github.event.number }}

- name: GitHub Pages action to push diff
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: diff${{ github.event.number }}
keep_files: true
destination_dir: diff${{ github.event.number }}
# force_orphan: true # once peaceiris updates to v4, change this to true and keep_files: true for the PR / main branch deploy previews

- name: Post URLS to PR thread
uses: mshick/[email protected]
with:
message: |
Hello! I've built a preview of your PR so that you can compare it to the current `main` branch.
* PR deploy preview available [here](https://datasciencebook.ca/pull${{ github.event.number }}/index.html)
* PR diff with `main` available [here](https://datasciencebook.ca/diff${{ github.event.number }}/index.html)
* Current `main` deploy preview available [here](https://datasciencebook.ca/dev/index.html)
* Public production build available [here](https://datasciencebook.ca)
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,27 @@ jobs:
packages: write

steps:
- name: checkout
- name: checkout gh-pages
uses: actions/checkout@v2
with:
ref: 'production'
- name: Build the book
ref: 'gh-pages'

- name: Copy contents of dev/ to home folder
run: |
./build_html.sh
yes | cp -rf dev ${{ runner.home }}

# Push the book's HTML to github-pages
- name: GitHub Pages action
# Push update website to dev/ and clean out old commits
- name: Update website to contents of dev, remove all old commits and subpages
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/
publish_dir: dev/
force_orphan: true # this will clean up all previous PR previews / main branch preview
cname: datasciencebook.ca

- name: copy dev/ website back in
run: |
yes | cp -rf ${{ runner.home }}/dev dev

- name: push the result to gh-pages
uses: stefanzweifel/git-auto-commit-action@v5
2 changes: 2 additions & 0 deletions .github/workflows/update_build_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Rebuild and publish new ubcdsci/intro-to-ds image on DockerHub
on:
pull_request:
types: [opened, synchronize]
branches:
- 'main'
jobs:
rebuild-docker:
name: Rebuild docker image
Expand Down
1 change: 1 addition & 0 deletions build_html.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Script to generate HTML book
docker run --rm -m 8g -v $(pwd):/home/rstudio/introduction-to-datascience ubcdsci/intro-to-ds:202307130106229dd1c2 /bin/bash -c "cd /home/rstudio/introduction-to-datascience; Rscript -e 'bookdown::render_book(\"index.Rmd\", output_format=\"bookdown::gitbook\"); warnings(); problems()'"

8 changes: 7 additions & 1 deletion index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ You can read the web version of the book on this site. Click a section in the ta
on the left side of the page to navigate to it. If you are on a mobile device,
you may need to open the table of contents first by clicking the menu button on
the top left of the page. You can purchase a PDF or print copy of the book
on the [CRC Press website](https://www.routledge.com/Data-Science-A-First-Introduction/Timbers-Campbell-Lee/p/book/9780367524685) or on [Amazon](https://www.amazon.com/Data-Science-First-Introduction-Chapman/dp/0367532174/ref=sr_[…]qid=1644637450&sprefix=data+science+timber%2Caps%2C166&sr=8-1).
on the [CRC Press website](https://www.routledge.com/Data-Science-A-First-Introduction/Timbers-Campbell-Lee/p/book/9780367524685) or on [Amazon](https://www.amazon.com/Data-Science-First-Introduction-Chapman/dp/0367532174).

For the python version of the textbook, visit [https://python.datasciencebook.ca](https://python.datasciencebook.ca).

This book is listed in a number of open educational resource (OER) collections:

- [The University of British Columbia OER collection](https://oer.open.ubc.ca/data-science-a-first-introduction/)
- [The OER Commons](https://oercommons.org/courses/data-science-a-first-introduction-with-r)
- [MERLOT](https://merlot.org/merlot/viewMaterial.htm?id=773420156)

```{r bookcover, echo = FALSE, fig.retina = 2, out.width = "45%"}
knitr::include_graphics("img/frontmatter/ds-a-first-intro-cover.jpg")
```
Expand Down
18 changes: 9 additions & 9 deletions source/reading.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ communication channel that R can use to send SQL commands to the database.
```{r}
library(DBI)

conn_lang_data <- dbConnect(RSQLite::SQLite(), "data/can_lang.db")
canlang_conn <- dbConnect(RSQLite::SQLite(), "data/can_lang.db")
```

Often relational databases have many tables; thus, in order to retrieve
Expand All @@ -557,7 +557,7 @@ all the tables in the database using the `dbListTables` \index{database!tables}
function:

```{r}
tables <- dbListTables(conn_lang_data)
tables <- dbListTables(canlang_conn)
tables
```

Expand All @@ -573,7 +573,7 @@ into SQL queries!
```{r}
library(dbplyr)

lang_db <- tbl(conn_lang_data, "lang")
lang_db <- tbl(canlang_conn, "lang")
lang_db
```

Expand All @@ -596,15 +596,15 @@ image_read("img/reading/ref_vs_tibble.001.jpeg") |>
```

We can look at the SQL commands that are sent to the database when we write
`tbl(conn_lang_data, "lang")` in R with the `show_query` function from the
`tbl(canlang_conn, "lang")` in R with the `show_query` function from the
`dbplyr` package. \index{database!show\_query}

```{r}
show_query(tbl(conn_lang_data, "lang"))
show_query(tbl(canlang_conn, "lang"))
```

The output above shows the SQL code that is sent to the database. When we
write `tbl(conn_lang_data, "lang")` in R, in the background, the function is
write `tbl(canlang_conn, "lang")` in R, in the background, the function is
translating the R code into SQL, sending that SQL to the database, and then translating the
response for us. So `dbplyr` does all the hard work of translating from R to SQL and back for us;
we can just stick with R!
Expand Down Expand Up @@ -704,7 +704,7 @@ be able to connect to a database using this information.

```{r, eval = FALSE}
library(RPostgres)
conn_mov_data <- dbConnect(RPostgres::Postgres(), dbname = "can_mov_db",
canmov_conn <- dbConnect(RPostgres::Postgres(), dbname = "can_mov_db",
host = "fakeserver.stat.ubc.ca", port = 5432,
user = "user0001", password = "abc123")
```
Expand All @@ -714,7 +714,7 @@ to when we were using an SQLite database in R. For example, we can again use
`dbListTables` to find out what tables are in the `can_mov_db` database:

```{r, eval = FALSE}
dbListTables(conn_mov_data)
dbListTables(canmov_conn)
```

```
Expand All @@ -727,7 +727,7 @@ We see that there are 10 tables in this database. Let's first look at the
database:

```{r, eval = FALSE}
ratings_db <- tbl(conn_mov_data, "ratings")
ratings_db <- tbl(canmov_conn, "ratings")
ratings_db
```

Expand Down
7 changes: 3 additions & 4 deletions source/version-control.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -941,10 +941,9 @@ and guidance that the worksheets provide will function as intended.
Now that you've picked up the basics of version control with Git and GitHub,
you can expand your knowledge through the resources listed below:

- GitHub's [guides website](https://guides.github.com/) and [YouTube
channel](https://www.youtube.com/githubguides), and [*Happy Git and GitHub
for the useR*](https://happygitwithr.com/) are great resources to take the next steps in
learning about Git and GitHub.
- GitHub's [guides website](https://docs.github.com/) and [*Happy Git and GitHub
for the useR*](https://happygitwithr.com/) are great resources for
learning more about Git and GitHub.
- [Good enough practices in scientific
computing](https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1005510#sec014)
[@wilson2014best] provides more advice on useful workflows and "good enough"
Expand Down
Loading