diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..b215581d --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +fund=false diff --git a/.vscode/settings.json b/.vscode/settings.json index 16bd0ea6..279dcc7a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -39,5 +39,16 @@ "editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" } + }, + "python.analysis.extraPaths": [ + "./lib/lambda_layers/helper_functions", + "./lib/lambda_layers/appsync_helpers" + ], + "files.watcherExclude": { + "**/.git/objects/**": true, + "**/.git/subtree-cache/**": true, + "**/node_modules/*/**": true, + "**/cdk.out/**": true, + "**/.venv/**": true } } diff --git a/Makefile b/Makefile index f91f2acd..8b4feef4 100644 --- a/Makefile +++ b/Makefile @@ -50,10 +50,10 @@ pipeline.clean: ## Destroys the CDK pipeline npx cdk destroy -c email=$(email) -c label=$(label) -c account=$(account_id) -c region=$(region) -c source_branch=$(source_branch) -c source_repo=$(source_repo) drem.clean-infrastructure: ## Delete DREM application - aws cloudformation delete-stack --stack-name drem-backend-$(label)-infrastructure --region $(region) -c source_branch=$(source_branch) -c source_repo=$(source_repo) + aws cloudformation delete-stack --stack-name drem-backend-$(label)-infrastructure --region $(region) drem.clean-base: ## Delete DREM application - aws cloudformation delete-stack --stack-name drem-backend-$(label)-base --region $(region) -c source_branch=$(source_branch) -c source_repo=$(source_repo) + aws cloudformation delete-stack --stack-name drem-backend-$(label)-base --region $(region) manual.deploy: ## Deploy via cdk npx cdk deploy --c manual_deploy=True -c email=$(email) -c label=$(label) -c account=$(account_id) -c region=$(region) -c source_branch=$(source_branch) -c source_repo=$(source_repo) --all @@ -106,6 +106,11 @@ local.config.docker: ## Setup local config based on branch cd $(overlaysSrcPath)/graphql/ && amplify codegen cd $(current_dir) +local.config.python: ## Setup a Python .venv + python3 -m venv --prompt drem .venv + source .venv/bin/activate + pip install -e .[dev] + local.run: ## Run the frontend application locally for development PORT=3000 npm start --prefix website diff --git a/README.md b/README.md index 35f3ee55..caf0beff 100644 --- a/README.md +++ b/README.md @@ -237,6 +237,11 @@ We recommend that you use the Makefile based commands to simplify the steps requ If you plan to help develop DREM and contribute code, the initial deployment of DREM is the same as above. Once DREM has deployed, to make the deployed DREM stack available for local development, run the following commands, alternatively the stack can be run using docker compose to create containers for each of the three react applications that make up DREM: +In Visual Studio Code add the following extensions for the best experience: + +- Prettier - `esbenp.prettier-vscode` +- Black Formatter - `ms-python.black-formatter` + ### Local frontend development Running all resources and installing all dependencies on the local machine diff --git a/package.json b/package.json index bc3760e8..b7739ab8 100644 --- a/package.json +++ b/package.json @@ -32,10 +32,10 @@ "devDependencies": { "@types/jest": "^29.5.4", "@types/node": "20.5.6", - "@types/prettier": "3.0.0", "@typescript-eslint/eslint-plugin": "^6.5.0", "@typescript-eslint/parser": "^6.5.0", - "aws-cdk": "2.122.0", + "@babel/plugin-proposal-private-property-in-object": "^7.16.7", + "aws-cdk": "2.166.0", "eslint": "^8.48.0", "eslint-config-node": "^4.1.0", "eslint-config-prettier": "^9.0.0", @@ -49,14 +49,14 @@ "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", "jest": "^29.6.4", - "prettier": "^3.0.3", + "prettier": "^3.4.2", "ts-jest": "^29.1.1", "ts-node": "^10.9.1", "typescript": "5.2.2" }, "dependencies": { - "@aws-cdk/aws-lambda-python-alpha": "^2.122.0-alpha.0", - "aws-cdk-lib": "2.122.0", + "@aws-cdk/aws-lambda-python-alpha": "^2.166.0-alpha.0", + "aws-cdk-lib": "2.166.0", "awscdk-appsync-utils": "^0.0.190", "cdk-nag": "2.27.111", "cdk-serverless-clamscan": "^2.5.64", diff --git a/pyproject.toml b/pyproject.toml index b6b30e6f..8abd90db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,22 +1,76 @@ -[tool.pytest.ini_options] -addopts = "--cov --cov-report html --junitxml=reports/unittest-report.xml" -testpaths = [ - "tests" +[project] +name = "guidance-for-aws-deepracer-event-management" +version = "1.0.0" +description = "AWS DeepRacer Event Management Solution" +readme = "README.md" +requires-python = ">=3.8" +license = { text = "Apache-2.0" } +authors = [ + { name = "AWS Solutions Library" } ] -pythonpath = [ - ".", - "./backend/lambdas/helper_functions_layer/http_response" +dependencies = [ + "aws_lambda_powertools", + "boto3", + "requests_aws4auth", + "requests", + "http_response", + "simplejson", + "matplotlib", + "opencv-python", + "tqdm", + "psutil", + "pandas" ] +[project.optional-dependencies] +dev = [ + "awscli", + "aws-cdk-lib>=2.0.0", + "constructs>=10.0.0", + "aws-cdk.aws-lambda-python-alpha", + "pytest", + "pytest-cov" +] -[tool.coverage.run] -source = ["backend/lambdas"] - +[tool.setuptools] +packages = ["lib"] -[tool.isort] -profile = "black" +[tool.pytest.ini_options] +testpaths = ["tests"] +python_files = "test_*.py" +addopts = "-ra -q" [tool.black] line-length = 88 +target-version = ['py38'] include = '\.pyi?$' -experimental_string_processing = true \ No newline at end of file +experimental_string_processing = true + +[tool.isort] +profile = "black" +multi_line_output = 3 +line_length = 88 + +[tool.mypy] +python_version = "3.8" +warn_return_any = true +warn_unused_configs = true +check_untyped_defs = true + +[tool.coverage.run] +source = ["lib"] +omit = ["tests/*", "**/__init__.py"] + +[tool.coverage.report] +exclude_lines = [ +"pragma: no cover", +"def __repr__", +"if __name__ == .__main__.:", +"raise NotImplementedError", +"if TYPE_CHECKING:" +] + +[project.urls] +Homepage = "https://github.com/aws-solutions-library-samples/guidance-for-aws-deepracer-event-management" +Documentation = "https://github.com/aws-solutions-library-samples/guidance-for-aws-deepracer-event-management/blob/main/README.md" +Repository = "https://github.com/aws-solutions-library-samples/guidance-for-aws-deepracer-event-management.git" \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 507608a9..05cb0bee 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,7 +17,7 @@ "inlineSources": true, "experimentalDecorators": true, "strictPropertyInitialization": false, - "typeRoots": ["./node_modules/@types"] + "typeRoots": ["./node_modules/*","./node_modules/@types"] }, "exclude": ["node_modules", "cdk.out"] } diff --git a/website-stream-overlays/package.json b/website-stream-overlays/package.json index 1be30516..0c8c5322 100644 --- a/website-stream-overlays/package.json +++ b/website-stream-overlays/package.json @@ -70,6 +70,7 @@ "eslint-plugin-prettier": "^5.0.0", "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", - "prettier": "^3.0.3" + "prettier": "^3.4.2", + "typescript": "5.2.2" } } diff --git a/website/package.json b/website/package.json index 547bb5e6..61ea5a85 100644 --- a/website/package.json +++ b/website/package.json @@ -80,10 +80,14 @@ "eslint-plugin-prettier": "^5.0.1", "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", - "prettier": "^3.0.3" + "prettier": "^3.4.2", + "typescript": "5.2.2" }, "overrides": { "@svgr/webpack": "$@svgr/webpack", + "react-scripts": { + "typescript": "^5" + }, "react-refresh": "^0.14.0" } }