Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Private Dashboards into Staging #42

Merged
merged 82 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
2f938f7
feat: redcap api, caching, upgrade python
greenstick Oct 26, 2023
a966c71
🧐 wip: test blob access
megasanjay Oct 26, 2023
6b2b401
chore: remove output
megasanjay Oct 27, 2023
756c7c8
🚑 fix: use a sas token
megasanjay Oct 30, 2023
1b2ec6d
wip: redcap api and supporting sql
greenstick Oct 31, 2023
b5bcd7d
Merge branch 'staging' of https://github.com/AI-READI/api.fairhub.io …
greenstick Oct 31, 2023
d315c64
feat: add api endpoint to request files from Azure
megasanjay Nov 1, 2023
4d3d175
✨ feat: add files endpoint
megasanjay Nov 1, 2023
21eb53a
✨ feat: add id to files
megasanjay Nov 1, 2023
9c5ae26
🐛fix: ignore created time
megasanjay Nov 1, 2023
de7b910
Merge branch 'staging' into blobs
megasanjay Nov 1, 2023
776e7b6
✨ feat: redcap endpoints done
greenstick Nov 2, 2023
869a271
Merge branch 'staging' of https://github.com/AI-READI/api.fairhub.io …
greenstick Nov 2, 2023
8d24d19
Merge branch 'staging' of https://github.com/AI-READI/api.fairhub.io …
greenstick Nov 2, 2023
10ef3bd
🚨 chore: fix redcap flake errors
greenstick Nov 2, 2023
dadc624
✨feat: hide redcap api token
greenstick Nov 2, 2023
eb71028
style: 🎨 fix code style issues with Black
lint-action Nov 2, 2023
eceaa8f
🐛 fix: return default port to 5000
greenstick Nov 2, 2023
7165910
🐛fix: ignore created time
megasanjay Nov 4, 2023
5357ec0
🚨 fix: fix formatting
megasanjay Nov 4, 2023
a6e1962
🚨 fix: fix flake errors
megasanjay Nov 4, 2023
dc24de6
style: 🎨 fix code style issues with Black
lint-action Nov 4, 2023
73ee3b1
🚨 fix: fix mypy errors
megasanjay Nov 4, 2023
2112c1a
Merge branch 'dashboard' of https://github.com/AI-READI/api.fairhub.i…
megasanjay Nov 4, 2023
4b836fb
style: 🎨 fix code style issues with Black
lint-action Nov 4, 2023
6cc0788
🚨 fix: fix pylint errors
megasanjay Nov 4, 2023
997750c
Merge branch 'dashboard' of https://github.com/AI-READI/api.fairhub.i…
megasanjay Nov 4, 2023
eb2962a
⬆️ chore: update to python 3.10
megasanjay Nov 4, 2023
76b4fd2
✅ test: update configs for cache
megasanjay Nov 4, 2023
287aee3
💚 ci: update ci test containers
megasanjay Nov 4, 2023
5f433c4
👷 chore: update dev compose
megasanjay Nov 4, 2023
93514a2
✨ feat: dashboard crud api
greenstick Nov 6, 2023
6d63c5a
wip: caching & dashboard done; cleanup in progress
greenstick Nov 14, 2023
7093fd0
⬆️ chore: cleaning up poe errors
greenstick Nov 15, 2023
794bc99
style: 🎨 fix code style issues with Black
lint-action Nov 15, 2023
2bff4b2
🐛 fix: etl config
greenstick Nov 15, 2023
88b36d9
Merge branch 'dashboard' of https://github.com/AI-READI/api.fairhub.i…
greenstick Nov 15, 2023
a84ff4b
🚨 fix: precommit errors fixed
greenstick Dec 5, 2023
d007c76
style: 🎨 fix code style issues with Black
lint-action Dec 5, 2023
b041334
🐛 fix: black issue with line length
greenstick Dec 5, 2023
6dbf4f8
Merge branch 'dashboard' of https://github.com/AI-READI/api.fairhub.i…
greenstick Dec 5, 2023
449797a
✨ feat: updates for new chart types/modules
greenstick Dec 12, 2023
91fbb9d
style: 🎨 fix code style issues with Black
lint-action Dec 12, 2023
26c0ed4
🐛 fix: minor fixes
greenstick Dec 13, 2023
6f5f98e
Merge branch 'dashboard' of https://github.com/AI-READI/api.fairhub.i…
greenstick Dec 13, 2023
1e1f849
style: 🎨 fix code style issues with Black
lint-action Dec 13, 2023
8e603d5
🐛 fix: minor fixes
greenstick Jan 20, 2024
4b5bf93
Merge branch 'dashboard' of https://github.com/AI-READI/api.fairhub.i…
greenstick Jan 20, 2024
300b156
🐛 fix: minor fixes
greenstick Jan 20, 2024
a2678da
style: 🎨 fix code style issues with Black
lint-action Jan 20, 2024
7c8f9a1
🐛 fix: minor fixes
greenstick Jan 20, 2024
004cdc2
Merge branch 'dashboard' of https://github.com/AI-READI/api.fairhub.i…
greenstick Jan 20, 2024
b7726af
style: 🎨 fix code style issues with Black
lint-action Jan 20, 2024
13748c2
Merge branch 'staging' into dashboard
greenstick Jan 23, 2024
e12265d
Merge branch 'dashboard' of https://github.com/AI-READI/api.fairhub.i…
greenstick Jan 23, 2024
4025744
🐛 fix: minor fixes
greenstick Jan 26, 2024
3f56c58
style: 🎨 fix code style issues with Black
lint-action Jan 26, 2024
95fb942
🐛 fix: minor fixes
greenstick Feb 4, 2024
f6f9fe4
style: 🎨 fix code style issues with Black
lint-action Feb 4, 2024
8ccd04a
🐛 fix: add host arg to app.py
greenstick Feb 5, 2024
86a0978
🐛 fix: fix module transform bug (needed to create deep copy)
greenstick Feb 6, 2024
c147960
✨feat: improved cache management
greenstick Feb 9, 2024
7641482
🐛 fix: minor fixes
greenstick Feb 9, 2024
cde2287
style: 🎨 fix code style issues with Black
lint-action Feb 13, 2024
bf42b45
🐛 fix: remove https://localhost:3000from CORS in debug mode
greenstick Feb 13, 2024
79ace19
Merge branch 'dashboard' of github.com:AI-READI/fairhub-api into dash…
greenstick Feb 13, 2024
f31e2c6
🐛 fix: import error
greenstick Feb 13, 2024
ce74942
🐛 fix: import error, upgrade to Python3.10
greenstick Feb 13, 2024
ef0efea
🐛 fix: import error - PyCap
greenstick Feb 13, 2024
5cf1ecd
✨feat: redcap + dashboard auth management
greenstick Feb 13, 2024
05db29b
style: 🎨 fix code style issues with Black
lint-action Feb 13, 2024
7c69aad
🐛 fix: minor fixes
greenstick Feb 13, 2024
76dc410
Merge branch 'dashboard' of github.com:AI-READI/fairhub-api into dash…
greenstick Feb 13, 2024
745a84b
style: 🎨 fix code style issues with Black
lint-action Feb 13, 2024
478cb12
🐛 fix: minor fixes
greenstick Feb 13, 2024
2383b55
Merge branch 'dashboard' of github.com:AI-READI/fairhub-api into dash…
greenstick Feb 13, 2024
12d080a
🔨 chore: update side scripts
megasanjay Feb 15, 2024
28089fa
✨feat: redcap api updates, dashboard wip
greenstick Feb 17, 2024
098457d
Merge branch 'dashboard' of github.com:AI-READI/fairhub-api into dash…
greenstick Feb 17, 2024
894b18a
style: 🎨 fix code style issues with Black
lint-action Feb 17, 2024
d9e6d81
feat: ✨ improved REDcap & Dashboard API structure
greenstick Feb 20, 2024
af6b55a
style: 🎨 fix code style issues with Black
lint-action Feb 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
FAIRHUB_DATABASE_URL="postgresql://admin:root@localhost:5432/fairhub_local"
FAIRHUB_SECRET="AddAny32+CharacterCountWordHereAsYourSecret"

