diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100644
index 0000000..bcb053d
--- /dev/null
+++ b/.eslintrc.js
@@ -0,0 +1,23 @@
+module.exports = {
+ env: {
+ browser: true,
+ es2021: true,
+ },
+ extends: "google",
+ overrides: [
+ {
+ env: {
+ node: true,
+ },
+ files: [".eslintrc.{js,cjs}"],
+ parserOptions: {
+ sourceType: "script",
+ },
+ },
+ ],
+ parserOptions: {
+ ecmaVersion: "latest",
+ sourceType: "module",
+ },
+ rules: {},
+};
diff --git a/.flake8 b/.flake8
new file mode 100644
index 0000000..7bf302c
--- /dev/null
+++ b/.flake8
@@ -0,0 +1,5 @@
+[flake8]
+ignore = E203, E266, E501, W503, F403, F401
+max-line-length = 120
+max-complexity = 18
+select = B,C,E,F,W,T4,B9
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
new file mode 100644
index 0000000..676646f
--- /dev/null
+++ b/.github/CONTRIBUTING.md
@@ -0,0 +1,3 @@
+# Contributing
+
+The repository is released under the GNU AFFERO GENERAL PUBLIC LICENSE license, and follows a standard Github development process, using Github tracker for issues and merging pull requests into master.
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..fe662b4
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,4 @@
+# These are supported funding model platforms
+
+github: FullStackWithLawrence
+patreon: FullStackWithLawrence
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 0000000..72e44eb
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,16 @@
+---
+name: Bug report
+about: Create a report to help us improve
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**Workflow**
+If applicable, provide a workflow file to help explain your problem.
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Additional context**
+Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 0000000..3ba13e0
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1 @@
+blank_issues_enabled: false
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 0000000..a09db44
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,16 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000..80c4aed
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,19 @@
+### Type of Change
+
+
+
+- [ ] New feature
+- [ ] Bug fix
+- [ ] Documentation
+- [ ] Refactor
+- [ ] Chore
+
+### Resolves
+
+- Fixes #[Add issue number here.]
+
+### Describe Changes
+
+
+
+_Describe what this Pull Request does_
diff --git a/.github/actions/merge-branch/action.yml b/.github/actions/merge-branch/action.yml
new file mode 100644
index 0000000..896656a
--- /dev/null
+++ b/.github/actions/merge-branch/action.yml
@@ -0,0 +1,59 @@
+---
+#------------------------------------------------------------------------------
+# Run pre-commit
+#------------------------------------------------------------------------------
+name: Merge
+branding:
+ icon: "git-pull-request"
+ color: "orange"
+inputs:
+ github-token:
+ description: "The GitHub token to use for authentication"
+ required: true
+ type: string
+ source-branch:
+ description: "The branch to merge from"
+ required: false
+ type: string
+ default: "main"
+ target-branch:
+ description: "The branch to merge to"
+ required: true
+ type: string
+
+ python-version:
+ description: "The version of Python to use, such as 3.11.0"
+ required: true
+ type: string
+
+runs:
+ using: "composite"
+ steps:
+ - name: Checkout code
+ id: checkout
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ persist-credentials: false
+
+ - name: Remember current branch
+ shell: bash
+ run: |
+ echo "CURRENT_BRANCH=$(git branch --show-current)" >> $GITHUB_ENV
+
+ - name: Merge
+ id: merge
+ shell: bash
+ run: |
+ git config --local user.email "action@github.com"
+ git config --local user.name "GitHub Action"
+ git checkout ${{ inputs.source-branch }}
+ git pull
+ git checkout ${{ inputs.target-branch }}
+ git merge -Xtheirs ${{ inputs.source-branch }}
+ git push https://${{ inputs.github-token }}@github.com/${{ github.repository }}.git HEAD:${{ inputs.target-branch }}
+
+ - name: Checkout current branch
+ shell: bash
+ run: |
+ git checkout ${{ env.CURRENT_BRANCH }}
diff --git a/.github/actions/tests/python/action.yml b/.github/actions/tests/python/action.yml
new file mode 100644
index 0000000..0ddad4c
--- /dev/null
+++ b/.github/actions/tests/python/action.yml
@@ -0,0 +1,65 @@
+---
+#------------------------------------------------------------------------------
+# Run Python unit tests
+#------------------------------------------------------------------------------
+name: Test Python
+branding:
+ icon: "git-pull-request"
+ color: "orange"
+inputs:
+ python-version:
+ description: "The version of Python to use, such as 3.11.0"
+ required: true
+ type: string
+
+env:
+ REQUIREMENTS_PATH: "requirements.txt"
+
+runs:
+ using: "composite"
+ steps:
+ - name: Checkout code
+ id: checkout
+ uses: actions/checkout@v4
+
+ - name: Cache Python dependencies
+ uses: actions/cache@v3
+ with:
+ path: ~/.cache/pip
+ key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
+ restore-keys: |
+ ${{ runner.os }}-pip
+
+ - name: Set up Python
+ uses: actions/setup-python@v4
+ with:
+ python-version: ${{ inputs.python-version }}
+
+ - name: locate site-packages path
+ shell: bash
+ run: |
+ echo "SITE_PACKAGES_PATH=$(python -c 'import site; print(site.getsitepackages()[0])')" >> $GITHUB_ENV
+
+ - name: Install pip
+ shell: bash
+ run: |
+ python -m pip install --upgrade pip
+
+ - name: Install dependencies
+ shell: bash
+ run: |
+ pip install -r ./requirements.txt
+ env:
+ SITE_PACKAGES_PATH: ${{ env.SITE_PACKAGES_PATH }}
+
+ - name: Create .env
+ shell: bash
+ run: |
+ touch ./.env
+ env:
+
+ - name: Run Tests
+ shell: bash
+ run: |
+ cd models && pytest -v -s tests/
+ python -m setup_test
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index dd8dd9f..9596b44 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -1,7 +1,41 @@
version: 2
updates:
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "weekly"
+ assignees:
+ - "lpm0073"
+ reviewers:
+ - "lpm0073"
- package-ecosystem: terraform
directory: "/terraform"
schedule:
- interval: daily
+ interval: weekly
open-pull-requests-limit: 10
+ assignees:
+ - "lpm0073"
+ reviewers:
+ - "lpm0073"
+ - package-ecosystem: "npm"
+ directory: "/"
+ schedule:
+ interval: "weekly"
+ labels:
+ - "dependencies"
+ - "javascript"
+ assignees:
+ - "FullStackWithLawrence"
+ reviewers:
+ - "FullStackWithLawrence"
+ - package-ecosystem: "pip"
+ directory: "/"
+ schedule:
+ interval: "weekly"
+ labels:
+ - "dependencies"
+ - "python"
+ assignees:
+ - "lpm0073"
+ reviewers:
+ - "lpm0073"
diff --git a/.github/workflows/auto-assign.yml b/.github/workflows/auto-assign.yml
new file mode 100644
index 0000000..9f5b78b
--- /dev/null
+++ b/.github/workflows/auto-assign.yml
@@ -0,0 +1,19 @@
+name: Auto Assign
+on:
+ issues:
+ types: [opened]
+ pull_request:
+ types: [opened]
+jobs:
+ run:
+ runs-on: ubuntu-latest
+ permissions:
+ issues: write
+ pull-requests: write
+ steps:
+ - name: "Auto-assign issue"
+ uses: pozil/auto-assign-issue@v1
+ with:
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
+ assignees: lpm0073
+ numOfAssignee: 1
diff --git a/.github/workflows/precommitVersionBumps.yml b/.github/workflows/precommitVersionBumps.yml
new file mode 100644
index 0000000..492d669
--- /dev/null
+++ b/.github/workflows/precommitVersionBumps.yml
@@ -0,0 +1,102 @@
+---
+#------------------------------------------------------------------------------
+# Lawrence McDaniel - https://lawrencemcdaniel.com
+# Version Bump Workflow for .pre-commit-config.yaml
+#
+# This workflow runs on a cron schedule and checks for updates to the
+# .pre-commit-config.yaml file. If updates are found, the workflow
+# commits the changes to the next branch and pushes the changes to GitHub.
+#
+# This is a workaround for the fact that the pre-commit autoupdate command
+# is not supported by Dependabot.
+#------------------------------------------------------------------------------
+name: pre-commit Version Bumps
+
+on:
+ schedule:
+ - cron: "0 0 * * 3"
+ workflow_dispatch:
+
+jobs:
+ evaluate_precommit_config:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ persist-credentials: false
+
+ - name: Checkout next branch
+ run: |
+ git fetch
+ git checkout next
+ git pull origin next
+
+ - name: Cache NPM dependencies
+ uses: actions/cache@v3
+ with:
+ path: ~/.npm
+ key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
+ restore-keys: |
+ ${{ runner.os }}-node
+
+ - name: Cache Python dependencies
+ uses: actions/cache@v3
+ with:
+ path: ~/.cache/pip
+ key: ${{ runner.os }}-pip-${{ hashFiles('**requirements.txt') }}
+ restore-keys: |
+ ${{ runner.os }}-pip
+
+ - name: Set up Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: "3.11"
+
+ - name: locate site-packages path
+ shell: bash
+ run: |
+ echo "SITE_PACKAGES_PATH=$(python -c 'import site; print(site.getsitepackages()[0])')" >> $GITHUB_ENV
+
+ - name: Install pip
+ shell: bash
+ run: |
+ python -m pip install --upgrade pip
+
+ - name: Install dependencies
+ shell: bash
+ run: |
+ pip install -r ./requirements.txt
+ env:
+ SITE_PACKAGES_PATH: ${{ env.SITE_PACKAGES_PATH }}
+
+ - name: Setup Node.js environment
+ uses: actions/setup-node@v4
+ with:
+ node-version: "20.9.0"
+
+ - name: Install npm dev dependencies
+ run: npm install
+
+ - name: Update .pre-commit-config.yaml
+ run: |
+ pre-commit autoupdate
+
+ - name: Check for unstaged changes
+ id: check_changes
+ run: |
+ if [[ -n "$(git status --porcelain .pre-commit-config.yaml)" ]]; then
+ echo "::set-output name=changes::true"
+ else
+ echo "::set-output name=changes::false"
+ fi
+
+ - name: Commit and push changes
+ if: steps.check_changes.outputs.changes == 'true'
+ shell: bash
+ run: |
+ git config --local user.email "action@github.com"
+ git config --local user.name "GitHub Action"
+ git add .pre-commit-config.yaml
+ git commit -m "chore: [gh] version bumps in .pre-commit-config.yaml [skip ci]"
+ git push https://${{ secrets.PAT }}@github.com/${{ github.repository }}.git HEAD:next
diff --git a/.github/workflows/pullRequestController.yml b/.github/workflows/pullRequestController.yml
new file mode 100644
index 0000000..6d9df6f
--- /dev/null
+++ b/.github/workflows/pullRequestController.yml
@@ -0,0 +1,116 @@
+---
+#------------------------------------------------------------------------------
+# Pull Request Workflow Controller.
+#
+# Triggers:
+# - Called automatically on relevant actions performed on pull requests.
+# - Can also be run manually by clicking the "Run workflow" button.
+#
+# Actions:
+# - Use semantic release rules to determine if a new release will be published.
+# - run Python tests, but only if Python-related files have changed.
+# - run Terraform tests, but only if Terraform-related files have changed.
+# - run ReactJS tests, but only if ReactJS-related files have changed.
+# - run pre-commit hooks to ensure code is formatted correctly.
+#
+# To-Do:
+# If a new release is to be published then we want to consider running QA tests
+# to ensure formatting and documentation is correct.
+#------------------------------------------------------------------------------
+name: Pull Request Controller
+
+on:
+ workflow_dispatch:
+ # GitHub Copilot: The `pull_request` and `pull_request_target` are two different
+ # event types in GitHub Actions that trigger workflows when activity related
+ # to pull requests occurs.
+ # - `pull_request`: This event triggers a workflow run whenever a pull
+ # request is opened, synchronized, or closed. The workflow runs in the context of the
+ # pull request, meaning it has access to the code and environment variables of the head
+ # branch of the pull request. This is safe for pull requests within the same repository,
+ # but for pull requests from a fork, this could potentially expose sensitive information.
+ #
+ # - `pull_request_target`: This event is similar to `pull_request`, but it runs in the context
+ # of the base of the pull request, rather than the head. This means it has access to the code
+ # and environment variables of the base branch, not the head branch. This is safer for
+ # pull requests from forks, as it prevents the fork from accessing sensitive information
+ # in the base repository. However, it means the workflow does not have access to the code
+ # in the pull request by default. If you need to access the code in the pull request,
+ # you can use the `actions/checkout` action with the `ref` input
+ # set to `github.event.pull_request.head.ref`.
+ #
+ # In general, use `pull_request` for workflows that need to access the code in the pull request,
+ # and `pull_request_target` for workflows that need to be safe for pull requests from forks.
+ pull_request_target:
+ types: [opened, synchronize]
+ paths:
+ - "**.py"
+ - "**.requirements.txt"
+ - "**.package.json"
+ - "./terraform/python/**"
+
+env:
+ python-version: "3.11"
+
+jobs:
+ check_for_pending_release:
+ name: test-semantic-release
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Semantic Release
+ uses: cycjimmy/semantic-release-action@v4
+ id: semantic
+ with:
+ dry_run: true
+ branches: |
+ [
+ '+([0-9])?(.{+([0-9]),x}).x',
+ 'main',
+ 'next',
+ 'next-major',
+ {
+ name: 'beta',
+ prerelease: true
+ },
+ {
+ name: 'alpha',
+ prerelease: true
+ }
+ ]
+ extra_plugins: |
+ @semantic-release/git
+ @semantic-release/changelog
+ env:
+ GITHUB_TOKEN: ${{ secrets.PAT }}
+
+ - name: Test Outputs
+ if: steps.semantic.outputs.new_release_published == 'true'
+ run: |
+ echo ${{ steps.semantic.outputs.new_release_version }}
+ echo ${{ steps.semantic.outputs.new_release_major_version }}
+ echo ${{ steps.semantic.outputs.new_release_minor_version }}
+ echo ${{ steps.semantic.outputs.new_release_patch_version }}
+
+ python_tests:
+ needs: check_for_pending_release
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout code
+ id: checkout
+ uses: actions/checkout@v4
+
+ - name: Check for changed files
+ id: file_changes
+ run: |
+ echo "::set-output name=files_changed::$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep '\.py$' || true)"
+ echo "::set-output name=requirements_changed::$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep 'requirements.txt$' || true)"
+
+ - name: Run Python tests
+ if: steps.file_changes.outputs.files_changed != '' || steps.file_changes.outputs.requirements_changed != ''
+ uses: ./.github/actions/tests/python
+ with:
+ python-version: "${{ env.python-version}}"
diff --git a/.github/workflows/pushMain.yml b/.github/workflows/pushMain.yml
new file mode 100644
index 0000000..6805ed0
--- /dev/null
+++ b/.github/workflows/pushMain.yml
@@ -0,0 +1,102 @@
+---
+#---------------------------------------------------------
+# - Create a semantical release
+# - Merge main into next, alpha, beta, and next-major
+#---------------------------------------------------------
+name: Push to main
+
+on:
+ workflow_dispatch:
+ push:
+ branches:
+ - main
+jobs:
+ merge-main-to-dev-branches:
+ runs-on: ubuntu-latest
+ env:
+ GITHUB_TOKEN: ${{ secrets.PAT }}
+
+ steps:
+ - name: Checkout code
+ id: checkout
+ uses: actions/checkout@v4
+
+ - name: Merge main into next
+ uses: ./.github/actions/merge-branch
+ with:
+ github-token: ${{ env.GITHUB_TOKEN }}
+ source-branch: main
+ target-branch: next
+
+ - name: Merge main into next-major
+ uses: ./.github/actions/merge-branch
+ with:
+ github-token: ${{ env.GITHUB_TOKEN }}
+ source-branch: main
+ target-branch: next-major
+
+ - name: Merge main into alpha
+ uses: ./.github/actions/merge-branch
+ with:
+ github-token: ${{ env.GITHUB_TOKEN }}
+ source-branch: main
+ target-branch: alpha
+
+ - name: Merge main into beta
+ uses: ./.github/actions/merge-branch
+ with:
+ github-token: ${{ env.GITHUB_TOKEN }}
+ source-branch: main
+ target-branch: beta
+
+ semantic-release:
+ needs: merge-main-to-dev-branches
+ runs-on: ubuntu-latest
+ env:
+ GITHUB_TOKEN: ${{ secrets.PAT }}
+
+ steps:
+ - uses: actions/checkout@v4
+ id: checkout
+ with:
+ persist-credentials: false
+
+ - name: Semantic Release
+ uses: cycjimmy/semantic-release-action@v4
+ id: semantic
+ with:
+ branches: |
+ [
+ '+([0-9])?(.{+([0-9]),x}).x',
+ 'main',
+ 'next',
+ 'next-major',
+ {
+ name: 'beta',
+ prerelease: true
+ },
+ {
+ name: 'alpha',
+ prerelease: true
+ }
+ ]
+ extra_plugins: |
+ @semantic-release/git
+ @semantic-release/changelog
+ env:
+ GIT_COMMITTER_NAME: github-actions[bot]
+ GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
+ GIT_AUTHOR_NAME: github-actions[bot]
+ GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
+
+ - name: Publish To GitHub Package Registry
+ id: publish
+ if: steps.semantic.outputs.new_release_published == 'true'
+ run: echo "new release was published"
+ shell: bash
+
+ - name: Push updates to branch for major version
+ id: push_major
+ if: steps.semantic.outputs.new_release_published == 'true'
+ run: "git push https://x-access-token:${{ env.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git HEAD:refs/heads/v${{steps.semantic.outputs.new_release_major_version}}"
+ shell: bash
diff --git a/.github/workflows/runTests.yml b/.github/workflows/runTests.yml
new file mode 100644
index 0000000..12a9dec
--- /dev/null
+++ b/.github/workflows/runTests.yml
@@ -0,0 +1,24 @@
+---
+#------------------------------------------------------------------------------
+# Run all tests
+#------------------------------------------------------------------------------
+name: Manual Unit Tests
+
+on:
+ workflow_dispatch:
+
+env:
+ python-version: "3.11"
+
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ id: checkout
+ uses: actions/checkout@v4
+
+ - name: Run Python tests
+ uses: ./.github/actions/tests/python
+ with:
+ python-version: "${{ env.python-version}}"
diff --git a/.github/workflows/semanticVersionBump.yml b/.github/workflows/semanticVersionBump.yml
new file mode 100644
index 0000000..7e3cef7
--- /dev/null
+++ b/.github/workflows/semanticVersionBump.yml
@@ -0,0 +1,125 @@
+---
+#------------------------------------------------------------------------------
+# Lawrence McDaniel - https://lawrencemcdaniel.com
+# Version Bump Workflow for Python package openai_utils
+#
+# Calculate the version of the 'next' branch based on semantic-release rules.
+# Compares the existing value of __version__.py to the calculated value.
+# If they are different, it will update __version__.py and push the changes
+# to the main branch.
+#------------------------------------------------------------------------------
+name: Semantic Version Bump (next)
+
+on:
+ workflow_dispatch:
+ push:
+ branches:
+ - alpha
+ - beta
+ - next
+ - next-major
+
+jobs:
+ bump-version-next:
+ runs-on: ubuntu-latest
+ env:
+ VERSION_FILE: __version__.py
+ PACKAGE_PATH: ${{ github.workspace }}/terraform/python/
+
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ persist-credentials: false
+
+ - name: Cache NPM dependencies
+ uses: actions/cache@v3
+ with:
+ path: ~/.npm
+ key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
+ restore-keys: |
+ ${{ runner.os }}-node
+
+ - name: Set up Python 3.11
+ uses: actions/setup-python@v5
+ with:
+ python-version: "3.11"
+
+ - name: Setup Node.js environment
+ uses: actions/setup-node@v4
+ with:
+ node-version: "20.9.0"
+
+ - name: Install npm dev dependencies
+ run: npm install
+
+ - name: Get current version
+ # step 1
+ # the current version persisted to __version__.py
+ id: current_version
+ run: |
+ cd ${{ env.PACKAGE_PATH }}
+ echo "CURRENT_VERSION=$(python -c 'from __version__ import __version__; print(__version__)')" >> $GITHUB_ENV
+ env:
+ GITHUB_TOKEN: ${{ secrets.PAT }}
+
+ - name: null step
+ id: null_step1
+ run: echo "i ensure that CURRENT_VERSION is set."
+
+ - name: Get next version
+ # step 2
+ # calculate the next version based on semantic-release rules
+ # this will return a null string is there in fact is no version bump.
+ # so set NEXT_VERSION to CURRENT_VERSION if there is no version bump.
+ id: next_version
+ run: |
+ NEXT_VERSION=$(npx semantic-release --dry-run --no-ci | awk '/The next release version is/{print $NF}')
+ echo "NEXT_VERSION=${NEXT_VERSION:-${{ env.CURRENT_VERSION }}}" >> $GITHUB_ENV
+ env:
+ GITHUB_TOKEN: ${{ secrets.PAT }}
+ CURRENT_VERSION: ${{ env.CURRENT_VERSION }}
+
+ - name: null step
+ id: null_step2
+ run: echo "i ensure that NEXT_VERSION is set."
+
+ - name: Check versions
+ # step 3
+ # compare the current version to the next version.
+ # if they are different, set VERSION_CHANGED to true
+ id: check_versions
+ run: |
+ if [ "$CURRENT_VERSION" != "$NEXT_VERSION" ]; then
+ echo "VERSION_CHANGED=true" >> $GITHUB_ENV
+ else
+ echo "VERSION_CHANGED=false" >> $GITHUB_ENV
+ fi
+ env:
+ CURRENT_VERSION: ${{ env.CURRENT_VERSION }}
+ NEXT_VERSION: ${{ env.NEXT_VERSION }}
+
+ - name: another null step
+ id: null_step3
+ run: echo "i ensure that CURRENT_VERSION, NEXT_VERSION and VERSION_CHANGED are set."
+
+ - name: Update __version__.py
+ # step 4
+ # if VERSION_CHANGED is true, update __version__.py and push the changes to the
+ # branch that triggered this workflow.
+ if: env.VERSION_CHANGED == 'true'
+ id: update_version
+ run: |
+ echo "# -*- coding: utf-8 -*-" > ${{ env.VERSION_FILE }}
+ echo "# DO NOT EDIT." > ${{ env.VERSION_FILE }}
+ echo "# Managed via automated CI/CD in .github/workflows/semanticVersionBump.yml." > ${{ env.VERSION_FILE }}
+ echo "__version__ = \"${{ env.NEXT_VERSION }}\"" >> ${{ env.VERSION_FILE }}
+ git config --local user.email "action@github.com"
+ git config --local user.name "GitHub Action"
+ git add ${{ env.VERSION_FILE }}
+ git commit -m "chore: [gh] Update __version__.py to ${{ env.NEXT_VERSION }} [skip ci]"
+ git push https://${{ secrets.PAT }}@github.com/${{ github.repository }}.git HEAD:${{ github.ref }}
+ env:
+ VERSION_FILE: ${{ env.PACKAGE_PATH }}${{ env.VERSION_FILE }}
+ GITHUB_TOKEN: ${{ secrets.PAT }}
+ NEXT_VERSION: ${{ env.NEXT_VERSION }}
+ VERSION_CHANGED: ${{ env.VERSION_CHANGED }}
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644
index 0000000..987e4b1
--- /dev/null
+++ b/.github/workflows/tests.yml
@@ -0,0 +1,28 @@
+name: Unit Tests
+
+on:
+ pull_request:
+ push:
+
+jobs:
+ tests:
+ name: tests
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Set up Python 3.x
+ uses: actions/setup-python@v5
+ with:
+ python-version: "3.11"
+
+ - name: Install requirements
+ run: |
+ python -m pip install --upgrade pip
+ pip install -r ./requirements.txt
+
+ - name: terraform/python Unit tests
+ run: |
+ export PYTHONPATH=$PYTHONPATH:$(pwd)
+ python -m unittest discover -s terraform/python/tests/
diff --git a/.gitignore b/.gitignore
index 038c671..cf752f8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,35 @@
+# Build artifacts
+build/
+dist/
+*.egg-info/
+*.egg
+*.zip
+
+# Jupyter Notebook
+.ipynb_checkpoints
+data
+
.DS_Store
# Local .terraform directories
.terraform/
+.env
+lambda_dist_pkg
+*.zip
+__pycache__
+.pytest_cache
+
+# Python
+venv
+.venv
+.pytest_cache
+*.pyc
+*.pyo
+*.pyd
+*.swp
+*.log
# .tfstate files
+.terraform.lock.hcl
*.tfstate
*.tfstate.*
@@ -16,3 +43,9 @@ tardigrade-ci/
# go tests
tests/go.*
+
+# ReactJS
+client/node_modules/
+node_modules
+
+package-lock.json
diff --git a/.mergify.yml b/.mergify.yml
index 3bfe530..4660967 100644
--- a/.mergify.yml
+++ b/.mergify.yml
@@ -1,17 +1,17 @@
pull_request_rules:
- name: automatic approve dependabot pull requests
conditions:
- - 'author~=dependabot[bot]|dependabot-preview[bot]|dependabot'
- - 'status-success=Travis CI - Branch'
- - 'status-success=Travis CI - Pull Request'
+ - "author~=dependabot[bot]|dependabot-preview[bot]|dependabot"
+ - "status-success=Travis CI - Branch"
+ - "status-success=Travis CI - Pull Request"
actions:
review:
type: APPROVE
- name: automatic merge dependabot pull requests
conditions:
- - 'author~=dependabot[bot]|dependabot-preview[bot]|dependabot'
- - '#approved-reviews-by>=1'
+ - "author~=dependabot[bot]|dependabot-preview[bot]|dependabot"
+ - "#approved-reviews-by>=1"
actions:
merge:
method: merge
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index ec78bc1..ecc54e8 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -2,36 +2,77 @@ default_language_version:
# default language version for each language
python: python3.11
repos:
+ - repo: https://github.com/pre-commit/mirrors-prettier
+ rev: v4.0.0-alpha.4
+ hooks:
+ - id: prettier
+ - repo: https://github.com/codespell-project/codespell
+ rev: v2.2.6
+ hooks:
+ - id: codespell
+ args: ["--ignore-words=codespell.txt"]
+ exclude: 'codespell.txt|\.svg$'
- repo: https://github.com/psf/black
- rev: 23.7.0
+ rev: 23.12.0
+ hooks:
+ - id: black
+ - repo: https://github.com/PyCQA/flake8
+ rev: 6.1.0
+ hooks:
+ - id: flake8
+ - repo: https://github.com/PyCQA/isort
+ rev: 5.13.1
+ hooks:
+ - id: isort
+ args: ["--settings-path=pyproject.toml"]
+ - repo: local
+ hooks:
+ - id: pylint
+ name: pylint
+ entry: ./run_pylint.sh
+ language: script
+ types: [python]
+ - repo: https://github.com/PyCQA/bandit
+ rev: 1.7.6
hooks:
- - id: black
+ - id: bandit
+ args: ["-ll"]
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v4.4.0
+ rev: v4.5.0
hooks:
# See https://pre-commit.com/hooks.html for more hooks
- - id: check-added-large-files
- - id: check-byte-order-marker
+ #- id: check-added-large-files
+ - id: fix-byte-order-marker
+ - id: fix-encoding-pragma
- id: check-case-conflict
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-xml
+ - id: check-yaml
- id: destroyed-symlinks
- id: detect-aws-credentials
- id: detect-private-key
- id: end-of-file-fixer
- id: forbid-new-submodules
- id: trailing-whitespace
- - id: check-yaml
- - repo: https://github.com/gruntwork-io/pre-commit
- rev: v0.1.22 # Get the latest from: https://github.com/gruntwork-io/pre-commit/releases
- hooks:
- - id: terraform-fmt
- - id: helmlint
- - id: terraform-validate
- - id: tflint
- # - id: shellcheck
- # - id: yapf
- # - id: markdown-link-check
+ - id: check-case-conflict
+ - id: check-merge-conflict
+ - id: debug-statements
+ - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
+ rev: v9.10.0
+ hooks:
+ - id: commitlint
+ stages: [commit-msg]
+ additional_dependencies: ["@commitlint/config-angular"]
+ci:
+ # for more information, see https://pre-commit.ci
+ autofix_commit_msg: |
+ [pre-commit.ci] auto fixes from pre-commit.com hooks
+ autofix_prs: true
+ autoupdate_branch: ""
+ autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate"
+ autoupdate_schedule: weekly
+ skip: [shellcheck, markdown-link-check, commitlint]
+ submodules: false
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 0000000..e69de29
diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 0000000..75fa134
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1,3 @@
+{
+ "tabWidth": 2
+}
diff --git a/.pylintrc b/.pylintrc
new file mode 100644
index 0000000..347c270
--- /dev/null
+++ b/.pylintrc
@@ -0,0 +1,11 @@
+[MASTER]
+init-hook='import sys; print(sys.executable); print(sys.path)'
+ignore-paths =
+ignore =
+ __version__.py
+
+[FORMAT]
+max-line-length=120
+
+[MESSAGES CONTROL]
+disable=too-few-public-methods,invalid-name,line-too-long
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8ce3c1d..50b0ef8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,4 +12,4 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
**Summary**:
-* Initial release!
+- Initial release!
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..6519c09
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,58 @@
+# Code of Conduct
+
+## 1. Purpose
+
+A primary goal of aws-rekogition is to be inclusive to the largest number of contributors, with the most varied and diverse backgrounds possible. As such, we are committed to providing a friendly, safe and welcoming environment for all, regardless of gender, sexual orientation, ability, ethnicity, socioeconomic status, and religion (or lack thereof).
+
+This code of conduct outlines our expectations for all those who participate in our community, as well as the consequences for unacceptable behavior.
+
+We invite all those who participate in aws-rekogition to help us create safe and positive experiences for everyone.
+
+## 2. Open Source Citizenship
+
+A supplemental goal of this Code of Conduct is to increase open source citizenship by encouraging participants to recognize and strengthen the relationships between our actions and their effects on our community.
+
+Communities mirror the societies in which they exist and positive action is essential to counteract the many forms of inequality and abuses of power that exist in society.
+
+## 3. Expected Behavior
+
+The following behaviors are expected and requested of all community members:
+
+- Participate in an authentic and active way. In doing so, you contribute to the health and longevity of this community.
+- Exercise consideration and respect in your speech and actions.
+- Attempt collaboration before conflict.
+- Refrain from demeaning, discriminatory, or harassing behavior and speech.
+- Be mindful of your surroundings and of your fellow participants. Alert community leaders if you notice a dangerous situation, someone in distress, or violations of this Code of Conduct, even if they seem inconsequential.
+
+## 4. Unacceptable Behavior
+
+The following behaviors are considered harassment and are unacceptable within our community:
+
+- Violence, threats of violence or violent language directed against another person.
+- Sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory jokes and language.
+- Posting or displaying sexually explicit or violent material.
+- Posting or threatening to post other people’s personally identifying information ("doxing").
+- Personal insults, particularly those related to gender, sexual orientation, race, religion, or disability.
+- Inappropriate photography or recording.
+- Inappropriate physical contact. You should have someone’s consent before touching them.
+- Unwelcome sexual attention. This includes, sexualized comments or jokes; inappropriate touching, groping, and unwelcomed sexual advances.
+
+## 5. Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [lpm0073@gmail.com](mailto:lpm0073@gmail.com). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
+
+## 6. Scope
+
+This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
+
+## 7. Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), version 1.4, available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct.html](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html).
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 31e541b..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright 2023 Maintainers of lpm0073/aws-rekognition
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..1eb391f
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,671 @@
+ GNU AFFERO GENERAL PUBLIC LICENSE
+ Version 3, 19 November 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+our General Public Licenses are intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
+
+ A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate. Many developers of free software are heartened and
+encouraged by the resulting cooperation. However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
+
+ The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community. It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server. Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
+
+ An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals. This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU Affero General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Remote Network Interaction; Use with the GNU General Public License.
+
+ Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software. This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU Affero General Public License from time to time. Such new versions
+will be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU Affero General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU Affero General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU Affero General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source. For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code. There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU AGPL, see
+.
+
+EdX Inc. wishes to state, in clarification of the above license terms, that
+any public, independently available web service offered over the network and
+communicating with edX's copyrighted works by any form of inter-service
+communication, including but not limited to Remote Procedure Call (RPC)
+interfaces, is not a work based on our copyrighted work within the meaning
+of the license. "Corresponding Source" of this work, or works based on this
+work, as defined by the terms of this license do not include source code
+files for programs used solely to provide those public, independently
+available web services.
diff --git a/Makefile b/Makefile
index 7231fca..c6d2a22 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,117 @@
SHELL := /bin/bash
+PYTHON = python3
+PIP = $(PYTHON) -m pip
+.PHONY: env analyze init pre-commit requirements lint clean test build force-release publish-test publish-prod help
+
+
+ifeq ($(OS),Windows_NT)
+ ACTIVATE_VENV = venv\Scripts\activate
+else
+ ACTIVATE_VENV = source venv/bin/activate
+endif
+
+env:
+ ifneq ("$(wildcard .env)","")
+ include .env
+ else
+ $(shell echo -e "MAX_FACES_COUNT=10" >> .env)
+ $(shell echo -e "FACE_DETECT_THRESHOLD=PLEASE-ADD-ME" >> .env)
+ $(shell echo -e "FACE_DETECT_ATTRIBUTES=PLEASE-ADD-ME" >> .env)
+ $(shell echo -e "QUALITY_FILTER=PLEASE-ADD-ME" >> .env)
+ $(shell echo -e "TABLE_ID=gcp-starter" >> .env)
+ $(shell echo -e "REGION=us-east-1" >> .env)
+ $(shell echo -e "COLLECTION_ID=gcp-starter" >> .env)
+ $(shell echo -e "DEBUG_MODE=True" >> .env)
+ endif
+
+# Default target executed when no arguments are given to make.
+all: help
+
+analyze:
+ cloc . --exclude-ext=svg,json,zip --vcs=git
+
+# -------------------------------------------------------------------------
+# Initialize. create virtual environment and install requirements
+# -------------------------------------------------------------------------
+init:
+ make clean && \
+ npm install eslint --save-dev && \
+ npm install eslint-plugin-import --save-dev && \
+ npm install eslint-config-google --save-dev && \
+ npm install && \
+ python3.11 -m venv venv && \
+ $(ACTIVATE_VENV) && \
+ pip install --upgrade pip && \
+ make requirements
+
+# -------------------------------------------------------------------------
+# Install and run pre-commit hooks
+# -------------------------------------------------------------------------
+pre-commit:
+ pre-commit install
+ pre-commit run --all-files
+
+# -------------------------------------------------------------------------
+# Install requirements: Python, npm and pre-commit
+# -------------------------------------------------------------------------
+requirements:
+ rm -rf .tox
+ $(PIP) install --upgrade pip wheel
+ $(PIP) install -r requirements.txt && \
+ npm install && \
+ pre-commit autoupdate
+ make pre-commit
+
+# -------------------------------------------------------------------------
+# Run black and pre-commit hooks.
+# includes prettier, isort, flake8, pylint, etc.
+# -------------------------------------------------------------------------
lint:
terraform fmt -recursive
pre-commit run --all-files
black ./terraform/python/
+
+# -------------------------------------------------------------------------
+# Destroy all build artifacts and Python temporary files
+# -------------------------------------------------------------------------
+clean:
+ rm -rf ./terraform/.terraform venv .pytest_cache __pycache__ .pytest_cache node_modules && \
+ rm -rf build dist aws-rekogition.egg-info
+
+# -------------------------------------------------------------------------
+# Run Python unit tests
+# -------------------------------------------------------------------------
+test:
+ python -m unittest discover -s terraform/python/tests/
+
+# -------------------------------------------------------------------------
+# Force a new semantic release to be created in GitHub
+# -------------------------------------------------------------------------
+force-release:
+ git commit -m "fix: force a new release" --allow-empty && git push
+
+update:
+ npm install -g npm
+ npm install -g npm-check-updates
+ ncu --upgrade --packageFile ./package.json
+ npm update -g
+ make init
+
+build:
+ @echo "Not implemented"
+
+# -------------------------------------------------------------------------
+# Generate help menu
+# -------------------------------------------------------------------------
+help:
+ @echo '===================================================================='
+ @echo 'init - build virtual environment and install requirements'
+ @echo 'analyze - runs cloc report'
+ @echo 'pre-commit - install and configure pre-commit hooks'
+ @echo 'requirements - install Python, npm and pre-commit requirements'
+ @echo 'lint - run black and pre-commit hooks'
+ @echo 'clean - destroy all build artifacts'
+ @echo 'test - run Python unit tests'
+ @echo 'build - build the project --- NOT IMPLEMENTED!!'
+ @echo 'force-release - force a new release to be created in GitHub'
diff --git a/README.md b/README.md
index ae0b21d..29a67eb 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,6 @@ As a convenience, this repo includes a set of test data that has already been ba
4. Search for indexed faces by uploading images to the `search` endpoint. Results are returned in JSON format. See [sample output](./doc/rekognition_search_output.json).
-
## Architecture
As of Sep-2023 AWS has introduced a large and still-growing [list of AI/ML services](https://aws.amazon.com/getting-started/decision-guides/machine-learning-on-aws-how-to-choose/) that seamlessly interoperate with other infrastructure and services in the AWS ecosystem. This solution is based fundamentally on AWS Rekognition, one of AWS' two vision services.
@@ -97,10 +96,10 @@ This is a [Terraform](https://www.terraform.io/) based installation methodology
The service stack consists of the following:
-* a AWS S3 bucket and DynamoDB table for managing Terraform state
-* [AWS S3 bucket](https://aws.amazon.com/s3/) for storing train and test image sets.
-* [DynamoDB Table](https://aws.amazon.com/dynamodb/) for persisting Rekognition service results
-* [AWS IAM Role](https://aws.amazon.com/iam/) for managing service-level role-based security for this service
+- a AWS S3 bucket and DynamoDB table for managing Terraform state
+- [AWS S3 bucket](https://aws.amazon.com/s3/) for storing train and test image sets.
+- [DynamoDB Table](https://aws.amazon.com/dynamodb/) for persisting Rekognition service results
+- [AWS IAM Role](https://aws.amazon.com/iam/) for managing service-level role-based security for this service
**WARNINGS**:
@@ -112,12 +111,12 @@ The service stack consists of the following:
Quickstart for Linux & macOS operating systems.
-**Prerequisite:** Obtain an [AWS IAM User](https://aws.amazon.com/iam/) with administrator priviledges, access key and secret key.
+**Prerequisite:** Obtain an [AWS IAM User](https://aws.amazon.com/iam/) with administrator privileges, access key and secret key.
Ensure that your environment includes the latest stable releases of the following software packages:
-* [aws cli](https://aws.amazon.com/cli/)
-* [terraform](https://www.terraform.io/)
+- [aws cli](https://aws.amazon.com/cli/)
+- [terraform](https://www.terraform.io/)
### Install required software packages using Homebrew
@@ -145,7 +144,6 @@ aws configure
This will interactively prompt for your AWS IAM user access key, secret key and preferred region.
-
### Setup Terraform
Terraform is a declarative open-source infrastructure-as-code software tool created by HashiCorp. This repo leverages Terraform to create all cloud infrastructure as well as to install and configure all software packages that run inside of Kubernetes. Terraform relies on an S3 bucket for storing its state data, and a DynamoDB table for managing a semaphore lock during operations.
@@ -208,7 +206,7 @@ vim terraform/terraform.tf
profile = "default"
encrypt = false
}
-````
+```
### Step 4. Configure your environment by setting Terraform global variable values
@@ -224,13 +222,12 @@ aws_region = "us-east-1"
aws_profile = "default"
```
-
### Step 3. Run the following command to initialize and build the solution
The Terraform modules in this repo rely extensively on calls to other third party Terraform modules published and maintained by [AWS](https://registry.terraform.io/namespaces/terraform-aws-modules). These modules will be downloaded by Terraform so that these can be executed locally from your computer. Noteworth examples of such third party modules include:
-* [terraform-aws-modules/s3](https://registry.terraform.io/modules/terraform-aws-modules/s3-bucket/aws/latest)
-* [terraform-aws-modules/dynamodb](https://registry.terraform.io/modules/terraform-aws-modules/dynamodb-table/aws/latest)
+- [terraform-aws-modules/s3](https://registry.terraform.io/modules/terraform-aws-modules/s3-bucket/aws/latest)
+- [terraform-aws-modules/dynamodb](https://registry.terraform.io/modules/terraform-aws-modules/dynamodb-table/aws/latest)
```console
cd terraform
@@ -304,7 +301,7 @@ Search images
## Original Sources
-Much of the code in this repository was scaffolded from these examples that I found via Google and Youtube searches. Several of these are well-presented, and they provide additional instruction and explanetory theory that I've ommited, so you might want to give these a look.
+Much of the code in this repository was scaffolded from these examples that I found via Google and Youtube searches. Several of these are well-presented, and they provide additional instruction and explanetory theory that I've omitted, so you might want to give these a look.
- [YouTube - Create your own Face Recognition Service with AWS Rekognition, by Tech Raj](https://www.youtube.com/watch?v=oHSesteFK5c)
- [Personnel Recognition with AWS Rekognition — Part I](https://aws.plainenglish.io/personnel-recognition-with-aws-rekognition-part-i-c4530f9b3c74)
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 0000000..0dde0f4
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1,24 @@
+# Security Policy
+
+## Supported Versions
+
+Only the latest version of this project is currently being supported with security updates.
+
+| Version | Supported |
+| -------- | ------------------ |
+| latest | :white_check_mark: |
+| < latest | :x: |
+
+## Reporting a Vulnerability
+
+If you discover a security vulnerability within this project, please send an email to [lpm0073@gmail.com](mailto:lpm0073@gmail.com). All security vulnerabilities will be promptly addressed.
+
+Please do not publicly disclose the issue until it has been addressed by the team.
+
+### Process
+
+1. The vulnerability will be acknowledged within 48 hours of receipt
+2. The team will investigate the issue and provide an estimated time for a fix
+3. Once a fix is prepared, it will be tested and confirmed
+4. The fix will be released as a new version of the package on PyPi
+5. The vulnerability report will be publicly disclosed, acknowledging the finder
diff --git a/aws-rekognition.postman_collection.json b/aws-rekognition.postman_collection.json
index b26d215..c9dcd11 100644
--- a/aws-rekognition.postman_collection.json
+++ b/aws-rekognition.postman_collection.json
@@ -1,177 +1,161 @@
{
- "info": {
- "_postman_id": "259121d3-a873-4041-9106-1cb01e5528db",
- "name": "AWS Rekognition",
- "description": "# 🚀 Get started here\n\nThis template guides you through CRUD operations (GET, POST, PUT, DELETE), variables, and tests.\n\n## 🔖 **How to use this template**\n\n#### **Step 1: Send requests**\n\nRESTful APIs allow you to perform CRUD operations using the POST, GET, PUT, and DELETE HTTP methods.\n\nThis collection contains each of these [request](https://learning.postman.com/docs/sending-requests/requests/) types. Open each request and click \"Send\" to see what happens.\n\n#### **Step 2: View responses**\n\nObserve the response tab for status code (200 OK), response time, and size.\n\n#### **Step 3: Send new Body data**\n\nUpdate or add new data in \"Body\" in the POST request. Typically, Body data is also used in PUT request.\n\n```\n{\n \"name\": \"Add your name in the body\"\n}\n\n```\n\n#### **Step 4: Update the variable**\n\nVariables enable you to store and reuse values in Postman. We have created a [variable](https://learning.postman.com/docs/sending-requests/variables/) called `base_url` with the sample request [https://postman-api-learner.glitch.me](https://postman-api-learner.glitch.me). Replace it with your API endpoint to customize this collection.\n\n#### **Step 5: Add tests in the \"Tests\" tab**\n\nTests help you confirm that your API is working as expected. You can write test scripts in JavaScript and view the output in the \"Test Results\" tab.\n\n
\n\n## 💪 Pro tips\n\n- Use folders to group related requests and organize the collection.\n- Add more [scripts](https://learning.postman.com/docs/writing-scripts/intro-to-scripts/) in \"Tests\" to verify if the API works as expected and execute workflows.\n \n\n## 💡Related templates\n\n[API testing basics](https://go.pstmn.io/API-testing-basics) \n[API documentation](https://go.pstmn.io/API-documentation) \n[Authorization methods](https://go.pstmn.io/Authorization-methods)",
- "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
- "_exporter_id": "2085624"
- },
- "item": [
- {
- "name": "File upload - index",
- "event": [
- {
- "listen": "test",
- "script": {
- "exec": [
- "pm.test(\"Successful POST request\", function () {",
- " pm.expect(pm.response.code).to.be.oneOf([200, 201]);",
- "});",
- ""
- ],
- "type": "text/javascript"
- }
- }
- ],
- "protocolProfileBehavior": {
- "strictSSL": true,
- "disabledSystemHeaders": {
- "content-type": true
- }
- },
- "request": {
- "auth": {
- "type": "noauth"
- },
- "method": "PUT",
- "header": [
- {
- "key": "x-amz-meta-name",
- "value": "Lawrence McDaniel",
- "type": "text"
- },
- {
- "key": "x-api-key",
- "value": "{{api_key}}",
- "type": "text"
- },
- {
- "key": "Content-Type",
- "value": "text/plain",
- "type": "text"
- }
- ],
- "body": {
- "mode": "file",
- "file": {
- "src": "/Users/mcdaniel/Desktop/test-data/Lawrence2_encoded.jpg"
- }
- },
- "url": {
- "raw": "{{base_url}}/{{stage}}/index/Lawrence2.jpeg",
- "host": [
- "{{base_url}}"
- ],
- "path": [
- "{{stage}}",
- "index",
- "Lawrence2.jpeg"
- ]
- },
- "description": "This is a POST request, submitting data to an API via the request body. This request submits JSON data, and the data is reflected in the response.\n\nA successful POST request typically returns a `200 OK` or `201 Created` response code."
- },
- "response": []
- },
- {
- "name": "File upload - search",
- "event": [
- {
- "listen": "test",
- "script": {
- "exec": [
- "pm.test(\"Successful POST request\", function () {",
- " pm.expect(pm.response.code).to.be.oneOf([200, 201]);",
- "});",
- ""
- ],
- "type": "text/javascript"
- }
- }
- ],
- "request": {
- "auth": {
- "type": "noauth"
- },
- "method": "PUT",
- "header": [
- {
- "key": "x-api-key",
- "value": "{{api_key}}",
- "type": "text"
- },
- {
- "key": "Content-Type",
- "value": "text/plain",
- "type": "text"
- }
- ],
- "body": {
- "mode": "file",
- "file": {
- "src": "/Users/mcdaniel/Desktop/test-data/bad-face-encoded-jpg"
- }
- },
- "url": {
- "raw": "{{base_url}}/{{stage}}/search/",
- "host": [
- "{{base_url}}"
- ],
- "path": [
- "{{stage}}",
- "search",
- ""
- ],
- "query": [
- {
- "key": "",
- "value": "",
- "disabled": true
- },
- {
- "key": "",
- "value": "",
- "disabled": true
- },
- {
- "key": "",
- "value": "",
- "disabled": true
- }
- ]
- },
- "description": "This is a POST request, submitting data to an API via the request body. This request submits JSON data, and the data is reflected in the response.\n\nA successful POST request typically returns a `200 OK` or `201 Created` response code."
- },
- "response": []
- }
- ],
- "event": [
- {
- "listen": "prerequest",
- "script": {
- "type": "text/javascript",
- "exec": [
- ""
- ]
- }
- },
- {
- "listen": "test",
- "script": {
- "type": "text/javascript",
- "exec": [
- ""
- ]
- }
- }
- ],
- "variable": [
- {
- "key": "id",
- "value": "1"
- },
- {
- "key": "base_url",
- "value": "https://postman-rest-api-learner.glitch.me/"
- }
- ]
+ "info": {
+ "_postman_id": "259121d3-a873-4041-9106-1cb01e5528db",
+ "name": "AWS Rekognition",
+ "description": "# 🚀 Get started here\n\nThis template guides you through CRUD operations (GET, POST, PUT, DELETE), variables, and tests.\n\n## 🔖 **How to use this template**\n\n#### **Step 1: Send requests**\n\nRESTful APIs allow you to perform CRUD operations using the POST, GET, PUT, and DELETE HTTP methods.\n\nThis collection contains each of these [request](https://learning.postman.com/docs/sending-requests/requests/) types. Open each request and click \"Send\" to see what happens.\n\n#### **Step 2: View responses**\n\nObserve the response tab for status code (200 OK), response time, and size.\n\n#### **Step 3: Send new Body data**\n\nUpdate or add new data in \"Body\" in the POST request. Typically, Body data is also used in PUT request.\n\n```\n{\n \"name\": \"Add your name in the body\"\n}\n\n```\n\n#### **Step 4: Update the variable**\n\nVariables enable you to store and reuse values in Postman. We have created a [variable](https://learning.postman.com/docs/sending-requests/variables/) called `base_url` with the sample request [https://postman-api-learner.glitch.me](https://postman-api-learner.glitch.me). Replace it with your API endpoint to customize this collection.\n\n#### **Step 5: Add tests in the \"Tests\" tab**\n\nTests help you confirm that your API is working as expected. You can write test scripts in JavaScript and view the output in the \"Test Results\" tab.\n\n
\n\n## 💪 Pro tips\n\n- Use folders to group related requests and organize the collection.\n- Add more [scripts](https://learning.postman.com/docs/writing-scripts/intro-to-scripts/) in \"Tests\" to verify if the API works as expected and execute workflows.\n \n\n## 💡Related templates\n\n[API testing basics](https://go.pstmn.io/API-testing-basics) \n[API documentation](https://go.pstmn.io/API-documentation) \n[Authorization methods](https://go.pstmn.io/Authorization-methods)",
+ "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
+ "_exporter_id": "2085624"
+ },
+ "item": [
+ {
+ "name": "File upload - index",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "exec": [
+ "pm.test(\"Successful POST request\", function () {",
+ " pm.expect(pm.response.code).to.be.oneOf([200, 201]);",
+ "});",
+ ""
+ ],
+ "type": "text/javascript"
+ }
+ }
+ ],
+ "protocolProfileBehavior": {
+ "strictSSL": true,
+ "disabledSystemHeaders": {
+ "content-type": true
+ }
+ },
+ "request": {
+ "auth": {
+ "type": "noauth"
+ },
+ "method": "PUT",
+ "header": [
+ {
+ "key": "x-amz-meta-name",
+ "value": "Lawrence McDaniel",
+ "type": "text"
+ },
+ {
+ "key": "x-api-key",
+ "value": "{{api_key}}",
+ "type": "text"
+ },
+ {
+ "key": "Content-Type",
+ "value": "text/plain",
+ "type": "text"
+ }
+ ],
+ "body": {
+ "mode": "file",
+ "file": {
+ "src": "/Users/mcdaniel/Desktop/test-data/Lawrence2_encoded.jpg"
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}/{{stage}}/index/Lawrence2.jpeg",
+ "host": ["{{base_url}}"],
+ "path": ["{{stage}}", "index", "Lawrence2.jpeg"]
+ },
+ "description": "This is a POST request, submitting data to an API via the request body. This request submits JSON data, and the data is reflected in the response.\n\nA successful POST request typically returns a `200 OK` or `201 Created` response code."
+ },
+ "response": []
+ },
+ {
+ "name": "File upload - search",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "exec": [
+ "pm.test(\"Successful POST request\", function () {",
+ " pm.expect(pm.response.code).to.be.oneOf([200, 201]);",
+ "});",
+ ""
+ ],
+ "type": "text/javascript"
+ }
+ }
+ ],
+ "request": {
+ "auth": {
+ "type": "noauth"
+ },
+ "method": "PUT",
+ "header": [
+ {
+ "key": "x-api-key",
+ "value": "{{api_key}}",
+ "type": "text"
+ },
+ {
+ "key": "Content-Type",
+ "value": "text/plain",
+ "type": "text"
+ }
+ ],
+ "body": {
+ "mode": "file",
+ "file": {
+ "src": "/Users/mcdaniel/Desktop/test-data/bad-face-encoded-jpg"
+ }
+ },
+ "url": {
+ "raw": "{{base_url}}/{{stage}}/search/",
+ "host": ["{{base_url}}"],
+ "path": ["{{stage}}", "search", ""],
+ "query": [
+ {
+ "key": "",
+ "value": "",
+ "disabled": true
+ },
+ {
+ "key": "",
+ "value": "",
+ "disabled": true
+ },
+ {
+ "key": "",
+ "value": "",
+ "disabled": true
+ }
+ ]
+ },
+ "description": "This is a POST request, submitting data to an API via the request body. This request submits JSON data, and the data is reflected in the response.\n\nA successful POST request typically returns a `200 OK` or `201 Created` response code."
+ },
+ "response": []
+ }
+ ],
+ "event": [
+ {
+ "listen": "prerequest",
+ "script": {
+ "type": "text/javascript",
+ "exec": [""]
+ }
+ },
+ {
+ "listen": "test",
+ "script": {
+ "type": "text/javascript",
+ "exec": [""]
+ }
+ }
+ ],
+ "variable": [
+ {
+ "key": "id",
+ "value": "1"
+ },
+ {
+ "key": "base_url",
+ "value": "https://postman-rest-api-learner.glitch.me/"
+ }
+ ]
}
diff --git a/codespell.txt b/codespell.txt
new file mode 100644
index 0000000..e3cd622
--- /dev/null
+++ b/codespell.txt
@@ -0,0 +1 @@
+OCE
diff --git a/commitlint.config.js b/commitlint.config.js
new file mode 100644
index 0000000..b58fa47
--- /dev/null
+++ b/commitlint.config.js
@@ -0,0 +1,56 @@
+const Configuration = {
+ /*
+ * Resolve and load @commitlint/config-conventional from node_modules.
+ * Referenced packages must be installed
+ */
+ extends: ["@commitlint/config-conventional", "@commitlint/config-angular"],
+ /*
+ * Resolve and load conventional-changelog-atom from node_modules.
+ * Referenced packages must be installed
+ */
+ parserPreset: "conventional-changelog-atom",
+ /*
+ * Resolve and load @commitlint/format from node_modules.
+ * Referenced package must be installed
+ */
+ formatter: "@commitlint/format",
+ /*
+ * Any rules defined here will override rules from @commitlint/config-conventional
+ */
+ rules: {},
+ /*
+ * Array of functions that return true if commitlint should ignore the given message.
+ * Given array is merged with predefined functions, which consist of matchers like:
+ *
+ * - 'Merge pull request', 'Merge X into Y' or 'Merge branch X'
+ * - 'Revert X'
+ * - 'v1.2.3' (ie semver matcher)
+ * - 'Automatic merge X' or 'Auto-merged X into Y'
+ *
+ * To see full list, check https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/is-ignored/src/defaults.ts.
+ * To disable those ignores and run rules always, set `defaultIgnores: false` as shown below.
+ */
+ /*
+ ignores: [(commit) => commit === ''],
+ * Whether commitlint uses the default ignore rules, see the description above.
+ */
+ defaultIgnores: true,
+ /*
+ * Custom URL to show upon failure
+ */
+ helpUrl:
+ "https://github.com/conventional-changelog/commitlint/#what-is-commitlint",
+ /*
+ * Custom prompt configs
+ */
+ prompt: {
+ messages: {},
+ questions: {
+ type: {
+ description: "please input type:",
+ },
+ },
+ },
+};
+
+module.exports = Configuration;
diff --git a/doc/apigateway_search_lambda_event.json b/doc/apigateway_search_lambda_event.json
index 7f79d91..26c7214 100644
--- a/doc/apigateway_search_lambda_event.json
+++ b/doc/apigateway_search_lambda_event.json
@@ -1,131 +1,95 @@
{
"event": {
- "resource": "/search/{filename}",
- "path": "/search/Lawrence4a.jpg",
+ "resource": "/search/{filename}",
+ "path": "/search/Lawrence4a.jpg",
+ "httpMethod": "PUT",
+ "headers": {
+ "Accept": "*/*",
+ "Accept-Encoding": "gzip, deflate, br",
+ "CloudFront-Forwarded-Proto": "https",
+ "CloudFront-Is-Desktop-Viewer": "true",
+ "CloudFront-Is-Mobile-Viewer": "false",
+ "CloudFront-Is-SmartTV-Viewer": "false",
+ "CloudFront-Is-Tablet-Viewer": "false",
+ "CloudFront-Viewer-ASN": "17072",
+ "CloudFront-Viewer-Country": "MX",
+ "Content-Type": "text/plain",
+ "Host": "44478mmtkg.execute-api.us-east-1.amazonaws.com",
+ "Postman-Token": "12784428-f519-48c2-9d27-83c74af1df23",
+ "User-Agent": "PostmanRuntime/7.32.3",
+ "Via": "1.1 ca31d0bb7c95405e2a3f70f912def572.cloudfront.net (CloudFront)",
+ "X-Amz-Cf-Id": "jqTZWdobBH3DK2NX9YaHLh3t41TJCjeAeKHqR-ujdPhO9dS8JMWiJw==",
+ "X-Amzn-Trace-Id": "Root=1-64f8d3c6-0e89b922326159fc139d1778",
+ "x-api-key": "NZPnpK6OedanfqZW9bz801QHniYKUTaB8yGeRa4t",
+ "X-Forwarded-For": "187.190.198.47, 18.68.19.23",
+ "X-Forwarded-Port": "443",
+ "X-Forwarded-Proto": "https"
+ },
+ "multiValueHeaders": {
+ "Accept": ["*/*"],
+ "Accept-Encoding": ["gzip, deflate, br"],
+ "CloudFront-Forwarded-Proto": ["https"],
+ "CloudFront-Is-Desktop-Viewer": ["true"],
+ "CloudFront-Is-Mobile-Viewer": ["false"],
+ "CloudFront-Is-SmartTV-Viewer": ["false"],
+ "CloudFront-Is-Tablet-Viewer": ["false"],
+ "CloudFront-Viewer-ASN": ["17072"],
+ "CloudFront-Viewer-Country": ["MX"],
+ "Content-Type": ["text/plain"],
+ "Host": ["44478mmtkg.execute-api.us-east-1.amazonaws.com"],
+ "Postman-Token": ["12784428-f519-48c2-9d27-83c74af1df23"],
+ "User-Agent": ["PostmanRuntime/7.32.3"],
+ "Via": [
+ "1.1 ca31d0bb7c95405e2a3f70f912def572.cloudfront.net (CloudFront)"
+ ],
+ "X-Amz-Cf-Id": [
+ "jqTZWdobBH3DK2NX9YaHLh3t41TJCjeAeKHqR-ujdPhO9dS8JMWiJw=="
+ ],
+ "X-Amzn-Trace-Id": ["Root=1-64f8d3c6-0e89b922326159fc139d1778"],
+ "x-api-key": ["NZPnpK6OedanfqZW9bz801QHniYKUTaB8yGeRa4t"],
+ "X-Forwarded-For": ["187.190.198.47, 18.68.19.23"],
+ "X-Forwarded-Port": ["443"],
+ "X-Forwarded-Proto": ["https"]
+ },
+ "queryStringParameters": null,
+ "multiValueQueryStringParameters": null,
+ "pathParameters": {
+ "filename": "Lawrence4a.jpg"
+ },
+ "stageVariables": null,
+ "requestContext": {
+ "resourceId": "ugz9kd",
+ "resourcePath": "/search/{filename}",
"httpMethod": "PUT",
- "headers": {
- "Accept": "*/*",
- "Accept-Encoding": "gzip, deflate, br",
- "CloudFront-Forwarded-Proto": "https",
- "CloudFront-Is-Desktop-Viewer": "true",
- "CloudFront-Is-Mobile-Viewer": "false",
- "CloudFront-Is-SmartTV-Viewer": "false",
- "CloudFront-Is-Tablet-Viewer": "false",
- "CloudFront-Viewer-ASN": "17072",
- "CloudFront-Viewer-Country": "MX",
- "Content-Type": "text/plain",
- "Host": "44478mmtkg.execute-api.us-east-1.amazonaws.com",
- "Postman-Token": "12784428-f519-48c2-9d27-83c74af1df23",
- "User-Agent": "PostmanRuntime/7.32.3",
- "Via": "1.1 ca31d0bb7c95405e2a3f70f912def572.cloudfront.net (CloudFront)",
- "X-Amz-Cf-Id": "jqTZWdobBH3DK2NX9YaHLh3t41TJCjeAeKHqR-ujdPhO9dS8JMWiJw==",
- "X-Amzn-Trace-Id": "Root=1-64f8d3c6-0e89b922326159fc139d1778",
- "x-api-key": "NZPnpK6OedanfqZW9bz801QHniYKUTaB8yGeRa4t",
- "X-Forwarded-For": "187.190.198.47, 18.68.19.23",
- "X-Forwarded-Port": "443",
- "X-Forwarded-Proto": "https"
+ "extendedRequestId": "K2YHIHWpoAMF4gQ=",
+ "requestTime": "06/Sep/2023:19:32:22 +0000",
+ "path": "/v1/search/Lawrence4a.jpg",
+ "accountId": "090511222473",
+ "protocol": "HTTP/1.1",
+ "stage": "v1",
+ "domainPrefix": "44478mmtkg",
+ "requestTimeEpoch": 1694028742970,
+ "requestId": "e69153a2-2e58-48a0-8e4b-8c6980923db0",
+ "identity": {
+ "cognitoIdentityPoolId": null,
+ "cognitoIdentityId": null,
+ "apiKey": "NZPnpK6OedanfqZW9bz801QHniYKUTaB8yGeRa4t",
+ "principalOrgId": null,
+ "cognitoAuthenticationType": null,
+ "userArn": null,
+ "apiKeyId": "25c7kjkc33",
+ "userAgent": "PostmanRuntime/7.32.3",
+ "accountId": null,
+ "caller": null,
+ "sourceIp": "187.190.198.47",
+ "accessKey": null,
+ "cognitoAuthenticationProvider": null,
+ "user": null
},
- "multiValueHeaders": {
- "Accept": [
- "*/*"
- ],
- "Accept-Encoding": [
- "gzip, deflate, br"
- ],
- "CloudFront-Forwarded-Proto": [
- "https"
- ],
- "CloudFront-Is-Desktop-Viewer": [
- "true"
- ],
- "CloudFront-Is-Mobile-Viewer": [
- "false"
- ],
- "CloudFront-Is-SmartTV-Viewer": [
- "false"
- ],
- "CloudFront-Is-Tablet-Viewer": [
- "false"
- ],
- "CloudFront-Viewer-ASN": [
- "17072"
- ],
- "CloudFront-Viewer-Country": [
- "MX"
- ],
- "Content-Type": [
- "text/plain"
- ],
- "Host": [
- "44478mmtkg.execute-api.us-east-1.amazonaws.com"
- ],
- "Postman-Token": [
- "12784428-f519-48c2-9d27-83c74af1df23"
- ],
- "User-Agent": [
- "PostmanRuntime/7.32.3"
- ],
- "Via": [
- "1.1 ca31d0bb7c95405e2a3f70f912def572.cloudfront.net (CloudFront)"
- ],
- "X-Amz-Cf-Id": [
- "jqTZWdobBH3DK2NX9YaHLh3t41TJCjeAeKHqR-ujdPhO9dS8JMWiJw=="
- ],
- "X-Amzn-Trace-Id": [
- "Root=1-64f8d3c6-0e89b922326159fc139d1778"
- ],
- "x-api-key": [
- "NZPnpK6OedanfqZW9bz801QHniYKUTaB8yGeRa4t"
- ],
- "X-Forwarded-For": [
- "187.190.198.47, 18.68.19.23"
- ],
- "X-Forwarded-Port": [
- "443"
- ],
- "X-Forwarded-Proto": [
- "https"
- ]
- },
- "queryStringParameters": null,
- "multiValueQueryStringParameters": null,
- "pathParameters": {
- "filename": "Lawrence4a.jpg"
- },
- "stageVariables": null,
- "requestContext": {
- "resourceId": "ugz9kd",
- "resourcePath": "/search/{filename}",
- "httpMethod": "PUT",
- "extendedRequestId": "K2YHIHWpoAMF4gQ=",
- "requestTime": "06/Sep/2023:19:32:22 +0000",
- "path": "/v1/search/Lawrence4a.jpg",
- "accountId": "090511222473",
- "protocol": "HTTP/1.1",
- "stage": "v1",
- "domainPrefix": "44478mmtkg",
- "requestTimeEpoch": 1694028742970,
- "requestId": "e69153a2-2e58-48a0-8e4b-8c6980923db0",
- "identity": {
- "cognitoIdentityPoolId": null,
- "cognitoIdentityId": null,
- "apiKey": "NZPnpK6OedanfqZW9bz801QHniYKUTaB8yGeRa4t",
- "principalOrgId": null,
- "cognitoAuthenticationType": null,
- "userArn": null,
- "apiKeyId": "25c7kjkc33",
- "userAgent": "PostmanRuntime/7.32.3",
- "accountId": null,
- "caller": null,
- "sourceIp": "187.190.198.47",
- "accessKey": null,
- "cognitoAuthenticationProvider": null,
- "user": null
- },
- "domainName": "44478mmtkg.execute-api.us-east-1.amazonaws.com",
- "apiId": "44478mmtkg"
- },
- "body": null,
- "isBase64Encoded": false
+ "domainName": "44478mmtkg.execute-api.us-east-1.amazonaws.com",
+ "apiId": "44478mmtkg"
+ },
+ "body": null,
+ "isBase64Encoded": false
}
}
diff --git a/doc/rekognition_search_output.json b/doc/rekognition_search_output.json
index 9831b70..0dfe287 100644
--- a/doc/rekognition_search_output.json
+++ b/doc/rekognition_search_output.json
@@ -1,129 +1,129 @@
{
"faces": {
- "SearchedFaceBoundingBox": {
- "Width": 0.6752675771713257,
- "Height": 0.6300017833709717,
- "Left": 0.14113087952136993,
- "Top": 0.1448897272348404
- },
- "SearchedFaceConfidence": 99.99968719482422,
- "FaceMatches": [
- {
- "Similarity": 100.0,
- "Face": {
- "FaceId": "df1faf37-6aa7-4636-89d7-579f16d0e13f",
- "BoundingBox": {
- "Width": 0.6752679944038391,
- "Height": 0.6300020217895508,
- "Left": 0.14113099873065948,
- "Top": 0.14488999545574188
- },
- "ImageId": "d1d0410d-01b8-322a-b79b-974b70eae5a5",
- "ExternalImageId": "Lawrence4.jpg",
- "Confidence": 99.99970245361328,
- "IndexFacesModelVersion": "6.0"
- }
+ "SearchedFaceBoundingBox": {
+ "Width": 0.6752675771713257,
+ "Height": 0.6300017833709717,
+ "Left": 0.14113087952136993,
+ "Top": 0.1448897272348404
+ },
+ "SearchedFaceConfidence": 99.99968719482422,
+ "FaceMatches": [
+ {
+ "Similarity": 100.0,
+ "Face": {
+ "FaceId": "df1faf37-6aa7-4636-89d7-579f16d0e13f",
+ "BoundingBox": {
+ "Width": 0.6752679944038391,
+ "Height": 0.6300020217895508,
+ "Left": 0.14113099873065948,
+ "Top": 0.14488999545574188
},
- {
- "Similarity": 99.99995422363281,
- "Face": {
- "FaceId": "a2f560af-be60-44b8-9cca-2cd280aca18a",
- "BoundingBox": {
- "Width": 0.3834420144557953,
- "Height": 0.5404369831085205,
- "Left": 0.3352310061454773,
- "Top": 0.133883997797966
- },
- "ImageId": "8d44141e-cfce-3f8a-b5b5-c11db1a67fb3",
- "ExternalImageId": "Lawrence2.jpg",
- "Confidence": 99.9979019165039,
- "IndexFacesModelVersion": "6.0"
- }
+ "ImageId": "d1d0410d-01b8-322a-b79b-974b70eae5a5",
+ "ExternalImageId": "Lawrence4.jpg",
+ "Confidence": 99.99970245361328,
+ "IndexFacesModelVersion": "6.0"
+ }
+ },
+ {
+ "Similarity": 99.99995422363281,
+ "Face": {
+ "FaceId": "a2f560af-be60-44b8-9cca-2cd280aca18a",
+ "BoundingBox": {
+ "Width": 0.3834420144557953,
+ "Height": 0.5404369831085205,
+ "Left": 0.3352310061454773,
+ "Top": 0.133883997797966
},
- {
- "Similarity": 99.99993133544922,
- "Face": {
- "FaceId": "601497ff-3b28-4962-aeab-5b4b47261f4a",
- "BoundingBox": {
- "Width": 0.690172016620636,
- "Height": 0.6782780289649963,
- "Left": 0.17868299782276154,
- "Top": 0.14326800405979156
- },
- "ImageId": "708b44a6-bd78-3071-a7b2-c3b2566d6aab",
- "ExternalImageId": "Lawrence19.jpg",
- "Confidence": 99.99970245361328,
- "IndexFacesModelVersion": "6.0"
- }
+ "ImageId": "8d44141e-cfce-3f8a-b5b5-c11db1a67fb3",
+ "ExternalImageId": "Lawrence2.jpg",
+ "Confidence": 99.9979019165039,
+ "IndexFacesModelVersion": "6.0"
+ }
+ },
+ {
+ "Similarity": 99.99993133544922,
+ "Face": {
+ "FaceId": "601497ff-3b28-4962-aeab-5b4b47261f4a",
+ "BoundingBox": {
+ "Width": 0.690172016620636,
+ "Height": 0.6782780289649963,
+ "Left": 0.17868299782276154,
+ "Top": 0.14326800405979156
},
- {
- "Similarity": 99.99992370605469,
- "Face": {
- "FaceId": "f3799c95-29fa-4d30-88da-606222932bf4",
- "BoundingBox": {
- "Width": 0.1601639986038208,
- "Height": 0.3523370027542114,
- "Left": 0.8077139854431152,
- "Top": 0.09413400292396545
- },
- "ImageId": "30dca1a3-309c-3c2e-bd52-94dcc53d4981",
- "ExternalImageId": "Keanu-Avril-Lawrence.jpg",
- "Confidence": 99.9999008178711,
- "IndexFacesModelVersion": "6.0"
- }
+ "ImageId": "708b44a6-bd78-3071-a7b2-c3b2566d6aab",
+ "ExternalImageId": "Lawrence19.jpg",
+ "Confidence": 99.99970245361328,
+ "IndexFacesModelVersion": "6.0"
+ }
+ },
+ {
+ "Similarity": 99.99992370605469,
+ "Face": {
+ "FaceId": "f3799c95-29fa-4d30-88da-606222932bf4",
+ "BoundingBox": {
+ "Width": 0.1601639986038208,
+ "Height": 0.3523370027542114,
+ "Left": 0.8077139854431152,
+ "Top": 0.09413400292396545
},
- {
- "Similarity": 99.99968719482422,
- "Face": {
- "FaceId": "77a75f21-8079-428a-94a4-64f850b4d093",
- "BoundingBox": {
- "Width": 0.12419100105762482,
- "Height": 0.11222200095653534,
- "Left": 0.40661299228668213,
- "Top": 0.052646201103925705
- },
- "ImageId": "f293e331-9b5e-3447-9bde-c5b0eb179bab",
- "ExternalImageId": "Lawrence3.jpg",
- "Confidence": 99.9114990234375,
- "IndexFacesModelVersion": "6.0"
- }
+ "ImageId": "30dca1a3-309c-3c2e-bd52-94dcc53d4981",
+ "ExternalImageId": "Keanu-Avril-Lawrence.jpg",
+ "Confidence": 99.9999008178711,
+ "IndexFacesModelVersion": "6.0"
+ }
+ },
+ {
+ "Similarity": 99.99968719482422,
+ "Face": {
+ "FaceId": "77a75f21-8079-428a-94a4-64f850b4d093",
+ "BoundingBox": {
+ "Width": 0.12419100105762482,
+ "Height": 0.11222200095653534,
+ "Left": 0.40661299228668213,
+ "Top": 0.052646201103925705
},
- {
- "Similarity": 99.99951171875,
- "Face": {
- "FaceId": "7d9ae71a-ba6a-44b4-911b-a7edacc8dd5f",
- "BoundingBox": {
- "Width": 0.057725198566913605,
- "Height": 0.05725089833140373,
- "Left": 0.3871830105781555,
- "Top": 0.38436999917030334
- },
- "ImageId": "fb881647-55e3-3471-affc-1c496c78a830",
- "ExternalImageId": "Justin-Trudeau-Barack-Obama-Lawrence.jpg",
- "Confidence": 99.89849853515625,
- "IndexFacesModelVersion": "6.0"
- }
- }
- ],
- "FaceModelVersion": "6.0",
- "ResponseMetadata": {
- "RequestId": "6750e387-56bc-4ca7-8e7a-1f13e44135d3",
- "HTTPStatusCode": 200,
- "HTTPHeaders": {
- "x-amzn-requestid": "6750e387-56bc-4ca7-8e7a-1f13e44135d3",
- "content-type": "application/x-amz-json-1.1",
- "content-length": "2395",
- "date": "Thu, 07 Sep 2023 16:49:03 GMT"
+ "ImageId": "f293e331-9b5e-3447-9bde-c5b0eb179bab",
+ "ExternalImageId": "Lawrence3.jpg",
+ "Confidence": 99.9114990234375,
+ "IndexFacesModelVersion": "6.0"
+ }
+ },
+ {
+ "Similarity": 99.99951171875,
+ "Face": {
+ "FaceId": "7d9ae71a-ba6a-44b4-911b-a7edacc8dd5f",
+ "BoundingBox": {
+ "Width": 0.057725198566913605,
+ "Height": 0.05725089833140373,
+ "Left": 0.3871830105781555,
+ "Top": 0.38436999917030334
},
- "RetryAttempts": 0
+ "ImageId": "fb881647-55e3-3471-affc-1c496c78a830",
+ "ExternalImageId": "Justin-Trudeau-Barack-Obama-Lawrence.jpg",
+ "Confidence": 99.89849853515625,
+ "IndexFacesModelVersion": "6.0"
+ }
}
+ ],
+ "FaceModelVersion": "6.0",
+ "ResponseMetadata": {
+ "RequestId": "6750e387-56bc-4ca7-8e7a-1f13e44135d3",
+ "HTTPStatusCode": 200,
+ "HTTPHeaders": {
+ "x-amzn-requestid": "6750e387-56bc-4ca7-8e7a-1f13e44135d3",
+ "content-type": "application/x-amz-json-1.1",
+ "content-length": "2395",
+ "date": "Thu, 07 Sep 2023 16:49:03 GMT"
+ },
+ "RetryAttempts": 0
+ }
},
"matchedFaces": [
- "Lawrence4.jpg",
- "Lawrence2.jpg",
- "Lawrence19.jpg",
- "Keanu avril lawrence.jpg",
- "Lawrence3.jpg",
- "Justin trudeau barack obama lawrence.jpg"
+ "Lawrence4.jpg",
+ "Lawrence2.jpg",
+ "Lawrence19.jpg",
+ "Keanu avril lawrence.jpg",
+ "Lawrence3.jpg",
+ "Justin trudeau barack obama lawrence.jpg"
]
}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..6d623a5
--- /dev/null
+++ b/package.json
@@ -0,0 +1,366 @@
+{
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "devDependencies": {
+ "@semantic-release/changelog": "^6.0.3",
+ "@semantic-release/commit-analyzer": "^11.1.0",
+ "@semantic-release/git": "^10.0.1",
+ "@semantic-release/github": "^9.2.3",
+ "@semantic-release/release-notes-generator": "^12.1.0",
+ "eslint": "^8.55.0",
+ "eslint-config-airbnb-base": "^15.0.0",
+ "eslint-config-google": "^0.14.0",
+ "eslint-plugin-import": "^2.29.0",
+ "semantic-release": "^22.0.10"
+ },
+ "name": "aws-rekognition",
+ "description": "[![Source code](https://img.shields.io/static/v1?logo=github&label=Git&style=flat-square&color=brightgreen&message=Source%20code)](https://github.com/FullStackWithLawrence/aws-rekognition) [![Documentation](https://img.shields.io/static/v1?&label=Documentation&style=flat-square&color=000000&message=Documentation)](https://github.com/FullStackWithLawrence/aws-rekognition) [![AGPL License](https://img.shields.io/github/license/overhangio/tutor.svg?style=flat-square)](https://www.gnu.org/licenses/agpl-3.0.en.html) [![hack.d Lawrence McDaniel](https://img.shields.io/badge/hack.d-Lawrence%20McDaniel-orange.svg)](https://lawrencemcdaniel.com)",
+ "version": "0.1.0",
+ "main": ".eslintrc.js",
+ "directories": {
+ "doc": "doc"
+ },
+ "dependencies": {
+ "acorn": "^8.11.2",
+ "acorn-jsx": "^5.3.2",
+ "agent-base": "^7.1.0",
+ "aggregate-error": "^3.1.0",
+ "ajv": "^6.12.6",
+ "ansi-escapes": "^6.2.0",
+ "ansi-regex": "^5.0.1",
+ "ansi-styles": "^3.2.1",
+ "ansicolors": "^0.3.2",
+ "argparse": "^2.0.1",
+ "argv-formatter": "^1.0.0",
+ "array-buffer-byte-length": "^1.0.0",
+ "array-ify": "^1.0.0",
+ "array-includes": "^3.1.7",
+ "array.prototype.findlastindex": "^1.2.3",
+ "array.prototype.flat": "^1.3.2",
+ "array.prototype.flatmap": "^1.3.2",
+ "arraybuffer.prototype.slice": "^1.0.2",
+ "available-typed-arrays": "^1.0.5",
+ "balanced-match": "^1.0.2",
+ "before-after-hook": "^2.2.3",
+ "bottleneck": "^2.19.5",
+ "brace-expansion": "^1.1.11",
+ "braces": "^3.0.2",
+ "call-bind": "^1.0.5",
+ "callsites": "^3.1.0",
+ "cardinal": "^2.1.1",
+ "chalk": "^2.4.2",
+ "char-regex": "^1.0.2",
+ "clean-stack": "^2.2.0",
+ "cli-table3": "^0.6.3",
+ "cliui": "^8.0.1",
+ "color-convert": "^1.9.3",
+ "color-name": "^1.1.3",
+ "compare-func": "^2.0.0",
+ "concat-map": "^0.0.1",
+ "config-chain": "^1.1.13",
+ "confusing-browser-globals": "^1.0.11",
+ "conventional-changelog-angular": "^7.0.0",
+ "conventional-changelog-writer": "^7.0.1",
+ "conventional-commits-filter": "^4.0.0",
+ "conventional-commits-parser": "^5.0.0",
+ "core-util-is": "^1.0.3",
+ "cosmiconfig": "^8.3.6",
+ "cross-spawn": "^7.0.3",
+ "crypto-random-string": "^4.0.0",
+ "debug": "^4.3.4",
+ "deep-extend": "^0.6.0",
+ "deep-is": "^0.1.4",
+ "define-data-property": "^1.1.1",
+ "define-properties": "^1.2.1",
+ "deprecation": "^2.3.1",
+ "dir-glob": "^3.0.1",
+ "doctrine": "^3.0.0",
+ "dot-prop": "^5.3.0",
+ "duplexer2": "^0.1.4",
+ "emoji-regex": "^8.0.0",
+ "emojilib": "^2.4.0",
+ "env-ci": "^10.0.0",
+ "error-ex": "^1.3.2",
+ "es-abstract": "^1.22.3",
+ "es-set-tostringtag": "^2.0.2",
+ "es-shim-unscopables": "^1.0.2",
+ "es-to-primitive": "^1.2.1",
+ "escalade": "^3.1.1",
+ "escape-string-regexp": "^1.0.5",
+ "eslint-import-resolver-node": "^0.3.9",
+ "eslint-module-utils": "^2.8.0",
+ "eslint-scope": "^7.2.2",
+ "eslint-visitor-keys": "^3.4.3",
+ "espree": "^9.6.1",
+ "esprima": "^4.0.1",
+ "esquery": "^1.5.0",
+ "esrecurse": "^4.3.0",
+ "estraverse": "^5.3.0",
+ "esutils": "^2.0.3",
+ "execa": "^5.1.1",
+ "fast-deep-equal": "^3.1.3",
+ "fast-glob": "^3.3.2",
+ "fast-json-stable-stringify": "^2.1.0",
+ "fast-levenshtein": "^2.0.6",
+ "fastq": "^1.15.0",
+ "figures": "^6.0.1",
+ "file-entry-cache": "^6.0.1",
+ "fill-range": "^7.0.1",
+ "find-up": "^2.1.0",
+ "find-up-simple": "^1.0.0",
+ "find-versions": "^5.1.0",
+ "flat-cache": "^3.2.0",
+ "flatted": "^3.2.9",
+ "for-each": "^0.3.3",
+ "from2": "^2.3.0",
+ "fs-extra": "^11.2.0",
+ "fs.realpath": "^1.0.0",
+ "function-bind": "^1.1.2",
+ "function.prototype.name": "^1.1.6",
+ "functions-have-names": "^1.2.3",
+ "get-caller-file": "^2.0.5",
+ "get-intrinsic": "^1.2.2",
+ "get-stream": "^7.0.1",
+ "get-symbol-description": "^1.0.0",
+ "git-log-parser": "^1.2.0",
+ "glob": "^7.2.3",
+ "glob-parent": "^5.1.2",
+ "globals": "^13.24.0",
+ "globalthis": "^1.0.3",
+ "globby": "^14.0.0",
+ "gopd": "^1.0.1",
+ "graceful-fs": "^4.2.11",
+ "graphemer": "^1.4.0",
+ "handlebars": "^4.7.8",
+ "has-bigints": "^1.0.2",
+ "has-flag": "^3.0.0",
+ "has-property-descriptors": "^1.0.1",
+ "has-proto": "^1.0.1",
+ "has-symbols": "^1.0.3",
+ "has-tostringtag": "^1.0.0",
+ "hasown": "^2.0.0",
+ "hook-std": "^3.0.0",
+ "hosted-git-info": "^7.0.1",
+ "http-proxy-agent": "^7.0.0",
+ "https-proxy-agent": "^7.0.2",
+ "human-signals": "^2.1.0",
+ "ignore": "^5.3.0",
+ "import-fresh": "^3.3.0",
+ "import-from-esm": "^1.3.3",
+ "import-meta-resolve": "^4.0.0",
+ "imurmurhash": "^0.1.4",
+ "indent-string": "^4.0.0",
+ "index-to-position": "^0.1.2",
+ "inflight": "^1.0.6",
+ "inherits": "^2.0.4",
+ "ini": "^1.3.8",
+ "internal-slot": "^1.0.6",
+ "into-stream": "^7.0.0",
+ "is-array-buffer": "^3.0.2",
+ "is-arrayish": "^0.2.1",
+ "is-bigint": "^1.0.4",
+ "is-boolean-object": "^1.1.2",
+ "is-callable": "^1.2.7",
+ "is-core-module": "^2.13.1",
+ "is-date-object": "^1.0.5",
+ "is-extglob": "^2.1.1",
+ "is-fullwidth-code-point": "^3.0.0",
+ "is-glob": "^4.0.3",
+ "is-negative-zero": "^2.0.2",
+ "is-number": "^7.0.0",
+ "is-number-object": "^1.0.7",
+ "is-obj": "^2.0.0",
+ "is-path-inside": "^3.0.3",
+ "is-regex": "^1.1.4",
+ "is-shared-array-buffer": "^1.0.2",
+ "is-stream": "^2.0.1",
+ "is-string": "^1.0.7",
+ "is-symbol": "^1.0.4",
+ "is-text-path": "^2.0.0",
+ "is-typed-array": "^1.1.12",
+ "is-unicode-supported": "^2.0.0",
+ "is-weakref": "^1.0.2",
+ "isarray": "^1.0.0",
+ "isexe": "^2.0.0",
+ "issue-parser": "^6.0.0",
+ "java-properties": "^1.0.2",
+ "js-tokens": "^4.0.0",
+ "js-yaml": "^4.1.0",
+ "json-buffer": "^3.0.1",
+ "json-parse-better-errors": "^1.0.2",
+ "json-parse-even-better-errors": "^2.3.1",
+ "json-schema-traverse": "^0.4.1",
+ "json-stable-stringify-without-jsonify": "^1.0.1",
+ "json-stringify-safe": "^5.0.1",
+ "json5": "^1.0.2",
+ "jsonfile": "^6.1.0",
+ "jsonparse": "^1.3.1",
+ "JSONStream": "^1.3.5",
+ "keyv": "^4.5.4",
+ "levn": "^0.4.1",
+ "lines-and-columns": "^1.2.4",
+ "load-json-file": "^4.0.0",
+ "locate-path": "^2.0.0",
+ "lodash": "^4.17.21",
+ "lodash-es": "^4.17.21",
+ "lodash.capitalize": "^4.2.1",
+ "lodash.escaperegexp": "^4.1.2",
+ "lodash.isplainobject": "^4.0.6",
+ "lodash.isstring": "^4.0.1",
+ "lodash.merge": "^4.6.2",
+ "lodash.uniqby": "^4.7.0",
+ "lru-cache": "^10.1.0",
+ "marked": "^9.1.6",
+ "marked-terminal": "^6.2.0",
+ "meow": "^12.1.1",
+ "merge-stream": "^2.0.0",
+ "merge2": "^1.4.1",
+ "micromatch": "^4.0.5",
+ "mime": "^4.0.0",
+ "mimic-fn": "^2.1.0",
+ "minimatch": "^3.1.2",
+ "minimist": "^1.2.8",
+ "ms": "^2.1.2",
+ "natural-compare": "^1.4.0",
+ "neo-async": "^2.6.2",
+ "nerf-dart": "^1.0.0",
+ "node-emoji": "^2.1.3",
+ "normalize-package-data": "^6.0.0",
+ "normalize-url": "^8.0.0",
+ "npm": "^10.2.5",
+ "npm-run-path": "^4.0.1",
+ "object-inspect": "^1.13.1",
+ "object-keys": "^1.1.1",
+ "object.assign": "^4.1.5",
+ "object.entries": "^1.1.7",
+ "object.fromentries": "^2.0.7",
+ "object.groupby": "^1.0.1",
+ "object.values": "^1.1.7",
+ "once": "^1.4.0",
+ "onetime": "^5.1.2",
+ "optionator": "^0.9.3",
+ "p-each-series": "^3.0.0",
+ "p-filter": "^3.0.0",
+ "p-is-promise": "^3.0.0",
+ "p-limit": "^1.3.0",
+ "p-locate": "^2.0.0",
+ "p-map": "^5.5.0",
+ "p-reduce": "^2.1.0",
+ "p-try": "^1.0.0",
+ "parent-module": "^1.0.1",
+ "parse-json": "^8.1.0",
+ "path-exists": "^3.0.0",
+ "path-is-absolute": "^1.0.1",
+ "path-key": "^3.1.1",
+ "path-parse": "^1.0.7",
+ "path-type": "^4.0.0",
+ "picomatch": "^2.3.1",
+ "pify": "^3.0.0",
+ "pkg-conf": "^2.1.0",
+ "prelude-ls": "^1.2.1",
+ "process-nextick-args": "^2.0.1",
+ "proto-list": "^1.2.4",
+ "punycode": "^2.3.1",
+ "queue-microtask": "^1.2.3",
+ "rc": "^1.2.8",
+ "read-pkg": "^9.0.1",
+ "read-pkg-up": "^11.0.0",
+ "readable-stream": "^2.3.8",
+ "redeyed": "^2.1.1",
+ "regexp.prototype.flags": "^1.5.1",
+ "registry-auth-token": "^5.0.2",
+ "require-directory": "^2.1.1",
+ "resolve": "^1.22.8",
+ "resolve-from": "^5.0.0",
+ "reusify": "^1.0.4",
+ "rimraf": "^3.0.2",
+ "run-parallel": "^1.2.0",
+ "safe-array-concat": "^1.0.1",
+ "safe-buffer": "^5.1.2",
+ "safe-regex-test": "^1.0.0",
+ "semver": "^7.5.4",
+ "semver-diff": "^4.0.0",
+ "semver-regex": "^4.0.5",
+ "set-function-length": "^1.1.1",
+ "set-function-name": "^2.0.1",
+ "shebang-command": "^2.0.0",
+ "shebang-regex": "^3.0.0",
+ "side-channel": "^1.0.4",
+ "signal-exit": "^3.0.7",
+ "signale": "^1.4.0",
+ "skin-tone": "^2.0.0",
+ "slash": "^5.1.0",
+ "source-map": "^0.6.1",
+ "spawn-error-forwarder": "^1.0.0",
+ "spdx-correct": "^3.2.0",
+ "spdx-exceptions": "^2.3.0",
+ "spdx-expression-parse": "^3.0.1",
+ "spdx-license-ids": "^3.0.16",
+ "split2": "^4.2.0",
+ "stream-combiner2": "^1.1.1",
+ "string_decoder": "^1.1.1",
+ "string-width": "^4.2.3",
+ "string.prototype.trim": "^1.2.8",
+ "string.prototype.trimend": "^1.0.7",
+ "string.prototype.trimstart": "^1.0.7",
+ "strip-ansi": "^6.0.1",
+ "strip-bom": "^3.0.0",
+ "strip-final-newline": "^2.0.0",
+ "strip-json-comments": "^2.0.1",
+ "supports-color": "^5.5.0",
+ "supports-hyperlinks": "^3.0.0",
+ "supports-preserve-symlinks-flag": "^1.0.0",
+ "temp-dir": "^3.0.0",
+ "tempy": "^3.1.0",
+ "text-extensions": "^2.4.0",
+ "text-table": "^0.2.0",
+ "through": "^2.3.8",
+ "through2": "^2.0.5",
+ "to-regex-range": "^5.0.1",
+ "traverse": "^0.6.7",
+ "tsconfig-paths": "^3.14.2",
+ "type-check": "^0.4.0",
+ "type-fest": "^4.8.3",
+ "typed-array-buffer": "^1.0.0",
+ "typed-array-byte-length": "^1.0.0",
+ "typed-array-byte-offset": "^1.0.0",
+ "typed-array-length": "^1.0.4",
+ "uglify-js": "^3.17.4",
+ "unbox-primitive": "^1.0.2",
+ "unicode-emoji-modifier-base": "^1.0.0",
+ "unicorn-magic": "^0.1.0",
+ "unique-string": "^3.0.0",
+ "universal-user-agent": "^6.0.1",
+ "universalify": "^2.0.1",
+ "uri-js": "^4.4.1",
+ "url-join": "^5.0.0",
+ "util-deprecate": "^1.0.2",
+ "validate-npm-package-license": "^3.0.4",
+ "which": "^2.0.2",
+ "which-boxed-primitive": "^1.0.2",
+ "which-typed-array": "^1.1.13",
+ "wordwrap": "^1.0.0",
+ "wrap-ansi": "^7.0.0",
+ "wrappy": "^1.0.2",
+ "xtend": "^4.0.2",
+ "y18n": "^5.0.8",
+ "yallist": "^4.0.0",
+ "yargs": "^17.7.2",
+ "yargs-parser": "^21.1.1",
+ "yocto-queue": "^0.1.0"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/FullStackWithLawrence/aws-rekognition.git"
+ },
+ "keywords": [
+ "rekognition"
+ ],
+ "author": "Lawrence McDaniel",
+ "license": "AGPL-3.0",
+ "bugs": {
+ "url": "https://github.com/FullStackWithLawrence/aws-rekognition/issues"
+ },
+ "homepage": "https://github.com/FullStackWithLawrence/aws-rekognition#readme"
+}
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..c8e5e38
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,38 @@
+[build-system]
+requires = ["setuptools", "wheel"]
+
+[tool.isort]
+profile = "black"
+lines_after_imports = 2
+
+[tool.black]
+line-length = 120
+target-version = ['py311']
+include = '\.pyi?$'
+exclude = '''
+/(
+ \.git
+ | \.hg
+ | \.mypy_cache
+ | \.tox
+ | \.venv
+ | venv
+ | node_modules
+ | build
+ | buck-out
+ | build
+ | dist
+)/
+'''
+
+[tool.flake8]
+ignore = "D205,D413,D400,D401"
+max-line-length =120
+max-complexity = 10
+exclude = "venv"
+extend-exclude = "*__init__.py,*__version__.py,venv"
+select = "C101"
+
+[tool.codespell]
+skip = '*.svg,models/prompt_templates.py'
+ignore-words = 'codespell.txt'
diff --git a/release.config.js b/release.config.js
new file mode 100644
index 0000000..e47f0cf
--- /dev/null
+++ b/release.config.js
@@ -0,0 +1,38 @@
+module.exports = {
+ dryRun: false,
+ branches: [
+ {
+ name: "next",
+ prerelease: true,
+ },
+ {
+ name: "next-major",
+ prerelease: true,
+ },
+ "main",
+ ],
+ plugins: [
+ "@semantic-release/commit-analyzer",
+ "@semantic-release/release-notes-generator",
+ [
+ "@semantic-release/changelog",
+ {
+ changelogFile: "CHANGELOG.md",
+ },
+ ],
+ "@semantic-release/github",
+ [
+ "@semantic-release/git",
+ {
+ assets: [
+ "CHANGELOG.md",
+ "client/package.json",
+ "client/package-lock.json",
+ "requirements.txt",
+ ],
+ message:
+ "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
+ },
+ ],
+ ],
+};
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..5bb7080
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,22 @@
+# dev and test
+# ------------
+pytest==7.4.3
+pytest_mock==3.12.0
+
+# Code linters, formatters, and security scanners
+# ------------
+black==23.11.0
+flake8==6.1.0
+flake8-coding==1.3.2
+pre-commit==3.6.0
+isort==5.9.3
+mypy==1.7.1
+pylint
+bandit==1.7.6
+pydocstringformatter==0.7.3
+tox==4.11.4
+codespell==2.2.6
+
+# project dependencies
+# ------------
+boto3==1.33.12
diff --git a/run_pylint.sh b/run_pylint.sh
new file mode 100755
index 0000000..bbccb2c
--- /dev/null
+++ b/run_pylint.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+# Called from pre-commit. Run pylint on all python files in the current directory
+python -m pylint "$@"
diff --git a/terraform/json/iam_policy_lambda_logging.json b/terraform/json/iam_policy_lambda_logging.json
index 7614aa3..c607c67 100644
--- a/terraform/json/iam_policy_lambda_logging.json
+++ b/terraform/json/iam_policy_lambda_logging.json
@@ -1,15 +1,15 @@
{
- "Version": "2012-10-17",
- "Statement": [
- {
- "Action": [
+ "Version": "2012-10-17",
+ "Statement": [
+ {
+ "Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
- ],
- "Effect": "Allow",
+ ],
+ "Effect": "Allow",
"Resource": ["arn:aws:logs:*:*:*"],
- "Sid": "1"
- }
- ]
+ "Sid": "1"
+ }
+ ]
}
diff --git a/terraform/json/iam_role_apigateway.json b/terraform/json/iam_role_apigateway.json
index 66c28b1..e231536 100644
--- a/terraform/json/iam_role_apigateway.json
+++ b/terraform/json/iam_role_apigateway.json
@@ -1,13 +1,13 @@
{
- "Version" : "2012-10-17",
- "Statement" : [
+ "Version": "2012-10-17",
+ "Statement": [
{
- "Sid" : "",
- "Effect" : "Allow",
- "Principal" : {
- "Service" : "apigateway.amazonaws.com"
+ "Sid": "",
+ "Effect": "Allow",
+ "Principal": {
+ "Service": "apigateway.amazonaws.com"
},
- "Action" : "sts:AssumeRole"
+ "Action": "sts:AssumeRole"
}
]
}
diff --git a/terraform/json/iam_role_lambda.json b/terraform/json/iam_role_lambda.json
index fe94373..b55db60 100644
--- a/terraform/json/iam_role_lambda.json
+++ b/terraform/json/iam_role_lambda.json
@@ -5,9 +5,7 @@
"Sid": "",
"Effect": "Allow",
"Principal": {
- "Service": [
- "lambda.amazonaws.com"
- ]
+ "Service": ["lambda.amazonaws.com"]
},
"Action": "sts:AssumeRole"
}
diff --git a/terraform/python/__init__.py b/terraform/python/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/terraform/python/__version__.py b/terraform/python/__version__.py
new file mode 100644
index 0000000..c26a392
--- /dev/null
+++ b/terraform/python/__version__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# DO NOT EDIT.
+# Managed via automated CI/CD in .github/workflows/semanticVersionBump.yml.
+__version__ = "0.1.0-next.1"
diff --git a/terraform/python/lambda_index.py b/terraform/python/lambda_index.py
index 7687bc2..dc05d44 100644
--- a/terraform/python/lambda_index.py
+++ b/terraform/python/lambda_index.py
@@ -1,50 +1,55 @@
-# ------------------------------------------------------------------------------
-# written by: Lawrence McDaniel
-# https://lawrencemcdaniel.com/
-#
-# date: sep-2023
-#
-# Rekognition.index_faces():
-# https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rekognition/client/index_faces.html
-#
-# Detects faces in the input image and adds them to the specified collection.
-# Amazon Rekognition doesn’t save the actual faces that are detected.
-# Instead, the underlying detection algorithm first detects the faces
-# in the input image. For each face, the algorithm extracts facial
-# features into a feature vector, and stores it in the backend database.
-# Amazon Rekognition uses feature vectors when it performs face match
-# and search operations using the SearchFaces and SearchFacesByImage operations.
-#
-# - To get the number of faces in a collection, call DescribeCollection.
-#
-# - If you provide the optional ExternalImageId for the input image you provided,
-# Amazon Rekognition associates this ID with all faces that it detects.
-# When you call the ListFaces operation, the response returns the external ID.
-#
-# - The input image is passed either as base64-encoded image bytes,
-# or as a reference to an image in an Amazon S3 bucket.
-# ------------------------------------------------------------------------------
-
-import sys, traceback # libraries for error management
-import os # library for interacting with the operating system
-import platform # library to view informatoin about the server host this Lambda runs on
+# -*- coding: utf-8 -*-
+# pylint: disable=R0801,R0911,R0912,R0914,R0915,W0718
+"""
+written by: Lawrence McDaniel
+ https://lawrencemcdaniel.com/
+
+date: sep-2023
+
+Rekognition.index_faces():
+https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rekognition/client/index_faces.html
+
+Detects faces in the input image and adds them to the specified collection.
+Amazon Rekognition doesn’t save the actual faces that are detected.
+Instead, the underlying detection algorithm first detects the faces
+in the input image. For each face, the algorithm extracts facial
+features into a feature vector, and stores it in the backend database.
+Amazon Rekognition uses feature vectors when it performs face match
+and search operations using the SearchFaces and SearchFacesByImage operations.
+
+- To get the number of faces in a collection, call DescribeCollection.
+
+- If you provide the optional ExternalImageId for the input image you provided,
+ Amazon Rekognition associates this ID with all faces that it detects.
+ When you call the ListFaces operation, the response returns the external ID.
+
+- The input image is passed either as base64-encoded image bytes,
+ or as a reference to an image in an Amazon S3 bucket.
+"""
+
import json # library for interacting with JSON data https://www.json.org/json-en.html
-from decimal import (
+import logging # library for interacting with application log data
+import os # library for interacting with the operating system
+import platform # library to view information about the server host this Lambda runs on
+import sys # libraries for error management
+import traceback
+from decimal import ( # Python Decimal data type, for type casting JSON return data https://docs.python.org/3/library/decimal.html
Decimal,
-) # Python Decimal data type, for type casting JSON return data https://docs.python.org/3/library/decimal.html
-from urllib.parse import (
+)
+from urllib.parse import ( # to 'de-escape' string representations of URL values
unquote_plus,
-) # to 'de-escape' string representations of URL values
-import logging # library for interacting with application log data
+)
+
import boto3 # AWS SDK for Python https://boto3.amazonaws.com/v1/documentation/api/latest/index.html
+
# environment variables that were created by Terraform.
# see:
# lambda_index.tf resource "aws_lambda_function" "index"
# https://us-east-1.console.aws.amazon.com/lambda/home?region=us-east-1#/functions/facialrecognition-index?tab=code
COLLECTION_ID = os.environ["COLLECTION_ID"]
TABLE_ID = os.environ["TABLE_ID"]
-MAX_FACES = int(os.getenv("MAX_FACES_COUNT", "10"))
+MAX_FACES_COUNT = int(os.getenv("MAX_FACES_COUNT", "10"))
FACE_DETECT_ATTRIBUTES = os.getenv("FACE_DETECT_ATTRIBUTES", "DEFAULT")
QUALITY_FILTER = os.getenv("QUALITY_FILTER", "AUTO")
DEBUG_MODE = os.getenv("DEBUG_MODE", "False").lower() in ("true", "1", "t")
@@ -60,7 +65,8 @@
urllib3_logger.setLevel(logging.CRITICAL)
-def lambda_handler(event, context):
+# pylint: disable=unused-argument
+def lambda_handler(event, context): # noqa: C901
"""
Facial recognition analysis and indexing of images. Invoked by S3.
@@ -86,7 +92,7 @@ def lambda_handler(event, context):
"boto3": boto3.__version__,
"COLLECTION_ID": COLLECTION_ID,
"TABLE_ID": TABLE_ID,
- "MAX_FACES": MAX_FACES,
+ "MAX_FACES": MAX_FACES_COUNT,
"FACE_DETECT_ATTRIBUTES": FACE_DETECT_ATTRIBUTES,
"QUALITY_FILTER": QUALITY_FILTER,
"DEBUG_MODE": DEBUG_MODE,
@@ -105,11 +111,7 @@ def http_response_factory(status_code: int, body: json) -> json:
see https://docs.aws.amazon.com/lambda/latest/dg/python-handler.html
"""
if status_code < 100 or status_code > 599:
- raise ValueError(
- "Invalid HTTP response code received: {status_code}".format(
- status_code=status_code
- )
- )
+ raise ValueError(f"Invalid HTTP response code received: {status_code}")
if DEBUG_MODE:
retval = {
@@ -155,28 +157,24 @@ def exception_response_factory(exception) -> json:
# 'event' variable match what we are expecting.
# ---------------------------
try:
- if not "Records" in event:
+ if "Records" not in event:
raise TypeError("Records object not found in event object")
if records[0]["eventSource"] != "aws:s3":
- msg = "lambda_index() is intended to be called from aws:s3, but was invoked by {service}".format(
- service=records[0]["eventSource"]
- )
+ service = records[0]["eventSource"]
+ msg = f"lambda_index() is intended to be called from aws:s3, but was invoked by {service}"
raise TypeError(msg)
- if not "bucket" in records[0]["s3"]:
+ if "bucket" not in records[0]["s3"]:
raise TypeError("bucket not found in event object")
if records[0]["eventName"] != "ObjectCreated:Put":
- msg = "lambda_index() is intended to be called for ObjectCreated:Put event, but was invoked by {event}".format(
- event=records[0]["eventName"]
- )
+ event = records[0]["eventName"]
+ msg = f"lambda_index() is intended to be called for ObjectCreated:Put event, but was invoked by {event}"
raise TypeError(msg)
except TypeError as e:
- return http_response_factory(
- status_code=500, body=exception_response_factory(e)
- )
+ return http_response_factory(status_code=500, body=exception_response_factory(e))
# all good. lets process the event!
# ---------------------------
@@ -187,8 +185,7 @@ def exception_response_factory(exception) -> json:
s3_object_key = unquote_plus(record["s3"]["object"]["key"], encoding="utf-8")
s3_object = s3_client.Object(s3_bucket_name, s3_object_key)
s3_object_metadata = {
- key.replace("x-amz-meta-", ""): s3_object.metadata[key]
- for key in s3_object.metadata.keys()
+ key.replace("x-amz-meta-", ""): s3_object.metadata[key] for key in s3_object.metadata.keys()
}
if DEBUG_MODE:
print(json.dumps({"event_record": record}))
@@ -199,7 +196,7 @@ def exception_response_factory(exception) -> json:
Image={"S3Object": {"Bucket": s3_bucket_name, "Name": s3_object_key}},
ExternalImageId=s3_object_key,
DetectionAttributes=[FACE_DETECT_ATTRIBUTES],
- MaxFaces=MAX_FACES,
+ MaxFaces=MAX_FACES_COUNT,
QualityFilter=QUALITY_FILTER,
)
# ----------------------------------------------------------------------
@@ -216,7 +213,7 @@ def exception_response_factory(exception) -> json:
# handle anything that went wrong
# see https://docs.aws.amazon.com/rekognition/latest/dg/error-handling.html
- except rekognition_client.exceptions.InvalidParameterException as e:
+ except rekognition_client.exceptions.InvalidParameterException:
# If no faces are detected in the image, then index_faces()
# returns an InvalidParameterException error
pass
@@ -226,33 +223,23 @@ def exception_response_factory(exception) -> json:
rekognition_client.exceptions.ProvisionedThroughputExceededException,
rekognition_client.exceptions.ServiceQuotaExceededException,
) as e:
- return http_response_factory(
- status_code=401, body=exception_response_factory(e)
- )
+ return http_response_factory(status_code=401, body=exception_response_factory(e))
except rekognition_client.exceptions.AccessDeniedException as e:
- return http_response_factory(
- status_code=403, body=exception_response_factory(e)
- )
+ return http_response_factory(status_code=403, body=exception_response_factory(e))
except rekognition_client.exceptions.ResourceNotFoundException as e:
- return http_response_factory(
- status_code=404, body=exception_response_factory(e)
- )
+ return http_response_factory(status_code=404, body=exception_response_factory(e))
except (
rekognition_client.exceptions.InvalidS3ObjectException,
rekognition_client.exceptions.ImageTooLargeException,
rekognition_client.exceptions.InvalidImageFormatException,
) as e:
- return http_response_factory(
- status_code=406, body=exception_response_factory(e)
- )
+ return http_response_factory(status_code=406, body=exception_response_factory(e))
except (rekognition_client.exceptions.InternalServerError, Exception) as e:
- return http_response_factory(
- status_code=500, body=exception_response_factory(e)
- )
+ return http_response_factory(status_code=500, body=exception_response_factory(e))
# success!! return the results
return http_response_factory(status_code=200, body=faces)
diff --git a/terraform/python/lambda_index_payload.zip b/terraform/python/lambda_index_payload.zip
deleted file mode 100644
index 0d0f0c7..0000000
Binary files a/terraform/python/lambda_index_payload.zip and /dev/null differ
diff --git a/terraform/python/lambda_search.py b/terraform/python/lambda_search.py
index 59ba72a..d78874e 100644
--- a/terraform/python/lambda_search.py
+++ b/terraform/python/lambda_search.py
@@ -1,4 +1,6 @@
-# ------------------------------------------------------------------------------
+# -*- coding: utf-8 -*-
+# pylint: disable=R0801,R0911,R0912,R0914,R0915,W0718
+"""
# written by: Lawrence McDaniel
# https://lawrencemcdaniel.com/
#
@@ -30,20 +32,25 @@
#
# GISTS:
# - https://gist.github.com/alexcasalboni/0f21a1889f09760f8981b643326730ff
-# ------------------------------------------------------------------------------
-import sys, traceback # libraries for error management
-import os # library for interacting with the operating system
-import platform # library to view informatoin about the server host this Lambda runs on
-import json # library for interacting with JSON data https://www.json.org/json-en.html
+"""
+
import base64 # library with base63 encoding/decoding functions
+import json # library for interacting with JSON data https://www.json.org/json-en.html
+import os # library for interacting with the operating system
+import platform # library to view information about the server host this Lambda runs on
+import sys # libraries for error management
+import traceback
+
import boto3 # AWS SDK for Python https://boto3.amazonaws.com/v1/documentation/api/latest/index.html
-MAX_FACES = int(os.environ["MAX_FACES_COUNT"])
-THRESHOLD = float(os.environ["FACE_DETECT_THRESHOLD"])
-QUALITY_FILTER = os.environ["QUALITY_FILTER"]
-TABLE_ID = os.environ["TABLE_ID"]
-AWS_REGION = os.environ["REGION"]
+
COLLECTION_ID = os.environ["COLLECTION_ID"]
+TABLE_ID = os.environ["TABLE_ID"]
+MAX_FACES = int(os.getenv("MAX_FACES_COUNT", "10"))
+FACE_DETECT_ATTRIBUTES = os.getenv("FACE_DETECT_ATTRIBUTES", "DEFAULT")
+QUALITY_FILTER = os.getenv("QUALITY_FILTER", "AUTO")
+THRESHOLD = float(os.environ["FACE_DETECT_THRESHOLD"])
+AWS_REGION = os.environ["AWS_REGION"]
DEBUG_MODE = os.getenv("DEBUG_MODE", "False").lower() in ("true", "1", "t")
rekognition_client = boto3.client("rekognition", AWS_REGION)
@@ -52,7 +59,8 @@
dynamodb_table = dynamodb_client.Table(TABLE_ID)
-def lambda_handler(event, context):
+# pylint: disable=unused-argument
+def lambda_handler(event, context): # noqa: C901
"""
Facial recognition image analysis and search for indexed faces. invoked by API Gateway.
"""
@@ -85,11 +93,7 @@ def http_response_factory(status_code: int, body: json) -> json:
see https://docs.aws.amazon.com/lambda/latest/dg/python-handler.html
"""
if status_code < 100 or status_code > 599:
- raise ValueError(
- "Invalid HTTP response code received: {status_code}".format(
- status_code=status_code
- )
- )
+ raise ValueError(f"Invalid HTTP response code received: {status_code}")
if DEBUG_MODE:
retval = {
@@ -176,7 +180,7 @@ def exception_response_factory(exception) -> json:
# handle anything that went wrong
# see https://docs.aws.amazon.com/rekognition/latest/dg/error-handling.html
- except rekognition_client.exceptions.InvalidParameterException as e:
+ except rekognition_client.exceptions.InvalidParameterException:
# If no faces are detected in the image, then index_faces()
# returns an InvalidParameterException error
pass
@@ -186,33 +190,24 @@ def exception_response_factory(exception) -> json:
rekognition_client.exceptions.ProvisionedThroughputExceededException,
rekognition_client.exceptions.ServiceQuotaExceededException,
) as e:
- return http_response_factory(
- status_code=401, body=exception_response_factory(e)
- )
+ return http_response_factory(status_code=401, body=exception_response_factory(e))
except rekognition_client.exceptions.AccessDeniedException as e:
- return http_response_factory(
- status_code=403, body=exception_response_factory(e)
- )
+ return http_response_factory(status_code=403, body=exception_response_factory(e))
except rekognition_client.exceptions.ResourceNotFoundException as e:
- return http_response_factory(
- status_code=404, body=exception_response_factory(e)
- )
+ return http_response_factory(status_code=404, body=exception_response_factory(e))
except (
rekognition_client.exceptions.InvalidS3ObjectException,
rekognition_client.exceptions.ImageTooLargeException,
rekognition_client.exceptions.InvalidImageFormatException,
) as e:
- return http_response_factory(
- status_code=406, body=exception_response_factory(e)
- )
+ return http_response_factory(status_code=406, body=exception_response_factory(e))
+ # pylint: disable=broad-except
except (rekognition_client.exceptions.InternalServerError, Exception) as e:
- return http_response_factory(
- status_code=500, body=exception_response_factory(e)
- )
+ return http_response_factory(status_code=500, body=exception_response_factory(e))
# success!! return the results
retval = {
diff --git a/terraform/python/lambda_search_payload.zip b/terraform/python/lambda_search_payload.zip
deleted file mode 100644
index 6f5aad1..0000000
Binary files a/terraform/python/lambda_search_payload.zip and /dev/null differ
diff --git a/terraform/python/tests/__init__.py b/terraform/python/tests/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..c4b98dc
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,48 @@
+# setup a basic tox environment for flake8 with the default python3.11
+# environment
+[tox]
+envlist = py3.11,flake8
+skip_missing_interpreters = true
+
+[tool.isort]
+profile = "black"
+skip =venv,node_modules
+
+[gh-actions]
+python =
+ 3.8: gitlint,py38,flake8
+ 3.9: gitlint,py39,flake8
+ 3.10: gitlint,py310,flake8
+ 3.11: gitlint,py311,flake8,mypy,black,pylint
+
+[testenv]
+deps = -rrequirements.txt
+commands = pytest
+
+[testenv:flake8]
+skip_install = True
+deps = flake8
+commands = flake8
+
+[testenv:gitlint]
+skip_install = True
+deps = gitlint
+commands = gitlint {posargs}
+
+[testenv:bumpversion]
+skip_install = True
+passenv =
+ # Git can only find its global configuration if it knows where the
+ # user's HOME is.
+ HOME
+ # We set sign_tags in .bumpversion.cfg, so pass in the GnuPG agent
+ # reference to avoid having to retype the passphrase for an
+ # already-cached private key.
+ GPG_AGENT_INFO
+deps = bump2version
+commands = bump2version {posargs}
+
+[testenv:pylint]
+deps = pylint
+commands =
+ pylint . --disable=W0102