Skip to content

Commit

Permalink
Merge pull request #47 from CUAHSI/main
Browse files Browse the repository at this point in the history
main -> develop
  • Loading branch information
devincowan authored Jul 16, 2024
2 parents b4c4665 + 93ef089 commit 71dd64e
Show file tree
Hide file tree
Showing 30 changed files with 74 additions and 227 deletions.
2 changes: 2 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ OAUTH2_CLIENT_SECRET="Get From Keycloak"

VITE_APP_NAME=swotvis

VITE_TEST_MODE=false

# if using npm run dev, set VITE_APP_ORIGIN=http://localhost:5173
VITE_APP_ORIGIN=https://localhost

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/frontend-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
- name: create env file
run: |
touch .env
echo VITE_TEST_MODE=${{ secrets.VITE_TEST_MODE }} >> .env
echo VITE_APP_API_URL=${{ secrets.VITE_APP_API_URL }} >> .env
echo VITE_APP_FULL_URL=${{ secrets.VITE_APP_FULL_URL }} >> .env
echo VITE_OAUTH2_REDIRECT_URL=${{ secrets.VITE_OAUTH2_REDIRECT_URL }} >> .env
Expand Down
6 changes: 3 additions & 3 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ RUN python -m wget https://dl.min.io/client/mc/release/linux-amd64/mc
RUN chmod +x mc
RUN mv mc /usr/local/bin/mc

COPY ./subsetter /subsetter
COPY ./swotvis /swotvis

ENV PYTHONPATH "/subsetter/:${PYTHONPATH}"
ENV PYTHONPATH "/swotvis/:${PYTHONPATH}"

EXPOSE 8000

CMD uvicorn --host 0.0.0.0 --port 8000 --proxy-headers subsetter.main:app
CMD uvicorn --host 0.0.0.0 --port 8000 --proxy-headers swotvis.main:app
1 change: 0 additions & 1 deletion api/subsetter/app/routers/access_control/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion api/subsetter/app/routers/argo/__init__.py

This file was deleted.

Empty file.
192 changes: 0 additions & 192 deletions api/subsetter/app/routers/discovery/discovery.py

This file was deleted.

1 change: 0 additions & 1 deletion api/subsetter/app/routers/storage/__init__.py

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion api/subsetter/app/db.py → api/swotvis/app/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from fastapi_users.db import BaseOAuthAccount, BeanieBaseUser, BeanieUserDatabase
from pydantic import BaseModel, Field

from subsetter.config import get_settings
from swotvis.config import get_settings

DATABASE_URL = get_settings().mongo_url
client = motor.motor_asyncio.AsyncIOMotorClient(DATABASE_URL, uuidRepresentation="standard")
Expand Down
4 changes: 2 additions & 2 deletions api/subsetter/app/models.py → api/swotvis/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from fastapi import Depends, HTTPException, Path, status
from pydantic import BaseModel, Field

from subsetter.app.db import Submission, User
from subsetter.app.users import current_active_user
from swotvis.app.db import Submission, User
from swotvis.app.users import current_active_user


class WorkflowParams(BaseModel):
Expand Down
1 change: 1 addition & 0 deletions api/swotvis/app/routers/access_control/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from swotvis.app.routers.access_control.router import router
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def refresh_minio_policy(user):
def bucket_name(resource_id: str):
# raccess = ResourceAccess.objects.filter(resource__short_id=resource_id).first()
# return raccess.owners.first().username
return "subsetter-outputs"
return "swotvis-outputs"


def create_view_statements(owner, submissions) -> list:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from fastapi import APIRouter, Depends, HTTPException
from pydantic import BaseModel

from subsetter.app.db import Submission, User
from subsetter.app.routers.access_control.policy_generation import minio_policy
from subsetter.app.users import current_active_user
from swotvis.app.db import Submission, User
from swotvis.app.routers.access_control.policy_generation import minio_policy
from swotvis.app.users import current_active_user

router = APIRouter()

Expand Down
1 change: 1 addition & 0 deletions api/swotvis/app/routers/argo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from swotvis.app.routers.argo.router import router
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
from argo_workflows.api import workflow_service_api
from fastapi import APIRouter, Depends, Query

