-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Zach Price
committed
Apr 2, 2024
1 parent
d470e39
commit 4cf5f56
Showing
35 changed files
with
2,702 additions
and
692 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.venv | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM python:3 | ||
|
||
ARG PIP_EXTRA_INDEX_URL | ||
ARG ESG_FASTAPI_VERSION | ||
|
||
WORKDIR /app | ||
|
||
RUN export PIP_EXTRA_INDEX_URL="$PIP_EXTRA_INDEX_URL" && \ | ||
export ESGFHUB_VERSION="$ESG_FASTAPI_VERSION" && \ | ||
pip install \ | ||
esg_fastapi==$ESG_FASTAPI_VERSION \ | ||
--no-cache-dir \ | ||
--report - | ||
|
||
ENV UVICORN_HOST=0.0.0.0 | ||
ENV UVICORN_PORT=8080 | ||
CMD ["uvicorn", "esg_fastapi:api"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# esg_fastapi | ||
|
||
```bash | ||
pip install -r requirements | ||
poetry install | ||
``` | ||
|
||
```bash | ||
uvicorn main:app --reload | ||
uvicorn esg_fastapi.api --reload | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
A REST API for Globus-based searches that mimics esg-search. | ||
This API is so that community tools that are based on the esg-search | ||
RESTful API need not change to be compatible with the new Globus indices. | ||
If you are designing a new project, you should look to use the globus-sdk | ||
directly and this is only a small wrapper around the `post_search` | ||
functionality. The standalone script does not need installed. You will | ||
need FastAPI on which it is based and the Globus sdk. | ||
python -m pip install fastapi[all] globus_sdk | ||
This will also install Uvicorn (an ASGI web server implementation for Python). | ||
This allows you to test this locally with: | ||
uvicorn concept:app --reload | ||
Questions: | ||
- format: do we need to be able to return the two formats? | ||
- distrib: how should this behave? | ||
- latest: does not work with CMIP3 | ||
""" | ||
|
||
from fastapi import FastAPI | ||
from starlette.routing import Mount | ||
|
||
from .api import versions | ||
from .observability import app as observability_app | ||
|
||
__all__ = ["api"] | ||
|
||
api = FastAPI( | ||
title="ESGF FastAPI", | ||
summary="An adapter service to translate and execute ESGSearch queries on a Globus Search Index.", | ||
description="# Long form CommonMark content\n---\nTODO: source this from the same place as the python package description?", | ||
) | ||
api.mount("/observability", observability_app) | ||
|
||
for version in versions.discovered: | ||
api.mount("/" + version.app.version, version.app) | ||
|
||
for route in api.routes: | ||
if isinstance(route, Mount): | ||
api.router.include_router(route.app.router) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import pkgutil | ||
from importlib import import_module | ||
|
||
discovered = [] | ||
for submodule in pkgutil.iter_modules(__path__): | ||
if submodule.name.lstrip("v").isdigit(): | ||
discovered.append(import_module("." + submodule.name, __package__)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .routes import app |
Oops, something went wrong.