PhotoOpsAI central application platform
.
├── LICENSE
├── Makefile
├── Pipfile
├── README.md
├── events
├── pytest.ini
├── src
│ ├── common
│ │ ├── common
│ │ │ └── __init__.py
│ │ └── setup.py
│ └── handlers
├── template.yaml
└── tests
├── conftest.py
├── integration
│ ├── __init__.py
│ └── src
│ ├── __init__.py
│ └── handlers
│ └── __init__.py
└── unit
├── __init__.py
└── src
├── __init__.py
└── handlers
└── __init__.py
- https://www.media.mit.edu/pia/Research/deepview/exif.html
- http://lclevy.free.fr/nef/index.html
- https://exiftool.org/TagNames/EXIF.html
- https://exiftool.org/TagNames/Nikon.html
- https://www.exiv2.org/tags-nikon.html
- https://github.com/LibRaw/LibRaw/blob/master/src/metadata/nikon.cpp
- http://exif.regex.info/exif.cgi
- AWS CLI with Administrator permission
- Python 3 installed
- Pipenv installed
pip install pipenv
- Docker installed
- SAM CLI installed
- Obtain or write sample data.
- Use Python
genson
to generate a schema. Adjust as necessary. - Use
json2models -s nested --datetime --max-strings-literals 0 -f dataclasses -m ClassName <json_file>
to generate dataclass. - Add test to
tests/unit/data
to ensure data, schema, and dataclass.
Invoking function locally using a local sample payload
sam local invoke <FUNCTION_NAME> --event events/<FUNCTION_NAME>-<EVENT_SOURCE>.json
Invoking function locally through local API Gateway
sam local start-api
If the previous command ran successfully you should now be able to hit the following local endpoint to invoke your function http://localhost:3000/hello
SAM CLI is used to emulate both Lambda and API Gateway locally and uses our template.yaml
to understand how to bootstrap this environment (runtime, where the source code is, etc.) - The following excerpt is what the CLI will read in order to initialize an API and its routes:
...
Events:
HelloWorld:
Type: Api
Properties:
Path: /hello
Method: get
To package and deploy this service run the command below.
$ make deploy
This will:
- Create an artifact deployment S3 bucket
- Bundle application dependencies
- Package the code and dependencies
- Upload code to S3.
- Deploy code via Cloudformation
To simplify troubleshooting, SAM CLI has a command called sam logs. sam logs lets you fetch logs generated by your Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug.
NOTE
: This command works for all AWS Lambda functions; not just the ones you deploy using SAM.
sam logs -n <FUNCTION_NAME> --stack-name PhotoOps --tail
You can find more information and examples about filtering Lambda function logs in the SAM CLI Documentation.
Next, we install test dependencies and we run pytest
against our tests
folder to run our initial unit tests:
pip install pytest pytest-mock --user
python -m pytest tests/ -v
In order to delete our Serverless Application recently deployed you can use the following AWS CLI Command:
aws cloudformation delete-stack --stack-name PhotoOps