Skip to content

Commit

Permalink
add redirect debug
Browse files Browse the repository at this point in the history
  • Loading branch information
xgui3783 committed Jun 6, 2024
1 parent ca3ded4 commit 1bb08e7
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 30 deletions.
22 changes: 3 additions & 19 deletions .github/workflows/dockerimgs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,9 @@ jobs:
echo "Done"
deploy-on-okd:
deploy-on-ebrains:
runs-on: ubuntu-latest
needs: build-docker-img
steps:
- name: 'Trigger deploy'
run: |
if [ ! -z "${{ secrets.EBRAINS_OKD_PRODCSCS_ENDPOINT }}" ]
then
if [ ! -z "${{ secrets.EBRAINS_OKD_PRODCSCS_SIIBRATOOLBOX_TOKEN }}" ]
then
oc login ${{ secrets.EBRAINS_OKD_PRODCSCS_ENDPOINT }} --token=${{ secrets.EBRAINS_OKD_PRODCSCS_SIIBRATOOLBOX_TOKEN }}
oc project ${{ secrets.EBRAINS_OKD_PRODCSCS_SIIBRATOOLBOX_NSP }}
for dc in $(oc get dc -l app=siibra-toolbox-deploy-siibra-toolbox-jugex | awk '{print $1}' | tail -n +2)
do
oc rollout latest dc/$dc
done
else
echo "secrets.EBRAINS_OKD_PRODCSCS_SIIBRATOOLBOX_TOKEN not set, skipping ..."
fi
else
echo "secrets.EBRAINS_OKD_PRODCSCS_ENDPOINT not set, skipping..."
fi
- name: "skip for now"
run: "echo skip for now"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ upload_to_pypi.sh
venv
.vscode
.env
secret*
9 changes: 9 additions & 0 deletions http_wrapper/conf/siibra_jugex_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os

SIIBRA_TOOLBOX_VIEWER_PLUGIN_STATIC_DIR = os.getenv("SIIBRA_TOOLBOX_VIEWER_PLUGIN_STATIC_DIR")

HBP_GITLAB_HOST = os.getenv("HBP_GITLAB_HOST")
HBP_GITLAB_TOKEN = os.getenv("HBP_GITLAB_TOKEN")
HBP_GITLAB_PROJECT_ID = os.getenv("HBP_GITLAB_PROJECT_ID")

CHANNEL = os.getenv("SIIBRA_JURGEX_CELERY_CHANNEL", "siibra_jugex_http")
22 changes: 22 additions & 0 deletions http_wrapper/routes/git.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from fastapi import APIRouter, Request
from fastapi.responses import PlainTextResponse
from fastapi.exceptions import HTTPException

router = APIRouter()

# @router.get("/{repo}.git/info/refs")
# def info_refs():
# return PlainTextResponse(
# """db53a06240ccf01b51eefa3ee348a12e360db2bd\trefs/heads/master"""
# )

# @router.get("/{repo}.git/HEAD")
# def head():
# return PlainTextResponse(
# """ref: refs/heads/master\n"""
# )

# @router.get("/objects/{head}/{rest}")
# def get_obj():
# print("foo")
# raise HTTPException(404)
14 changes: 8 additions & 6 deletions http_wrapper/routes/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
from uuid import uuid4
from urllib.parse import quote, quote_plus
from http_wrapper.routes.common import PostReqModel, common_params, reverse_param
from http_wrapper.conf.siibra_jugex_conf import HBP_GITLAB_HOST, HBP_GITLAB_TOKEN, HBP_GITLAB_PROJECT_ID

HBP_GITLAB_HOST = os.getenv("HBP_GITLAB_HOST")
HBP_GITLAB_TOKEN = os.getenv("HBP_GITLAB_TOKEN")
HBP_GITLAB_PROJECT_ID = os.getenv("HBP_GITLAB_PROJECT_ID")

run_now_enabled = HBP_GITLAB_HOST is not None and HBP_GITLAB_TOKEN is not None and HBP_GITLAB_PROJECT_ID is not None
run_now_enabled = (HBP_GITLAB_HOST is not None
and HBP_GITLAB_TOKEN is not None
and HBP_GITLAB_PROJECT_ID is not None)

class NotebookExecutionSite(Enum):
EBRAINS_LAB="EBRAINS_LAB"
Expand Down Expand Up @@ -144,7 +143,10 @@ def delete_branch(branch: str):
gl = Gitlab(url=HBP_GITLAB_HOST, private_token=HBP_GITLAB_TOKEN)
project = gl.projects.get(HBP_GITLAB_PROJECT_ID)
project.branches.delete(branch)


@router.get("/redirect")
def redirect():
return RedirectResponse("https://lab.ebrains.eu/")

@router.get("/run", tags=TAGS)
def run_notebook(background_tasks: BackgroundTasks, site: NotebookExecutionSite, post_req:PostReqModel = Depends(common_params)):
Expand Down
3 changes: 1 addition & 2 deletions http_wrapper/scheduling/worker.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from typing import List
import os
import logging

CHANNEL = os.getenv("SIIBRA_JURGEX_CELERY_CHANNEL", "siibra_jugex_http")
from http_wrapper.conf.siibra_jugex_conf import CHANNEL

logger = logging.getLogger(__name__)

Expand Down
8 changes: 5 additions & 3 deletions http_wrapper/server.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from http_wrapper.routes.analysis import router as analysis_router
from http_wrapper.routes.notebook import router as notebook_router
from http_wrapper.routes.git import router as git_router
from http_wrapper.jugex_logger import access_logger
from http_wrapper.conf.siibra_jugex_conf import SIIBRA_TOOLBOX_VIEWER_PLUGIN_STATIC_DIR

from fastapi import FastAPI, Request
from fastapi.staticfiles import StaticFiles
from fastapi.middleware.cors import CORSMiddleware
from os import getenv
import time

app = FastAPI()
Expand Down Expand Up @@ -39,9 +40,10 @@ async def access_log(request: Request, call_next):

app.include_router(analysis_router, prefix="/analysis")
app.include_router(notebook_router, prefix="/notebook")
app.include_router(git_router, prefix="/git")

if getenv("SIIBRA_TOOLBOX_VIEWER_PLUGIN_STATIC_DIR"):
path_to_viewer_plugin = getenv("SIIBRA_TOOLBOX_VIEWER_PLUGIN_STATIC_DIR")
if SIIBRA_TOOLBOX_VIEWER_PLUGIN_STATIC_DIR:
path_to_viewer_plugin = SIIBRA_TOOLBOX_VIEWER_PLUGIN_STATIC_DIR
app.mount('/viewer_plugin', StaticFiles(directory=path_to_viewer_plugin))

from threading import Event
Expand Down

0 comments on commit 1bb08e7

Please sign in to comment.