Skip to content

Commit

Permalink
Improved description of how to use Colab.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhahsler committed Dec 10, 2024
1 parent cf9ccab commit fee62fe
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 9 deletions.
39 changes: 32 additions & 7 deletions Agents/robot_vacuum.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@
"\n",
"Complete this notebook. Use the provided notebook cells and insert additional code and markdown cells as needed. Submit the completely rendered notebook as a HTML file. \n",
"\n",
"In Visual Studio Code: Use Export (click on ... in the menu bar) to save your notebook as a HTML file.\n",
"### Using Visual Studio Code\n",
"\n",
"In Colab you need to save the notebook on GoogleDrive and then add the following block"
"If you use VS code then you can use `Export` (click on `...` in the menu bar) to save your notebook as a HTML file. Note that you have to run all blocks before so the HTML file contains your output.\n",
"\n",
"### Using Google Colab\n",
"\n",
"In Colab you need to save the notebook on GoogleDrive to work with it. For this you need to mount your google dive and change to the correct directory by uncommenting the following lines and running the code block."
]
},
{
Expand All @@ -29,19 +33,40 @@
"metadata": {},
"outputs": [],
"source": [
"# !pip install nbconvert\n",
"#\n",
"# from google.colab import drive\n",
"# import os\n",
"#\n",
"# drive.mount('/content/drive')\n",
"# !jupyter nbconvert --to html /content/drive/MyDrive/Colab\\ Notebooks/Copy\\ of\\ robot_vacuum.ipynb"
"# os.chdir('/content/drive/My Drive/Colab Notebooks/')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Once you are done with the assignment and have run all code blocks using `Runtime/Run all`, you can convert the file on your GoogleDrive into HTML be uncommenting the following line and running the block."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# !jupyter nbconvert --to html Copy\\ of\\ robot_vacuum.ipynb"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You may have to fix the file location or the file name to match how it looks on your GoogleDrive. You can navigate in Colab to your GoogleDrive using the little folder symbol in the navigation bar to the left."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You will need to fix the file location on your GoogleDrive.\n",
"\n",
"## Introduction\n",
"\n",
"In this assignment you will implement a simulator environment for an automatic vacuum cleaner robot, a set of different reflex-based agent programs, and perform a comparison study for cleaning a single room. Focus on the __cleaning phase__ which starts when the robot is activated and ends when the last dirty square in the room has been cleaned. Someone else will take care of the agent program needed to navigate back to the charging station after the room is clean.\n",
Expand Down
16 changes: 14 additions & 2 deletions HOWTOs/working_on_assignments.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,29 @@

We will provide you with a CoLab link to the assignment notebook.

* **Option 1:** You can work directly on CoLab by using `File>Save a copy to Drive`(you will need a Google Account). To use data files from within CoLab, you need to go to your [Google Drive](drive.google.com) to the folder called My Drive - CoLab Notebooks and copt the needed files there. Then you need to mount your Google drive in your notebook, and change to the directory to the notebook folder. The needed code for your code cell looks like this:
* **Option 1:** You can work directly on CoLab by using `File>Save a copy to Drive`(you will need a Google Account). To use data files from within CoLab, you need to go to your [Google Drive](https://drive.google.com) to the folder called My Drive - CoLab Notebooks and copy the needed files there. Then you need to mount your Google drive in your notebook, and change to the directory to the notebook folder. The needed code for your code cell looks like this:

```{python}
from google.colab import drive
import os
drive.mount('/content/drive')
os.chdir('/content/drive/My Drive/Colab Notebooks/')
!pwd
```
You can execute shell commands. The following line will list the contents of the current directory. Is should show you the ipynb files you have there.
```{python}
!ls
```
To create a HTML documents out of your rendered notebooks you can run execute jupyter which is already installed on Colab.
```{python}
!jupyter nbconvert --to html nameofyournorebook.ipynb
```

You can now download the created HTML file from your GoogleDrive.

* **Option 2:** You can download individual assignment notebooks using `File>Download>Download .ipynb` and then work locally on the project. You will need to download additional files as well.

Make sure that you have a copy of your assignment in a save place that has a backup (e.g., Google Drive).
Expand Down

0 comments on commit fee62fe

Please sign in to comment.