Skip to content

Commit

Permalink
Fix Development Environment (#260)
Browse files Browse the repository at this point in the history
* fix: Adjust service and home directories, fix labextension directory, and install oauthenticator

* Add JUPYTERHUB_CRYPT_KEY, required to enable auth state

* Ignore missing files

* doc: Mention to clone labextension
  • Loading branch information
Paul2708 authored Jan 23, 2025
1 parent 4c05ef6 commit 8a1505d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
5 changes: 3 additions & 2 deletions docs/source/installation/installation_from_source.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ Running this command will make sure that all dependencies from `pyproject.toml`

### Grader Labextension

To locally install Grader Labextension, make sure to clone [Grader Labextension project](https://github.com/TU-Wien-dataLAB/Grader-Labextension) or download the corresponding [zip file](https://github.com/TU-Wien-dataLAB/Grader-Labextension/archive/refs/heads/main.zip).
To locally install Grader Labextension, make sure to clone [Grader Labextension project](https://github.com/TU-Wien-dataLAB/grader-labextension) or download the corresponding [zip file](https://github.com/TU-Wien-dataLAB/Grader-Labextension/archive/refs/heads/main.zip).

Grader Labextension is composed of a Python package named `grader_labextension` for the server extension and an NPM package `grader-labextension` for the frontend extensio.

To install the extension in development mode, navigate to your local `Grader_Labextension` directory and run:
To install the extension in development mode, navigate to your local `grader-labextension` directory and run:

```bash
pip install -e .
Expand Down Expand Up @@ -76,6 +76,7 @@ Keep in mind that `jlpm watch` continues running until you stop it and can consu
## Installation Scripts

Alternatively you can use installation scripts which you can find in `examples/dev_environment` directory. This directory provides you with local development environment and serves as a guide for more complex setups. The bash scripts have to be run in the `dev_environment` directory.
Ensure that you cloned the [Grader Labextension project](https://github.com/TU-Wien-dataLAB/grader-labextension) and it is located in the same directory as the grader service repository.

The `dev_enviroment` directory contains following files:

Expand Down
8 changes: 3 additions & 5 deletions examples/dev_environment/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
rm -rf ./home_dir
rm -rf ./service_dir

rm ./grader.db

rm ./jupyterhub-proxy.pid
rm ./jupyterhub.sqlite
rm ./jupyterhub_cookie_secret
rm -f ./jupyterhub-proxy.pid
rm -f ./jupyterhub.sqlite
rm -f ./jupyterhub_cookie_secret
2 changes: 1 addition & 1 deletion examples/dev_environment/grader_service_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

c.GraderService.service_host = "127.0.0.1"
# existing directory to use as the base directory for the grader service
service_dir = os.path.expanduser("~/grader_service_dir")
service_dir = os.path.join(os.getcwd(), "service_dir")
c.GraderService.grader_service_dir = service_dir

c.RequestHandlerConfig.autograde_executor_class = LocalAutogradeExecutor
Expand Down
8 changes: 6 additions & 2 deletions examples/dev_environment/install.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#!/bin/bash

DEV_ENV_DIR=$PWD

echo "Creating virtual environment..."
python -m venv venv
source ./venv/bin/activate
which python

python -m pip install --upgrade pip
pip install jupyterhub jupyterlab
pip install jupyterhub jupyterlab oauthenticator

echo "Installing grader_service..."
cd ../../
pip install -e .

echo "Installing grader_labextension..."
cd ../Grader-Labextension
cd ../grader-labextension
pip install -e .

jupyter labextension develop . --overwrite
Expand All @@ -25,6 +27,8 @@ jupyter server extension list
jupyter labextension list

# home directory for users
cd $DEV_ENV_DIR

mkdir -p ./home_dir

mkdir -p ./service_dir
Expand Down
3 changes: 2 additions & 1 deletion examples/dev_environment/jupyterhub_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from jupyterhub import orm
import os

## generic
c.JupyterHub.admin_access = True
Expand Down Expand Up @@ -45,7 +46,7 @@ def auth_state_hook(spawner, auth_state):

## spawner
c.JupyterHub.spawner_class = 'jupyterhub.spawner.SimpleLocalProcessSpawner'
c.SimpleLocalProcessSpawner.home_dir_template = '/tmp/lab_dir/{username}'
c.SimpleLocalProcessSpawner.home_dir_template = os.path.join(os.getcwd(), "home_dir", "{username}")

## simple setup
c.JupyterHub.ip = '127.0.0.1'
Expand Down
2 changes: 2 additions & 0 deletions examples/dev_environment/run_hub.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash
source ./venv/bin/activate

export JUPYTERHUB_CRYPT_KEY=$(openssl rand -hex 32)
jupyterhub -f ./jupyterhub_config.py

0 comments on commit 8a1505d

Please sign in to comment.