From ec535e939bf12b0ea55f2eba34934fffa9739098 Mon Sep 17 00:00:00 2001 From: Vincent Emonet Date: Mon, 29 Jul 2024 10:58:04 +0200 Subject: [PATCH] improve dev instructions and fix auth audience for dev in config --- README.md | 90 ++++++++++++++++++++----------------------- backend/src/config.py | 8 ++-- 2 files changed, 45 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index dfa440b..ac8bfd9 100644 --- a/README.md +++ b/README.md @@ -74,71 +74,63 @@ This platform is composed of 3 main components: > | ----------------- | -------- | --------------- | --------------- | ----- | -------------- | ----- | -------------- | ------------ | ------------------ | ----------- | ---------------------- | --------------------- | --------------------- | ----------------------- | > | | | | | | | | | | | | | | | | -### 📥 Install dependencies +### ⚡ Start for development -1. Install [hatch](https://hatch.pypa.io/latest/) for managing python projects, and [pnpm](https://pnpm.io/installation) for TS/JS projects +Requirements: [Docker](https://docs.docker.com/engine/install/) - ```bash - pip install hatch - ``` +1. Create a `.env` file with the secret configuration at the root of the repository (ask admins for the client ID and secret, and retrieve you Decentriq token from decentriq): -2. Create a `backend/.env` file with secret configuration: + ```bash + AUTH_ENDPOINT=https://auth0.com + CLIENT_ID=AAA + CLIENT_SECRET=BBB + DECENTRIQ_EMAIL=ccc@ddd.com + DECENTRIQ_TOKEN=EEE + JWT_SECRET=vCitcsPBwH4BMCwEqlO1aHJSIn--usrcyxPPRbeYdHM + ADMINS=admin1@email.com,admin2@email.com + ``` - ```bash - AUTH_ENDPOINT=https://auth0.com - CLIENT_ID=AAA - CLIENT_SECRET=BBB - DECENTRIQ_EMAIL=ccc@ddd.com - DECENTRIQ_TOKEN=EEE - JWT_SECRET=vCitcsPBwH4BMCwEqlO1aHJSIn--usrcyxPPRbeYdHM - ADMINS=admin1@email.com,admin2@email.com - ``` +2. Put the excel spreadsheet with all cohorts metadata in `data/iCARE4CVD_Cohorts.xlsx`. Uploaded cohorts will go to separated folders in `data/cohorts/` -3. Put the excel spreadsheet with all cohorts metadata in `data/iCARE4CVD_Cohorts.xlsx`. Uploaded cohorts will go to separated folders in `data/cohorts/` +3. Start the whole stack in development with docker compose, with hot reload for the frontend and backend: -> \[!WARNING] -> -> There is a bug with pandas when conditional cells are used in the excel spreadsheet. To remove conditional cells copy the whole sheet content, delete the current content, and paste the original sheet content without formatting (ctrl+shift+v) + ```bash + docker compose up + ``` -> \[!IMPORTANT] +> [!IMPORTANT] > > For the authentication to the Decentriq OAuth provider to work you need to deploy the backend on -### ⚡ Start for development - -In development it is more convenient to start all components like the database with docker, and the backend/frontend outside of docker. - -Start the database with docker: - -```bash -docker compose up db -``` - -In a different terminal, start the backend: - -```bash -cd backend -hatch run dev -``` - -In another terminal, start the frontend: - -```bash -cd frontend -pnpm dev -``` +> [!NOTE] +> +> In development the user requesting a DCR will be added to as data owner of all cohorts dataset requested for development purpose (so they can provision the data themselves, and to avoid spamming emails owners when developing) -> \[!TIP] +> [!TIP] +> +> Alternatively you can start the different component in in different terminals outside of docker. For this, put the `.env` file in the `backend` folder > -> Alternatively you can start the whole stack in development with docker compose in 1 command, but you won't get hot reload for the frontend (you will need to rebuild the frontend image for changes to be taken into account): +> Start the database with docker: > > ```bash -> docker compose up +>docker compose up db > ``` - -> [!NOTE] +> +> In a different terminal, start the backend with [hatch](https://hatch.pypa.io/latest/install/): > -> In development the user requesting a DCR will be added to as data owner of all cohorts dataset requested for development purpose (so they can provision the data themselves, and to avoid spamming emails owners when developing) +> ```bash +>cd backend +> hatch run dev +> ``` +> +> In another terminal, start the frontend with [pnpm](https://pnpm.io/installation): +> +> ```bash +>cd frontend +> pnpm install +> pnpm dev +> ``` +> ### 🧹 Code formatting and linting diff --git a/backend/src/config.py b/backend/src/config.py index b451491..b9c829d 100644 --- a/backend/src/config.py +++ b/backend/src/config.py @@ -39,10 +39,10 @@ def redirect_uri(self) -> str: @property def auth_audience(self) -> str: - if self.dev_mode: - return "https://other-ihi-app" - else: - return "https://explorer.icare4cvd.eu" + # if self.dev_mode: + # return "https://other-ihi-app" + # else: + return "https://explorer.icare4cvd.eu" @property def query_endpoint(self) -> str: