|
| 1 | +# /// script |
| 2 | +# requires-python = ">=3.13" |
| 3 | +# dependencies = [ |
| 4 | +# "marimo", |
| 5 | +# ] |
| 6 | +# /// |
| 7 | + |
| 8 | +import marimo |
| 9 | + |
| 10 | +__generated_with = "0.14.10" |
| 11 | +app = marimo.App(width="medium") |
| 12 | + |
| 13 | + |
| 14 | +@app.cell(hide_code=True) |
| 15 | +def _(mo): |
| 16 | + mo.md( |
| 17 | + r""" |
| 18 | + ## Introduction |
| 19 | +
|
| 20 | + In order to get the most of this book, |
| 21 | + you will want to be able to execute the examples in the notebooks, |
| 22 | + modify them, break the code, and fix it. |
| 23 | + Pedagogically, that is the best way for you to learn the concepts. |
| 24 | + Here's the recommended way to get set up. |
| 25 | + """ |
| 26 | + ) |
| 27 | + return |
| 28 | + |
| 29 | + |
| 30 | +@app.cell(hide_code=True) |
| 31 | +def _(mo): |
| 32 | + mo.md( |
| 33 | + r""" |
| 34 | + ## Quick Setup |
| 35 | +
|
| 36 | + To get started with the notebooks, follow these simple steps: |
| 37 | +
|
| 38 | + 1. Git clone the repository: https://github.com/ericmjl/Network-Analysis-Made-Simple |
| 39 | +
|
| 40 | + 1. **Install uv** (the Python package manager): |
| 41 | + Follow the installation instructions at [https://docs.astral.sh/uv/getting-started/installation/](https://docs.astral.sh/uv/getting-started/installation/) |
| 42 | +
|
| 43 | + 2. **Navigate to the notebook directory**: |
| 44 | + ```bash |
| 45 | + cd notebooks/00-preface/ # replace with the actual numbered subdir! |
| 46 | + ``` |
| 47 | +
|
| 48 | + 3. **Run the notebook**: |
| 49 | + ```bash |
| 50 | + uvx marimo edit --sandbox 01-setup.py |
| 51 | + ``` |
| 52 | +
|
| 53 | + Once Marimo is launched, on the bottom, click on "on startup", "on cel change", and "on module change" to disable automatic execution. This will allow us to mimic original Jupyter behaviour, which is advantageous for a teaching setting (but toggle them back to "autorun" ) |
| 54 | +
|
| 55 | + |
| 56 | + That's it! The `--sandbox` flag ensures a clean, isolated environment for running the notebooks with all necessary dependencies automatically managed. |
| 57 | + """ |
| 58 | + ) |
| 59 | + return |
| 60 | + |
| 61 | + |
| 62 | +@app.cell(hide_code=True) |
| 63 | +def _(mo): |
| 64 | + mo.md( |
| 65 | + r""" |
| 66 | + ## What this does |
| 67 | +
|
| 68 | + - **uv** is a fast Python package manager that handles dependency resolution and virtual environments |
| 69 | + - **marimo** is an interactive notebook environment optimized for Python |
| 70 | + - The `--sandbox` flag creates an isolated environment for each notebook, preventing dependency conflicts |
| 71 | + - All required packages are automatically installed when you run the notebook |
| 72 | +
|
| 73 | + This approach eliminates the need for manual environment setup, conda environments, or Docker containers while ensuring reproducible execution of the tutorial content. |
| 74 | + """ |
| 75 | + ) |
| 76 | + return |
| 77 | + |
| 78 | + |
| 79 | +@app.cell(hide_code=True) |
| 80 | +def _(): |
| 81 | + import marimo as mo |
| 82 | + return (mo,) |
| 83 | + |
| 84 | + |
| 85 | +if __name__ == "__main__": |
| 86 | + app.run() |
0 commit comments