Skip to content

Commit

Permalink
refactor(server): better env var names, provide example.env
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdoret committed Feb 29, 2024
1 parent b01ae7a commit 4c9f485
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
14 changes: 14 additions & 0 deletions deploy/.example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# PUBLIC
URL_PREFIX="http://localhost:80"
S3_PUBLIC_URL="$URL_PREFIX/s3"
HTSGET_PUBLIC_URL="$URL_PREFIX/htsget"

# MINIO
MINIO_ROOT_USER="minio"
MINIO_ROOT_PASSWORD="minio123"
MINIO_SERVER_ACCESS_KEY="user"
MINIO_SERVER_SECRET_KEY="pass"
MINIO_DEFAULT_BUCKET="modo-demo:public"

# HTSGET
HTSGET_DATA_DIR="/data"
18 changes: 9 additions & 9 deletions deploy/modo-server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@
"""

import os
from typing import Union

from fastapi import FastAPI
from modo.api import MODO
import rdflib
import s3fs
import zarr


S3_URL = os.environ["S3_ENDPOINT"]
S3_PUBLIC_URL = os.environ["S3_PUBLIC_URL"]
S3_LOCAL_URL = os.environ["S3_LOCAL_URL"]
BUCKET = os.environ["S3_BUCKET"]
HTSGET = os.environ["HTSGET_ENDPOINT"]
HTSGET_PUBLIC_URL = os.environ["HTSGET_PUBLIC_URL"]
HTSGET_LOCAL_URL = os.environ["HTSGET_LOCAL_URL"]

app = FastAPI()
minio = s3fs.S3FileSystem(anon=True, endpoint_url=S3_URL)
minio = s3fs.S3FileSystem(anon=True, endpoint_url=S3_LOCAL_URL)


@app.get("/")
def index():
return {
"Message": "Welcome to the modo server",
"Catalog bucket": f"{S3_URL}/{BUCKET}",
"htsget": HTSGET,
"Catalog bucket": f"{S3_PUBLIC_URL}/{BUCKET}",
"htsget": HTSGET_PUBLIC_URL,
}


Expand All @@ -39,7 +39,7 @@ def list_modos() -> list[str]:
"""List MODO entries in bucket."""
modos = minio.ls(BUCKET)
# NOTE: modo contains bucket name
return [f"{S3_URL}/{modo}" for modo in modos]
return [f"{S3_PUBLIC_URL}/{modo}" for modo in modos]


@app.get("/meta")
Expand All @@ -52,6 +52,6 @@ def gather_metadata():
archive = zarr.open(
store=store,
)
meta = MODO(path=f"{S3_URL}/{modo}", archive=archive).metadata
meta = MODO(path=f"{S3_LOCAL_URL}/{modo}", archive=archive).metadata

return meta

0 comments on commit 4c9f485

Please sign in to comment.