Skip to content

Commit

Permalink
Add Python Lambda
Browse files Browse the repository at this point in the history
Fixes #1583.
  • Loading branch information
lpsinger committed Oct 30, 2023
1 parent 88db36e commit d235df5
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 5 deletions.
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,11 @@ 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

1 change: 1 addition & 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 Down
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',
}
4 changes: 2 additions & 2 deletions package-lock.json

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

5 changes: 4 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,9 @@
"ts-jest": "^29.1.0",
"typescript": "^5.2.2"
},
"overrides": {
"@architect/hydrate": "github:lpsinger/hydrate#hydrate-per-function-config"
},
"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
13 changes: 13 additions & 0 deletions python/lambda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright © 2023 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.


def handler(event, context):
return {
"statusCode": 200,
"headers": {
"content-type": "text/plain",
},
"body": "Hello, world",
}
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
astropy
black

0 comments on commit d235df5

Please sign in to comment.