Skip to content

Commit

Permalink
move "accidentally deleted something" section, update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lillianw101 committed Jan 28, 2024
1 parent e02cc9e commit fb738de
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 72 deletions.
87 changes: 33 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,90 +1,69 @@
# Debugging Guide

# Guide to Quarto Installation & Use
Website link: https://ds100.org/debugging-guide/

## Quarto Set-Up

Begin by [installing Quarto](https://quarto.org/docs/get-started/).

Texts can be authored in Quarto using JupyterLab or classic Jupyter Notebook. To start a new document, open Jupyter and create a new notebook file.
Texts can be authored in Quarto using VSCode, JupyterLab, or classic Jupyter Notebook. We suggest using [VSCode](https://quarto.org/docs/get-started/hello/vscode.html)

## Repo Organization
This website uses Quarto to render pages. The main index can be found in `_quarto.yml`, and subpages are organized under the `chapters` section. Each subpage has it's own folder and `.md` (markdown) file. Note that unlike the [Course Notes repo](https://github.com/DS-100/course-notes), the debugging guide rarely runs any code, so we rely on `.md` files rather than `.qmd`, saving us the trouble of converting from `.qmd` to `.ipynb` for editing, then back to `.qmd` to render the website. Instead we can make edits directly to the `.md` file.

To set up the document, create a new Raw NBConvert cell. This will be used to set document-level YAML options. The Data 100 lecture notes are generated using the following YAML settings:
## Creating a new section
To start a new document, create an empty folder `topic_name` and create an empty markdown file `topic_name.md`. Start each document like so:

```
---
title: "Name of the Lecture"
execute:
echo: true
title: INSERT_TOPIC_TITLE
format:
html:
code-fold: true
code-tools: true
toc: true
toc-title: Name of the Lecture
page-layout: full
theme: [cosmo, cerulean]
toc-depth: 5
toc-location: right
code-fold: false
theme:
- cosmo
- cerulean
callout-icon: false
jupyter: python3
jupyter:
jupytext:
text_representation:
extension: .qmd
format_name: quarto
format_version: '1.0'
jupytext_version: 1.16.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
name: python3
---
```

Now, the notebook is ready for writing content. Quarto supports all the functionality of a standard ipynb file – code cells, markdown, and LaTeX. To begin writing lecture notes, it's a good idea to first set out the main headings of the document. These typically correspond to the title slides of each lecture ([example](https://docs.google.com/presentation/d/1FZJhOS8S1lCqZCRxbyys9rCZT0QxdY4hcmvZDskEHFI/edit#slide=id.g1150ea2fb2b_0_220)) and are written with the Markdown second headng level (`##`). Quarto will auto-populate the table of contents as these headings are created.
Now, the notebook is ready for writing content. In VSCode, you can activate a live preview of markdown files by clicking the button on the upper right-hand corner.

To view the Quarto file, open a terminal window (either [within Jupyter](https://docs.google.com/presentation/d/1FZJhOS8S1lCqZCRxbyys9rCZT0QxdY4hcmvZDskEHFI/edit#slide=id.g1150ea2fb2b_0_220) or through your machine's terminal) and navigate to the notebook's directory. Running the command `quarto preview notebook.ipynb` will render the document and open it in a new web browser tab.
![](md_preview.png)

With the preview activated, the rendered view will update every time a change is saved in the notebook. When editing the document, it's helpful to have side-by-side views of the notebook and preview so you can watch changes in real-time.
Note that clicking on the quarto `Preview` button does not generate a *live* preview but rather a static one.

## Document Formatting

A pdf view of how this notebook renders in Quarto can be found [here](https://drive.google.com/file/d/17ga5wvfcmvAzQ1rbnCP4kEf5bckST3--/view?usp=sharing).

#### Formatting Code

The `code-fold: true` option in the YAML set-up will automatically collapse all code cells in the rendered document. If a particular code cell should be uncollapsed by default (e.g. to explicitly show a `pandas` example), a cell-specific YAML option can be specified:

```
#| code-fold: false
print("this code is now visible")
```

#### Formatting Images

Inserting images in a Quarto document is similar to the standard Markdown syntax. The difference is that Quarto will insert figure captions automatically. The syntax below will insert an image with an accompanying description.

```
#![The best class at Berkeley](data.png)
```

#### Formatting Learning Outcomes

Each lecture note should start with a brief list of intended student learning outcomes. These are formatted as collapsable call-out cells, which can be created in a Markdown cell using the syntax below.

```
::: {.callout-note collapse="true"}
## Learning Outcomes
* Gain familiarity with Quarto
* Create your first Quarto document
* Write A+ Data 100 lecture notes
:::
```
To give you the most control when inserting images, we use html with the following format to center images/figs and control their size:

## Generating Output
To generate the final notebook as an HTML, run the terminal command `quarto render notebook.ipynb`. The HTML will be outputted in the same directory as the notebook.
```<center><img src = "IMAGE_NAME" width = "IMAGE_WIDTH_IN_PIXELS"></img></a></center>```

# Data 100-specific items
## Generating Output + Rendering Website
After making edits to the `.md` files, ensure that the right documents are un-commented under `_quarto.yml`'s `chapter` section. Then, run `quarto render` to render the entire website. Push your changes to Github, and you should see the changes reflected in the [website](https://ds100.org/debugging-guide/) after a few minutes.

General commands/notes:
* `jupyter lab # local jupyter setup`
* `ipynb` -> `qmd`: `quarto convert notebook.ipynb` or `quarto convert notebook.qmd`
* `quarto render`: renders HTML to `docs`. Note `qmd` has to exist for rendering
* Edit `_quarto.yml` to include note in sidebar/table of contents
* Quick local development:
* TODO: how to quickly render just one notes directory and not all notes?
* Publish notes to GitHub pages:
* `quarto render` everything
* `git add`, `git commit`, `git push`
* Can view website compilation on GitHub (look for yellow-to-green button next to commit number)
* Common errors:
* `Illegal instruction: 4 ...` close jupyter lab

## Other Quarto Resources

Expand Down
2 changes: 1 addition & 1 deletion _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ format:
theme: cosmo
toc: true
toc-depth: 5
toc-expand: 3
toc-expand: 3 # depth to expand index
callout-icon: false
number-sections: false
pdf: default
Expand Down
5 changes: 0 additions & 5 deletions autograder_gradescope/autograder_gradescope.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ This can happen if you “overwrite” a variable that is used in a question. Fo
### Why does a notebook test fail now when it passed before, and I didn’t change my code?
You probably ran your notebook out of order. [Re-run all previous cells](https://ds100.org/debugging-guide/jupyter101/jupyter101.html#running-cells) in order, which is how your code will be graded.

### I accidentally deleted something in a cell that was provided to me – how do I get it back?
Suppose you’re working on Lab 5. One solution is to go directly to DataHub and rename your lab05 folder to something else, like lab05-old. Then, click the Lab 5 link on the course website again, and it’ll bring you to a brand-new version of Lab 5. You can then copy your work from your old Lab 5 to this new one, which should have the original version of the assignment.

Alternatively, you can access this [public repo](https://github.com/DS-100/sp24-student) and navigate to a blank copy of the assignment you were working on. In the case of Lab 5 for example, the notebook would be located at `lab/lab05/lab05.ipynb`. You can then check and copy over the contents of the deleted cell into a new cell in your existing notebook.

## Gradescope

When submitting to Gradescope, there are often unexpected errors that make students lose more points than expected. Thus, it is imperative that you **stay on the submission page until the autograder finishes running**, and the results are displayed.
Expand Down
Binary file modified docs/Data-100-Debugging-Guide.pdf
Binary file not shown.
6 changes: 0 additions & 6 deletions docs/autograder_gradescope/autograder_gradescope.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ <h2 id="toc-title">Table of contents</h2>
<li><a href="#im-positive-i-have-the-right-answer-but-the-test-fails.-is-there-a-mistake-in-the-test" id="toc-im-positive-i-have-the-right-answer-but-the-test-fails.-is-there-a-mistake-in-the-test" class="nav-link" data-scroll-target="#im-positive-i-have-the-right-answer-but-the-test-fails.-is-there-a-mistake-in-the-test">I’m positive I have the right answer, but the test fails. Is there a mistake in the test?</a></li>
<li><a href="#why-does-grader.exportrun_teststrue-fail-if-all-previous-tests-passed" id="toc-why-does-grader.exportrun_teststrue-fail-if-all-previous-tests-passed" class="nav-link" data-scroll-target="#why-does-grader.exportrun_teststrue-fail-if-all-previous-tests-passed">Why does <code>grader.export(run_tests=True)</code> fail if all previous tests passed?</a></li>
<li><a href="#why-does-a-notebook-test-fail-now-when-it-passed-before-and-i-didnt-change-my-code" id="toc-why-does-a-notebook-test-fail-now-when-it-passed-before-and-i-didnt-change-my-code" class="nav-link" data-scroll-target="#why-does-a-notebook-test-fail-now-when-it-passed-before-and-i-didnt-change-my-code">Why does a notebook test fail now when it passed before, and I didn’t change my code?</a></li>
<li><a href="#i-accidentally-deleted-something-in-a-cell-that-was-provided-to-me-how-do-i-get-it-back" id="toc-i-accidentally-deleted-something-in-a-cell-that-was-provided-to-me-how-do-i-get-it-back" class="nav-link" data-scroll-target="#i-accidentally-deleted-something-in-a-cell-that-was-provided-to-me-how-do-i-get-it-back">I accidentally deleted something in a cell that was provided to me – how do I get it back?</a></li>
</ul></li>
<li><a href="#gradescope" id="toc-gradescope" class="nav-link" data-scroll-target="#gradescope">Gradescope</a>
<ul>
Expand Down Expand Up @@ -220,11 +219,6 @@ <h3 class="anchored" data-anchor-id="why-does-grader.exportrun_teststrue-fail-if
<h3 class="anchored" data-anchor-id="why-does-a-notebook-test-fail-now-when-it-passed-before-and-i-didnt-change-my-code">Why does a notebook test fail now when it passed before, and I didn’t change my code?</h3>
<p>You probably ran your notebook out of order. <a href="https://ds100.org/debugging-guide/jupyter101/jupyter101.html#running-cells">Re-run all previous cells</a> in order, which is how your code will be graded.</p>
</section>
<section id="i-accidentally-deleted-something-in-a-cell-that-was-provided-to-me-how-do-i-get-it-back" class="level3">
<h3 class="anchored" data-anchor-id="i-accidentally-deleted-something-in-a-cell-that-was-provided-to-me-how-do-i-get-it-back">I accidentally deleted something in a cell that was provided to me – how do I get it back?</h3>
<p>Suppose you’re working on Lab 5. One solution is to go directly to DataHub and rename your lab05 folder to something else, like lab05-old. Then, click the Lab 5 link on the course website again, and it’ll bring you to a brand-new version of Lab 5. You can then copy your work from your old Lab 5 to this new one, which should have the original version of the assignment.</p>
<p>Alternatively, you can access this <a href="https://github.com/DS-100/sp24-student">public repo</a> and navigate to a blank copy of the assignment you were working on. In the case of Lab 5 for example, the notebook would be located at <code>lab/lab05/lab05.ipynb</code>. You can then check and copy over the contents of the deleted cell into a new cell in your existing notebook.</p>
</section>
</section>
<section id="gradescope" class="level2">
<h2 class="anchored" data-anchor-id="gradescope">Gradescope</h2>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ <h1 class="title">Data 100 Debugging Guide</h1>
<h1 class="unnumbered">About</h1>
<p>This text offers pointers for keyboard shortcuts or common mistakes that accompany the coursework in the Spring 2024 Edition of the UC Berkeley course Data 100: Principles and Techniques of Data Science.</p>
<p>Inspiration for this guide was taken from the UC San Diego course DSC 10: Principles of Data Science and their <a href="https://dsc10.com/debugging/">debugging guide</a>.</p>
<p>If you spot any typos or would like to suggest any changes, please email us at <strong>data100.instructors@berkeley.edu</strong></p>
<p>If you spot any typos or would like to suggest any changes, please fill out the <a href="https://docs.google.com/forms/d/e/1FAIpQLSe0fBEJwt6aEfZxU3fh3llNk8rSWHj6Umq0km3wPqmFu0MlGA/viewform?usp=sf_link">Data 100 Content Feedback Form (Spring 2024)</a>. Note that this link will only work if you have an <span class="citation" data-cites="berkeley.edu">@berkeley.edu</span> email address. If you’re not a student at Berkeley and would like to provide feedback, please email us at <strong>data100.instructors@berkeley.edu</strong></p>


</section>
Expand Down
10 changes: 9 additions & 1 deletion docs/jupyter_datahub/jupyter_datahub.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ <h2 id="toc-title">Table of contents</h2>
<li><a href="#i-cant-edit-a-cell" id="toc-i-cant-edit-a-cell" class="nav-link" data-scroll-target="#i-cant-edit-a-cell">I can’t edit a cell</a></li>
<li><a href="#my-text-cell-looks-like-code" id="toc-my-text-cell-looks-like-code" class="nav-link" data-scroll-target="#my-text-cell-looks-like-code">My text cell looks like code</a></li>
<li><a href="#my-text-cell-changed-to-a-code-cell-my-code-cell-changed-to-a-text-cell" id="toc-my-text-cell-changed-to-a-code-cell-my-code-cell-changed-to-a-text-cell" class="nav-link" data-scroll-target="#my-text-cell-changed-to-a-code-cell-my-code-cell-changed-to-a-text-cell">My text cell changed to a code cell / My code cell changed to a text cell</a></li>
<li><a href="#why-does-running-a-particular-cell-cause-my-kernel-to-die" id="toc-why-does-running-a-particular-cell-cause-my-kernel-to-die" class="nav-link" data-scroll-target="#why-does-running-a-particular-cell-cause-my-kernel-to-die">Why does running a particular cell cause my kernel to die?</a></li>
<li><a href="#why-does-running-a-particular-cell-cause-my-kernel-to-die" id="toc-why-does-running-a-particular-cell-cause-my-kernel-to-die" class="nav-link" data-scroll-target="#why-does-running-a-particular-cell-cause-my-kernel-to-die">Why does running a particular cell cause my kernel to die?</a>
<ul>
<li><a href="#i-accidentally-deleted-something-in-a-cell-that-was-provided-to-me-how-do-i-get-it-back" id="toc-i-accidentally-deleted-something-in-a-cell-that-was-provided-to-me-how-do-i-get-it-back" class="nav-link" data-scroll-target="#i-accidentally-deleted-something-in-a-cell-that-was-provided-to-me-how-do-i-get-it-back">I accidentally deleted something in a cell that was provided to me – how do I get it back?</a></li>
</ul></li>
<li><a href="#click-here-to-download-zip-file-is-not-working" id="toc-click-here-to-download-zip-file-is-not-working" class="nav-link" data-scroll-target="#click-here-to-download-zip-file-is-not-working">“Click <u>here</u> to download zip file” is not working</a></li>
<li><a href="#i-cant-export-my-assignment-as-a-pdf-due-to-a-latexfailed-error" id="toc-i-cant-export-my-assignment-as-a-pdf-due-to-a-latexfailed-error" class="nav-link" data-scroll-target="#i-cant-export-my-assignment-as-a-pdf-due-to-a-latexfailed-error">I can’t export my assignment as a PDF due to a <code>LatexFailed</code> error</a></li>
</ul>
Expand Down Expand Up @@ -218,6 +221,11 @@ <h2 class="anchored" data-anchor-id="my-text-cell-changed-to-a-code-cell-my-code
<section id="why-does-running-a-particular-cell-cause-my-kernel-to-die" class="level2">
<h2 class="anchored" data-anchor-id="why-does-running-a-particular-cell-cause-my-kernel-to-die">Why does running a particular cell cause my kernel to die?</h2>
<p>If one particular cell seems to cause your kernel to die, this is likely because the computer is trying to use more memory than it has available. For instance: your code is trying to create a gigantic array. To prevent the entire server from crashing, the kernel will “die”. This is an indication that there is a mistake in your code that you need to fix.</p>
<section id="i-accidentally-deleted-something-in-a-cell-that-was-provided-to-me-how-do-i-get-it-back" class="level3">
<h3 class="anchored" data-anchor-id="i-accidentally-deleted-something-in-a-cell-that-was-provided-to-me-how-do-i-get-it-back">I accidentally deleted something in a cell that was provided to me – how do I get it back?</h3>
<p>Suppose you’re working on Lab 5. One solution is to go directly to DataHub and rename your lab05 folder to something else, like lab05-old. Then, click the Lab 5 link on the course website again, and it’ll bring you to a brand-new version of Lab 5. You can then copy your work from your old Lab 5 to this new one, which should have the original version of the assignment.</p>
<p>Alternatively, you can access this <a href="https://github.com/DS-100/sp24-student">public repo</a> and navigate to a blank copy of the assignment you were working on. In the case of Lab 5 for example, the notebook would be located at <code>lab/lab05/lab05.ipynb</code>. You can then check and copy over the contents of the deleted cell into a new cell in your existing notebook.</p>
</section>
</section>
<section id="click-here-to-download-zip-file-is-not-working" class="level2">
<h2 class="anchored" data-anchor-id="click-here-to-download-zip-file-is-not-working">“Click <u>here</u> to download zip file” is not working</h2>
Expand Down
Loading

0 comments on commit fb738de

Please sign in to comment.