Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python Lambda #1599

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: '18'
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: NPM Install
run: npm ci
- name: Pip Install
run: pip install -r requirements.txt
- name: Build
run: npm run build
- name: Configure aws credentials
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Node.js CI
name: Pull Request
on:
push:
branches:
Expand All @@ -7,5 +7,10 @@ on:
branches:
- main
jobs:
build:
node:
uses: nasa-gcn/.github/.github/workflows/node.yml@main
python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
vendor

# Generated by `npm run dev`, `npm run build`, etc.
/.cache
Expand All @@ -21,5 +22,8 @@ sam.yaml
# Generated by Mac
.DS_Store

# Generated by Python
__pycache__

.env
.eslintcache
5 changes: 5 additions & 0 deletions app.arc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ remix-gcn
method any
src build/server

/labs/api/*
method any
src python

@email-incoming
circulars
src build/email-incoming/circulars
Expand Down Expand Up @@ -111,6 +115,7 @@ region us-east-1
architecture arm64
memory 256
timeout 30
hydrate false

@search
instanceType t3.small.search
Expand Down
1 change: 1 addition & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ export default {
if (!files) return []
return `prettier --write ${filteredFiles}`
},
'*.py': 'black',
}
119 changes: 70 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dev:esbuild": "node esbuild.js --dev",
"dev": "run-p \"dev:*\"",
"prepare": "husky install",
"deploy": "arc deploy --no-hydrate --prune --production",
"deploy": "arc deploy --prune --production",
"clean": "rimraf --glob build/static app/css \"build/**/index.*\" \"build/**/metafile.*\" \"build/**/version.txt\" \"app/**/*.css\" \"app/**/*.css.map\" sam.json sam.yaml .cache",
"test": "jest",
"test-coverage": "jest --coverage",
Expand Down Expand Up @@ -135,6 +135,10 @@
"ts-jest": "^29.1.0",
"typescript": "^5.2.2"
},
"overrides": {
"@architect/hydrate": "github:lpsinger/hydrate#hydrate-per-function-config",
"@architect/sandbox": "github:lpsinger/sandbox#x-forwarded-port-string"
},
"engines": {
"node": ">=18"
},
Expand Down
7 changes: 7 additions & 0 deletions python/config.arc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@aws
runtime python3.11
memory 2048
timeout 30

@arc
hydrate true
17 changes: 17 additions & 0 deletions python/lambda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright © 2023 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.


from fastapi import FastAPI
from mangum import Mangum

app = FastAPI()


@app.get("/")
async def example():
return {"greeting": "Hello, world!"}


handler = Mangum(app, api_gateway_base_path="/labs/api", lifespan="off")
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
astropy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this being used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't yet, but it will be.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you prefer that I remove this?

black
fastapi
mangum