FAIRHUB_AZURE_READ_SAS_TOKEN=
FAIRHUB_AZURE_STORAGE_ACCOUNT_NAME=

FAIRHUB_GROWTHBOOK_CLIENT_KEY=
FAIRHUB_GROWTHBOOK_CLIENT_KEY=
FAIRHUB_CACHE_DEFAULT_TIMEOUT=86400
FAIRHUB_CACHE_KEY_PREFIX=fairhub-io#
FAIRHUB_CACHE_HOST=localhost
FAIRHUB_CACHE_PORT=6379
FAIRHUB_CACHE_TYPE=RedisCache
FAIRHUB_CACHE_DB=0
FAIRHUB_CACHE_URL=redis://127.0.0.1:6379
67 changes: 67 additions & 0 deletions .github/workflows/deploy-app-to-main-slot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions

name: Build and deploy Python app to Azure Web App - api-fairhub-io

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python version
uses: actions/setup-python@v1
with:
python-version: "3.10"

- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate

- name: Install dependencies
run: pip install poetry==1.3.2 && poetry install

# Optional: Add step to run tests here (PyTest, Django test suites, etc.)

- name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v2
with:
name: python-app
path: |
.
!venv/

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: "main"
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: python-app
path: .

- name: "Deploy to Azure Web App"
uses: azure/webapps-deploy@v2
id: deploy-to-webapp
with:
app-name: "api-fairhub-io"
slot-name: "main"
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_6C6B1227CD464BFDBC9173E57CDEEC65 }}
67 changes: 67 additions & 0 deletions .github/workflows/deploy-app-to-staging-slot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions

