Skip to content

Commit

Permalink
Modify directory structure to align with latest ADF guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpulver committed Jan 11, 2025
1 parent 1c7f1c9 commit 43a751c
Show file tree
Hide file tree
Showing 17 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Consider [AWS CDK CLI](https://docs.aws.amazon.com/cdk/latest/guide/reference.ht
when upgrading AWS CDK packages version.

```bash
pip-compile --upgrade service/api/requirements.in
pip-compile --upgrade service/api/app/requirements.in
pip-compile --upgrade requirements.in
pip-compile --upgrade requirements-dev.in
```
Expand Down
2 changes: 1 addition & 1 deletion cdk.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"app": "python app.py",
"app": "python main.py",
"context": {
"@aws-cdk/aws-iam:minimizePolicies": true
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion requirements-dev.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-c service/api/requirements.txt
-c service/api/app/requirements.txt
-c requirements.txt
bandit
black
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ set -o verbose
npm install

# Install project dependencies
pip install -r service/api/requirements.txt -r requirements.txt -r requirements-dev.txt
pip install -r service/api/app/requirements.txt -r requirements.txt -r requirements-dev.txt
14 changes: 7 additions & 7 deletions scripts/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -o errexit
set -o verbose

targets=("service" "tests" "toolchain" "app.py" "constants.py")
targets=("service" "tests" "toolchain" "constants.py" "main.py")

# Find common security issues (https://bandit.readthedocs.io)
bandit --recursive "${targets[@]}"
Expand All @@ -25,16 +25,16 @@ xenon --max-absolute A --max-modules A --max-average A "${targets[@]}"

# Check dependencies for security issues (https://pyup.io/safety)
# See https://data.safetycli.com/v/70612/97c/ for 70612 ignore reason.
safety check -i 70612 -r service/api/requirements.txt -r requirements.txt -r requirements-dev.txt
safety check -i 70612 -r service/api/app/requirements.txt -r requirements.txt -r requirements-dev.txt

# Static type checker (https://mypy.readthedocs.io)
MYPYPATH="${PWD}" mypy --config-file .mypy.ini --exclude service/api "${targets[@]}"
MYPYPATH="${PWD}/service/api" mypy --config-file .mypy.ini --explicit-package-bases service/api
MYPYPATH="${PWD}" mypy --config-file .mypy.ini --exclude service/api/app "${targets[@]}"
MYPYPATH="${PWD}/service/api/app" mypy --config-file .mypy.ini --explicit-package-bases service/api/app

# Check for errors, enforce a coding standard, look for code smells (http://pylint.pycqa.org)
PYTHONPATH="${PWD}" pylint --rcfile .pylintrc --ignore service/api "${targets[@]}"
PYTHONPATH="${PWD}/service/api" pylint --rcfile .pylintrc service/api
PYTHONPATH="${PWD}" pylint --rcfile .pylintrc --ignore service/api/app "${targets[@]}"
PYTHONPATH="${PWD}/service/api/app" pylint --rcfile .pylintrc service/api/app

# Run tests and measure code coverage (https://coverage.readthedocs.io)
coverage run -m unittest discover -s tests
(cd "${PWD}/service/api"; coverage run -m unittest discover -s tests)
(cd "${PWD}/service/api/app"; coverage run -m unittest discover -s tests)
Empty file added service/api/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import unittest
from unittest import mock

import app
import main


class CRUDTestCase(unittest.TestCase):
Expand All @@ -22,7 +22,7 @@ def test_get_user_exists(self, mock_get_user: mock.Mock) -> None:
"stage": "$default",
},
}
response = app.lambda_handler(apigatewayv2_proxy_event, None)
response = main.lambda_handler(apigatewayv2_proxy_event, None)
self.assertEqual(json.loads(response["body"]), user)


Expand Down
4 changes: 2 additions & 2 deletions service/compute.py → service/api/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def __init__(
),
environment={"DYNAMODB_TABLE_NAME": dynamodb_table_name},
reserved_concurrent_executions=lambda_reserved_concurrency,
entry=str(pathlib.Path(__file__).parent.joinpath("api").resolve()),
index="app.py",
entry=str(pathlib.Path(__file__).parent.joinpath("app").resolve()),
index="main.py",
handler="lambda_handler",
)
cfn_lambda_function = cast(
Expand Down
2 changes: 1 addition & 1 deletion service/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from constructs import Construct

import constants
from service.compute import Compute
from service.api.compute import Compute
from service.ingress import Ingress


Expand Down
2 changes: 1 addition & 1 deletion service/service_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import aws_cdk.aws_dynamodb as dynamodb
from constructs import Construct

from service.compute import Compute
from service.api.compute import Compute
from service.database import Database
from service.ingress import Ingress
from service.metadata import Metadata
Expand Down
2 changes: 1 addition & 1 deletion tests/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import aws_cdk.aws_dynamodb as dynamodb
from aws_cdk import assertions

from service.compute import Compute
from service.api.compute import Compute
from service.database import Database


Expand Down

0 comments on commit 43a751c

Please sign in to comment.