Skip to content

Commit

Permalink
Setup CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
Zach Price committed Apr 2, 2024
1 parent d470e39 commit 4cf5f56
Show file tree
Hide file tree
Showing 35 changed files with 2,702 additions and 692 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.venv
__pycache__
17 changes: 17 additions & 0 deletions Dockerfile
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"]
4 changes: 2 additions & 2 deletions README.md
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
```
44 changes: 44 additions & 0 deletions esg_fastapi/__init__.py
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 added esg_fastapi/api/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions esg_fastapi/api/versions/__init__.py
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__))
1 change: 1 addition & 0 deletions esg_fastapi/api/versions/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .routes import app
Loading

0 comments on commit 4cf5f56

Please sign in to comment.