from subsetter.app.db import Submission, User
from subsetter.app.models import (
from swotvis.app.db import Submission, User
from swotvis.app.models import (
LogsResponseModel,
SubmissionResponseModel,
UrlResponseModel,
UserSubmissionsResponseModel,
WorkflowDep,
)
from subsetter.app.users import current_active_user
from subsetter.config import get_minio_client, get_settings
from swotvis.app.users import current_active_user
from swotvis.config import get_minio_client, get_settings
from .transformer import transform_latlon

if get_settings().cloud_run:
Expand Down Expand Up @@ -220,7 +220,7 @@ async def logs(workflow_params: WorkflowDep) -> LogsResponseModel:
async def signed_url_minio(workflow_params: WorkflowDep) -> UrlResponseModel:
submission = workflow_params.user.get_submission(workflow_params.workflow_id)
url = get_minio_client().presigned_get_object(
"subsetter-outputs",
"swotvis-outputs",
f"{workflow_params.user.username}/{submission.workflow_name}/{submission.workflow_id}/all.gz",
)
return {'url': url}
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions api/swotvis/app/routers/storage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from swotvis.app.routers.storage.router import router
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fastapi import APIRouter

from subsetter.app.models import WorkflowDep
from subsetter.config import get_minio_client
from swotvis.app.models import WorkflowDep
from swotvis.config import get_minio_client

router = APIRouter()

Expand Down Expand Up @@ -46,7 +46,7 @@ async def share_workflow_with_user(
# @router.post('/extract/{workflow_id}')
# async def extract_workflow_artifact(workflow_params: WorkflowDep) -> SubmissionResponseModel:
# workflow_id = str(uuid.uuid4())
# bucket = "subsetter-outputs"
# bucket = "swotvis-outputs"
# submission = workflow_params.user.get_submission(workflow_params.workflow_id)
# path_key = f'{submission.workflow_name}/{submission.workflow_id}/subset.gz'
# api_instance.submit_workflow(
Expand Down
1 change: 1 addition & 0 deletions api/swotvis/app/routers/test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from swotvis.app.routers.test.router import router
8 changes: 8 additions & 0 deletions api/swotvis/app/routers/test/router.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from fastapi import APIRouter

router = APIRouter()


@router.get('/', description="Test endpoint")
async def test_endpoint():
return {"message": "Hello, world!"}
File renamed without changes.
4 changes: 2 additions & 2 deletions api/subsetter/app/users.py → api/swotvis/app/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from httpx_oauth.exceptions import GetIdEmailError
from httpx_oauth.oauth2 import OAuth2

from subsetter.app.db import User, get_user_db
from subsetter.config import get_settings, get_minio_client
from swotvis.app.db import User, get_user_db
from swotvis.config import get_settings, get_minio_client

SECRET = "SECRET"

Expand Down
File renamed without changes.
25 changes: 15 additions & 10 deletions api/subsetter/main.py → api/swotvis/main.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import subprocess
import httpx

from beanie import init_beanie
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from subsetter.app.db import User, db
from subsetter.app.routers.access_control import router as access_control_router
from subsetter.app.routers.argo import router as argo_router
from subsetter.app.routers.storage import router as storage_router
from subsetter.app.schemas import UserRead, UserUpdate
from subsetter.app.users import SECRET, auth_backend, cuahsi_oauth_client, fastapi_users
from subsetter.config import get_settings
from swotvis.app.db import User, db
from swotvis.app.routers.access_control import router as access_control_router
from swotvis.app.routers.argo import router as argo_router
from swotvis.app.routers.storage import router as storage_router
from swotvis.app.routers.test import router as test_router
from swotvis.app.schemas import UserRead, UserUpdate
from swotvis.app.users import SECRET, auth_backend, cuahsi_oauth_client, fastapi_users
from swotvis.config import get_settings

# TODO: get oauth working with swagger/redoc
# Setting the base url for swagger docs
Expand Down Expand Up @@ -81,6 +80,12 @@
tags=["users"],
)

app.include_router(
test_router,
prefix="/test",
tags=["test"],
)


@app.on_event("startup")
async def on_startup():
Expand Down
Loading

0 comments on commit 71dd64e

Please sign in to comment.