From 4df15a6b1d0ab6bec80b732df81abac57e15e812 Mon Sep 17 00:00:00 2001 From: Gustas <37534529+PunkPun@users.noreply.github.com> Date: Sat, 23 Nov 2024 13:46:29 +0200 Subject: [PATCH] [Docs] Update the notebook tutorial Signed-off-by: Gustas <37534529+PunkPun@users.noreply.github.com> --- examples/notebooks/README.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/examples/notebooks/README.md b/examples/notebooks/README.md index 4ee3854595..277c7e558a 100644 --- a/examples/notebooks/README.md +++ b/examples/notebooks/README.md @@ -6,7 +6,7 @@ like Python. This page explains how to get started with Mojo notebooks, and this repo directory contains notebooks that demonstrate some of Mojo's features (most of which we originally published on the [Mojo -Playground](https://playground.modular.com/)). +Playground](https://docs.modular.com/mojo/playground)). If you're not familiar with Jupyter notebooks, they're files that allow you to create documents with live code, equations, visualizations, and explanatory @@ -67,6 +67,7 @@ If you have [`magic`](https://docs.modular.com/magic) you can run the following command to launch JupyterLab from this directory: ```sh +# Run from an active conda or magic shell environment magic run jupyter lab ``` @@ -74,7 +75,17 @@ After a moment, it will open a browser window with JupterLab running. #### Using conda -Create a Conda environment, activate that enviroment, and install JupyterLab. +Conda allows you to export environments via `.yml` format. [Guide to managing +conda environments](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html). +If you already have a working jupyter environment on a different computer and +server you can export it using the following command. + +```sh +# Example of exporting environment.yml from a conda environment named `your-env` +conda env export --name your_env > environment.yml +``` + +To create a Conda environment, activate that environment, and install JupyterLab. ``` sh # Create a Conda environment if you don't have one @@ -87,6 +98,19 @@ conda run -n mojo-repo jupyter lab After a moment, it will open a browser window with JupterLab running. +#### Using more magic + +Magic allows you to create an environment from a conda `environment.yml`. + +```sh +# Create a magic environment if you don't have one +magic init mojo-repo --import environment.yml +# Activate the environment +cd mojo-repo && magic shell +# run JupyterLab +magic run jupyter lab +``` + ### 2. Run the .ipynb notebooks The left nav bar should show all the notebooks in this directory.