name: Build and deploy Python app to Azure Web App - api-fairhub-io

on:
push:
branches:
- staging
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- staging
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python version
uses: actions/setup-python@v1
with:
python-version: "3.10"

- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate

- name: Install dependencies
run: pip install poetry==1.3.2 && poetry install

# Optional: Add step to run tests here (PyTest, Django test suites, etc.)

- name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v2
with:
name: python-app
path: |
.
!venv/

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: "staging"
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: python-app
path: .

- name: "Deploy to Azure Web App"
uses: azure/webapps-deploy@v2
id: deploy-to-webapp
with:
app-name: "api-fairhub-io"
slot-name: "staging"
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_STAGING }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ coverage

# Environment variables
.env
.venv

# Virutal Environments
.venv
Expand Down
2 changes: 1 addition & 1 deletion .pylint.ini
Original file line number Diff line number Diff line change
Expand Up @@ -410,4 +410,4 @@ known-third-party=enchant
# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=builtins.BaseException,
builtins.Exception
builtins.Exception
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8-alpine
FROM python:3.10-alpine

EXPOSE 5000

Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ Close the database with:
docker-compose -f ./db-docker-compose.yaml down -v
```

## Running

For developer mode:

```bash
flask run --debug
```

For production mode:

```bash
python3 app.py --host $HOST --port $PORT
```

## License

This work is licensed under
Expand Down
1 change: 1 addition & 0 deletions alembic/versions/0defbfc71c59_add_identifier_to_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2024-01-05 13:25:15.547450

"""

from typing import Sequence, Union

from alembic import op
Expand Down
1 change: 1 addition & 0 deletions alembic/versions/29e42ce4be3f_adding_license_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-12-21 13:34:26.478808

"""

from typing import Sequence, Union

from alembic import op
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-11-08 15:47:00.205940

"""

from typing import Sequence, Union

import alembic
Expand Down
7 changes: 7 additions & 0 deletions apis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
"""Initialize the api system for the backend"""

from flask_restx import Api, Resource

from apis.dataset_metadata_namespace import api as dataset_metadata_namespace
from apis.study_metadata_namespace import api as study_metadata_namespace

from .authentication import api as authentication
from .contributor import api as contributors_api
from .dashboard import api as dashboard
from .dataset import api as dataset_api
from .dataset_metadata.dataset_access import api as access
from .dataset_metadata.dataset_alternate_identifier import api as alternate_identifier
Expand All @@ -23,6 +25,7 @@
from .dataset_metadata.dataset_title import api as title
from .file import api as file_api
from .participant import api as participants_api
from .redcap import api as redcap
from .study import api as study_api
from .study_metadata.study_arm import api as arm
from .study_metadata.study_available_ipd import api as available_ipd
Expand Down Expand Up @@ -89,6 +92,8 @@
"identification",
"study_description",
"dataset_contributor",
"redcap",
"dashboard",
"utils",
]

Expand Down Expand Up @@ -117,3 +122,5 @@ def get(self):
api.add_namespace(contributors_api)
api.add_namespace(user)
api.add_namespace(utils)
api.add_namespace(redcap)
api.add_namespace(dashboard)
13 changes: 13 additions & 0 deletions apis/authentication.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""This module is used to authenticate users to the system and
handle few authentication errors. Also, it sets token for logged user
along with expiration date"""

import datetime
import importlib
import os
Expand Down Expand Up @@ -322,6 +323,12 @@ def is_granted(permission: str, study=None):
"participant",
"study_metadata",
"dataset_metadata",
"add_redcap",
"update_redcap",
"delete_redcap",
"add_dashboard",
"update_dashboard",
"delete_dashboard",
"make_owner",
],
"admin": [
Expand All @@ -341,6 +348,12 @@ def is_granted(permission: str, study=None):
"participant",
"study_metadata",
"dataset_metadata",
"add_redcap",
"update_redcap",
"delete_redcap",
"add_dashboard",
"update_dashboard",
"delete_delete",
],
"editor": [
"editor",
Expand Down
Loading
Loading