Skip to content

Commit

Permalink
updated service info
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Apr 11, 2024
1 parent 5bc60f8 commit 6d34a4b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 27 deletions.
10 changes: 0 additions & 10 deletions bedhost/const.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import os
from platform import python_version
from bbconf import __version__ as bbconf_v

from ._version import __version__ as SERVER_VERSION

PKG_NAME = "bedhost"

# for now bedstat version is hard coded
ALL_VERSIONS = {
"bedhost_version": SERVER_VERSION,
"bbconf_version": bbconf_v,
"python_version": python_version(),
}
TEMPLATES_DIRNAME = "templates"
STATIC_DIRNAME = "../docs"
STATIC_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), STATIC_DIRNAME)
Expand Down
8 changes: 8 additions & 0 deletions bedhost/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,16 @@ class ComponentVersions(BaseModel):
bedhost_version: str
bbconf_version: str
python_version: str
geniml_version: str
openapi_version: str


class EmbeddingModels(BaseModel):
vec2vec: str
region2vec: str
text2vec: str


class ServiceInfoResponse(BaseModel):
id: str
name: str
Expand All @@ -62,3 +69,4 @@ class ServiceInfoResponse(BaseModel):
environment: str
version: str
component_versions: ComponentVersions
embedding_models: EmbeddingModels
10 changes: 4 additions & 6 deletions bedhost/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

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

import markdown
from fastapi.templating import Jinja2Templates
from bbconf.exceptions import (
MissingObjectError,
MissingThumbnailError,
BadAccessMethodError,
BEDFileNotFoundError,
BedSetNotFoundError,
)
Expand All @@ -24,11 +23,10 @@
drs_response,
)
from .cli import build_parser
from ._version import __version__ as bedhost_version
from .const import (
ALL_VERSIONS,
PKG_NAME,
STATIC_PATH,
SERVER_VERSION,
)


Expand Down Expand Up @@ -62,7 +60,7 @@
app = FastAPI(
title=PKG_NAME,
description="BED file/sets statistics and image server API",
version=SERVER_VERSION,
version=bedhost_version,
docs_url="/docs",
openapi_tags=tags_metadata,
)
Expand All @@ -72,7 +70,7 @@
"http://localhost:8000",
"http://localhost:5173",
"https://bedbase.org",
"*", # allow cross origin resource sharing, since this is a public API
"*", # allow cross-origin resource sharing, since this is a public API
]

app.add_middleware(
Expand Down
32 changes: 23 additions & 9 deletions bedhost/routers/base_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@
from fastapi import APIRouter

from bbconf.models.base_models import StatsReturn

from platform import python_version
from bbconf import __version__ as bbconf_version
from geniml import __version__ as geniml_version

from ..main import bbagent, app
from ..const import ALL_VERSIONS
from ..helpers import get_openapi_version
from ..data_models import ServiceInfoResponse
from .._version import __version__ as bedhost_version

router = APIRouter(prefix="/v1", tags=["base"])


packages_versions = {}


@router.get(
"/stats",
summary="Get summary statistics for the DRS object store",
Expand All @@ -36,24 +41,33 @@ async def service_info():
"""
Returns information about this service, such as versions, name, etc.
"""
all_versions = ALL_VERSIONS
service_version = all_versions["bedhost_version"]
all_versions.update({"openapi_version": get_openapi_version(app)})
all_versions = {
"bedhost_version": bedhost_version,
"bbconf_version": bbconf_version,
"geniml_version": geniml_version,
"python_version": python_version(),
"openapi_version": get_openapi_version(app),
}

return ServiceInfoResponse(
id="org.bedbase.api",
name="BEDbase API",
type={
"group": "org.databio",
"artifact": "bedbase",
"version": service_version,
"version": bedhost_version,
},
description="An API providing genomic interval data and metadata",
organization={"name": "Databio Lab", "url": "https://databio.org"},
contactUrl="https://github.com/databio/bedbase/issues",
documentationUrl="https://bedbase.org",
documentationUrl="https://docs.bedbase.org",
updatedAt="2023-10-25T00:00:00Z",
environment="dev",
version=service_version,
environment="main",
version=bedhost_version,
component_versions=all_versions,
embedding_models={
"vec2vec": bbagent.config.config.path.vec2vec,
"region2vec": bbagent.config.config.path.region2vec,
"text2vec": bbagent.config.config.path.text2vec,
},
)
4 changes: 2 additions & 2 deletions requirements/requirements-all.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# bbconf @ git+https://github.com/databio/bbconf.git@dev#egg=bbconf
bbconf>=0.5.0
bbconf>=0.5.1
fastapi>=0.103.0
logmuse>=0.2.7
markdown
requests
setuptools
uvicorn
yacman>=0.9.2
pephubclient>=0.4.0
pephubclient>=0.4.1
psycopg[binary,pool]
python-multipart>=0.0.9

0 comments on commit 6d34a4b

Please sign in to comment.