From c4839292a6759ac82d87b901463cc44a740df947 Mon Sep 17 00:00:00 2001 From: Viacheslav Kukushkin Date: Sun, 21 Jan 2024 19:34:14 +0300 Subject: [PATCH] Codespaces (#521) * Create devcontainer.json * Supported python3.10 Updated PyYAML to 6.0.1 as 5.4.1 do not support py3.10 * Installing medperf via codespaces features * Update devcontainer.json * Custom codespaces image * Update devcontainer.json * Update devcontainer.json * Update devcontainer.json * Update devcontainer.json * Update devcontainer.json * Update devcontainer.json * Update devcontainer.json * Update devcontainer.json * Update devcontainer.json * Update devcontainer.json * Update devcontainer.json * Update devcontainer.json * Update devcontainer.json * Moved all set up to a container post-start script * Update devcontainer.json * update env_start.sh * moved server start to a post-attach step * update devcontainer.json * update devcontainer.json * Moved server running to a separate script * Removed commented code * Used custom codespace image path for future changes * Added codespaces option to tutorials * small fix * add dockerfile placeholder --------- Co-authored-by: hasan7n --- .devcontainer/Dockerfile | 1 + .devcontainer/devcontainer.json | 10 ++++++++++ cli/requirements.txt | 4 ++-- docs/getting_started/shared/before_we_start.md | 15 +++++++++++---- tutorials_scripts/codespaces/env_start.sh | 13 +++++++++++++ .../codespaces/run_server_detached.sh | 3 +++ 6 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 tutorials_scripts/codespaces/env_start.sh create mode 100644 tutorials_scripts/codespaces/run_server_detached.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..9867beba2 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1 @@ +FROM mcr.microsoft.com/devcontainers/python:3.10-bookworm diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..be0342387 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,10 @@ +{ + "image": "docker.io/mlcommons/medperf-codespaces:latest", + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": { + "moby": false + } + }, + "postStartCommand": "bash /workspaces/medperf/tutorials_scripts/codespaces/env_start.sh", + "postAttachCommand": "bash /workspaces/medperf/tutorials_scripts/codespaces/run_server_detached.sh" +} diff --git a/cli/requirements.txt b/cli/requirements.txt index 93d014cd7..eec3d960b 100644 --- a/cli/requirements.txt +++ b/cli/requirements.txt @@ -1,6 +1,6 @@ typer~=0.6.0 rich~=12.5.0 -PyYAML>=5.4,<6 +PyYAML==6.0.1 requests>=2.26.0 pydantic==1.10.2 yaspin==2.1.0 @@ -20,4 +20,4 @@ schema==0.7.5 # setuptools hotfix: https://github.com/mlcommons/medperf/issues/449 setuptools<=66.1.1 email-validator==2.0.0 -auth0-python==4.3.0 \ No newline at end of file +auth0-python==4.3.0 diff --git a/docs/getting_started/shared/before_we_start.md b/docs/getting_started/shared/before_we_start.md index 4b39270eb..168982323 100644 --- a/docs/getting_started/shared/before_we_start.md +++ b/docs/getting_started/shared/before_we_start.md @@ -2,11 +2,18 @@ #### First steps -To start experimenting with MedPerf through this tutorial, you need to start by following these quick steps: +##### Running in cloud via Github Codespaces - 1. **[Create an Account](../signup)** - 2. **[Install Medperf](../installation)** - 3. **[Set up Medperf](../setup)** +As the most easy way to play with the tutorials you can launch a preinstalled [Codespace](https://github.com/features/codespaces) cloud environment for MedPerf by clicking this link: + +[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=416800365) + +##### Running in local environment + +To start experimenting with MedPerf through this tutorial on your local machine, you need to start by following these quick steps: + + 1. **[Install Medperf](../installation)** + 2. **[Set up Medperf](../setup)** #### Prepare the Local MedPerf Server diff --git a/tutorials_scripts/codespaces/env_start.sh b/tutorials_scripts/codespaces/env_start.sh new file mode 100644 index 000000000..48801fb55 --- /dev/null +++ b/tutorials_scripts/codespaces/env_start.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +echo "Preparing local medperf server..." +# we are located at /workspaces/medperf/ where repo is cloned to +pip install -e ./cli +pip install -r server/requirements.txt +pip install -r server/test-requirements.txt +medperf profile activate local + +cd server +cp .env.local.local-auth .env +medperf auth login -e testmo@example.com +echo "Medperf is ready for local usage" +cd .. diff --git a/tutorials_scripts/codespaces/run_server_detached.sh b/tutorials_scripts/codespaces/run_server_detached.sh new file mode 100644 index 000000000..c152a3953 --- /dev/null +++ b/tutorials_scripts/codespaces/run_server_detached.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +cd /workspaces/medperf/server +bash ./setup-dev-server.sh < /dev/null &>server.log &