Python Environment Setup

Python Environment Setup#

This tutorial can be set up in two ways: GitHub Codespaces or Conda.

During the tutorial, to follow along, we recommend using GitHub Codespaces for ease of use, as you won’t need to worry about setting up the compute environment. However, if you would like to set up the tutorial on your local machine, you can use Conda.

GitHub Codespaces, is a cloud-based development environment that’s hosted in the cloud. This option is available indefinitely, but you will be limited in the free resources you can use with GitHub Codespaces.

🐱‍💻 GitHub Codespaces#

Note

Indefinite Access, but Limited Resources. If your Codespace gives you a low disk space error, please refresh the tab.

This tutorial is available to run within Github Codespaces - “a development environment that’s hosted in the cloud” - with the conda packages specification in the conda-lock.yml file. However, you will be limited in the free resources you can use with GitHub Codespaces and you need to have a GitHub account to use GitHub Codespaces.

A codespace is a development environment that’s hosted in the cloud. You are able to chose from various Dev container configurations. For this specific workshop, please ensure that Scipy2024 is selected. GitHub currently gives every user 120 vCPU hours per month for free, beyond that you must pay. So be sure to explicitly stop or shut down your codespace when you are done by going to this page (codespaces).

Open in GitHub Codespaces

☝️ Click the button above to go to options window to launch a Github codespace.

🐍 Conda#

Note

Most Persistent, but requires local setup that take time and may differ from the tutorial environment

You can set up the tutorial locally using a Conda environment. Here’s how:

  1. Downloading and Installing Conda

    If you don’t have Conda installed, we recommend following the instructions to download and install the Miniforge distribution >= Miniforge3-22.3.1-0 of Conda. This distribution is a minimal installer for conda specifically optimized for conda-forge (Community-led recipes, infrastructure and distributions for conda.).

  2. Create a new Conda environment called ssec-scipy2024 with the conda-lock package installed. This package is used to install the exact versions of the packages in the conda-lock.yml file.

    Note: Ensure that you are using Python Version 3.11. The command below will install a clean conda environment with just Python 3.11, conda-lock, and their dependencies

    conda create --yes -n ssec-scipy2024 python=3.11 conda-lock
    
  3. Activate the conda environment:

    conda activate ssec-scipy2024
    
  4. Download the conda lock file:

    The example below uses wget to download the file. If you don’t have wget installed, you can download the file directly from github by clicking the download () button on the right side of page

    wget https://raw.githubusercontent.com/uw-ssec/docker-images/main/tutorial-scipy-2024/conda-lock.yml
    
  5. Install the packages for the tutorial using conda-lock:

    conda-lock install -n ssec-scipy2024 conda-lock.yml
    
  6. Clone the tutorial repository:

    git clone https://github.com/uw-ssec/tutorials.git
    
  7. Navigate to the tutorial directory:

    cd tutorials/
    
  8. Download the tutorial data with the provided download_data.py script in the resources directory. This includes the OLMo data, copy of the vector database, and others. The data are downloaded to ~/.cache/ssec_tutorials/ directory:

    python resources/download_data.py
    
  9. Navigate to the tutorial directory:

    cd AI_Postdoc_Workshop
    
  10. Run Jupyter Lab:

    jupyter lab
    
  11. Navigate to the specific tutorial notebook you would like to run. For guidance on using the Jupyter Lab interface, see the Jupyter Lab documentation.