-
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
Showing
13 changed files
with
463 additions
and
17 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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
.idea | ||
__pycache__ | ||
.serverless | ||
node_modules/ |
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,15 @@ | ||
RUN = poetry run | ||
|
||
# serverless/lambda seems to require this be at root level | ||
#APP_PATH = ontology_term_usage.app.main | ||
APP_PATH = main | ||
|
||
test: | ||
$(RUN) pytest -s | ||
|
||
app: | ||
$(RUN) uvicorn $(APP_PATH):app --reload | ||
|
||
# https://adem.sh/blog/tutorial-fastapi-aws-lambda-serverless | ||
deploy: | ||
sls deploy --stage staging |
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
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,34 @@ | ||
# TODO: figure out how to put this in the app/ folder and still use serverless | ||
# This line: `handler: main.handler` | ||
# How do we specify a path here, as per uvicorn? | ||
|
||
import os | ||
from enum import Enum | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel | ||
from fastapi import FastAPI, Query | ||
|
||
# for lambda; see https://adem.sh/blog/tutorial-fastapi-aws-lambda-serverless | ||
from mangum import Mangum | ||
|
||
|
||
from ontology_term_usage.term_usage import OntologyClient, ResultSet, TermUsage, TERM | ||
|
||
stage = os.environ.get('STAGE', None) | ||
openapi_prefix = f"/{stage}" if stage else "/" | ||
|
||
client = OntologyClient() | ||
|
||
app = FastAPI(title='Ontology Usage API', openapi_prefix=openapi_prefix) | ||
|
||
@app.get("/") | ||
async def root(): | ||
return {"message": "Hello World"} | ||
|
||
@app.get("/usage/{term}", response_model=ResultSet) | ||
async def usage(term: TERM) -> ResultSet: | ||
rs = client.term_usage(term) | ||
return rs | ||
|
||
handler = Mangum(app) |
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,3 +1,3 @@ | ||
__version__ = '0.1.0' | ||
|
||
from ontology_term_usage import * | ||
from ontology_term_usage.term_usage import OntologyClient, ResultSet, TermUsage |
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,30 @@ | ||
import os | ||
from enum import Enum | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel | ||
from fastapi import FastAPI, Query | ||
|
||
# for lambda; see https://adem.sh/blog/tutorial-fastapi-aws-lambda-serverless | ||
from mangum import Mangum | ||
|
||
|
||
from ontology_term_usage.term_usage import OntologyClient, ResultSet, TermUsage, TERM | ||
|
||
stage = os.environ.get('STAGE', None) | ||
openapi_prefix = f"/{stage}" if stage else "/" | ||
|
||
client = OntologyClient() | ||
|
||
app = FastAPI(title='Ontology Usage API', openapi_prefix=openapi_prefix) | ||
|
||
@app.get("/") | ||
async def root(): | ||
return {"message": "Hello World"} | ||
|
||
@app.get("/usage/{term}", response_model=ResultSet) | ||
async def usage(term: TERM) -> ResultSet: | ||
rs = client.term_usage(term) | ||
return rs | ||
|
||
handler = Mangum(app) |
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
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,8 @@ | ||
{ | ||
"name": "ontology-term-usage", | ||
"version": "1.0.0", | ||
"author": "Chris Mungall", | ||
"dependencies": { | ||
"serverless-python-requirements": "^5.0.1" | ||
} | ||
} |
Oops, something went wrong.