diff --git a/CHANGELOG.md b/CHANGELOG.md index 601b3a57..04f497db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,4 +22,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### **Changed** +- refactor validation script to use `ruff` instead of `black` and `isort` + ### **Removed** diff --git a/modules/mlflow/mlflow-fargate/pyproject.toml b/modules/mlflow/mlflow-fargate/pyproject.toml index f44862b2..ef8db5f9 100644 --- a/modules/mlflow/mlflow-fargate/pyproject.toml +++ b/modules/mlflow/mlflow-fargate/pyproject.toml @@ -1,32 +1,24 @@ -[tool.black] +[tool.ruff] +exclude = [ + ".eggs", + ".git", + ".hg", + ".mypy_cache", + ".ruff_cache", + ".tox", + ".venv", + "_build", + "buck-out", + "build", + "dist", + "codeseeder", +] line-length = 120 -target-version = ["py38", "py39", "py310"] -exclude = ''' -/( - \.eggs - | \.git - | \.hg - | \.mypy_cache - | \.tox - | \.venv - | \.env - | _build - | buck-out - | build - | dist - | codeseeder.out -)/ -''' +target-version = "py38" -[tool.isort] -multi_line_output = 3 -include_trailing_comma = true -force_grid_wrap = 0 -use_parentheses = true -ensure_newline_before_comments = true -line_length = 120 -py_version = 38 -skip_gitignore = false +[tool.ruff.lint] +select = ["F", "I", "E", "W"] +fixable = ["ALL"] [tool.mypy] python_version = "3.8" diff --git a/modules/mlflow/mlflow-fargate/requirements-dev.in b/modules/mlflow/mlflow-fargate/requirements-dev.in index 6412f987..e338a527 100644 --- a/modules/mlflow/mlflow-fargate/requirements-dev.in +++ b/modules/mlflow/mlflow-fargate/requirements-dev.in @@ -1,14 +1,12 @@ awscli -black cdk-nag cfn-lint check-manifest -flake8 -isort mypy pip-tools pydot pyroma pytest +ruff types-PyYAML types-setuptools diff --git a/modules/mlflow/mlflow-fargate/requirements-dev.txt b/modules/mlflow/mlflow-fargate/requirements-dev.txt index 1864c0bb..24849f9d 100644 --- a/modules/mlflow/mlflow-fargate/requirements-dev.txt +++ b/modules/mlflow/mlflow-fargate/requirements-dev.txt @@ -26,8 +26,6 @@ aws-sam-translator==1.84.0 # via cfn-lint awscli==1.32.41 # via -r requirements-dev.in -black==24.2.0 - # via -r requirements-dev.in boto3==1.34.41 # via aws-sam-translator botocore==1.34.41 @@ -53,9 +51,7 @@ charset-normalizer==3.3.2 check-manifest==0.49 # via -r requirements-dev.in click==8.1.7 - # via - # black - # pip-tools + # via pip-tools colorama==0.4.4 # via awscli constructs==10.3.0 @@ -70,8 +66,6 @@ exceptiongroup==1.2.0 # via # cattrs # pytest -flake8==7.0.0 - # via -r requirements-dev.in idna==3.6 # via requests importlib-metadata==7.0.1 @@ -80,8 +74,6 @@ importlib-resources==6.1.1 # via jsii iniconfig==2.0.0 # via pytest -isort==5.13.2 - # via -r requirements-dev.in jmespath==1.0.1 # via # boto3 @@ -110,34 +102,25 @@ jsonschema-specifications==2023.12.1 # via jsonschema junit-xml==1.9 # via cfn-lint -mccabe==0.7.0 - # via flake8 mpmath==1.3.0 # via sympy mypy==1.8.0 # via -r requirements-dev.in mypy-extensions==1.0.0 - # via - # black - # mypy + # via mypy networkx==3.2.1 # via cfn-lint packaging==23.2 # via - # black # build # pyroma # pytest -pathspec==0.12.1 - # via black pbr==6.0.0 # via # jschema-to-python # sarif-om pip-tools==7.3.0 # via -r requirements-dev.in -platformdirs==4.2.0 - # via black pluggy==1.4.0 # via pytest publication==0.0.3 @@ -151,16 +134,12 @@ publication==0.0.3 # jsii pyasn1==0.5.1 # via rsa -pycodestyle==2.11.1 - # via flake8 pydantic==2.6.1 # via aws-sam-translator pydantic-core==2.16.2 # via pydantic pydot==2.0.0 # via -r requirements-dev.in -pyflakes==3.2.0 - # via flake8 pygments==2.17.2 # via pyroma pyparsing==3.1.1 @@ -193,6 +172,8 @@ rpds-py==0.18.0 # referencing rsa==4.7.2 # via awscli +ruff==0.2.2 + # via -r requirements-dev.in s3transfer==0.10.0 # via # awscli @@ -207,7 +188,6 @@ sympy==1.12 # via cfn-lint tomli==2.0.1 # via - # black # build # check-manifest # mypy @@ -232,7 +212,6 @@ types-setuptools==69.0.0.20240125 typing-extensions==4.9.0 # via # aws-sam-translator - # black # cattrs # jsii # mypy diff --git a/modules/mlflow/mlflow-fargate/setup.cfg b/modules/mlflow/mlflow-fargate/setup.cfg deleted file mode 100644 index e97ef4c3..00000000 --- a/modules/mlflow/mlflow-fargate/setup.cfg +++ /dev/null @@ -1,13 +0,0 @@ -[flake8] -max-line-length = 120 -extend-ignore = E203, W503 -exclude = - .git, - __pycache__, - docs/source/conf.py, - old, - build, - dist, - .venv, - codeseeder.out, - bundle diff --git a/modules/mlflow/mlflow-fargate/tests/test_app.py b/modules/mlflow/mlflow-fargate/tests/test_app.py index 45b7a56f..fea72b5f 100644 --- a/modules/mlflow/mlflow-fargate/tests/test_app.py +++ b/modules/mlflow/mlflow-fargate/tests/test_app.py @@ -54,9 +54,9 @@ def test_rds_settings(stack_defaults): os.environ["SEEDFARMER_PARAMETER_RDS_HOSTNAME"] = "xxxxx" os.environ["SEEDFARMER_PARAMETER_RDS_PORT"] = "3306" os.environ["SEEDFARMER_PARAMETER_RDS_SECURITY_GROUP_ID"] = "sg-12345" - os.environ[ - "SEEDFARMER_PARAMETER_RDS_CREDENTIALS_SECRET_ARN" - ] = "arn:aws:secretsmanager:us-east-1:111111111111:secret:xxxxxx/xxxxxx-yyyyyy" + os.environ["SEEDFARMER_PARAMETER_RDS_CREDENTIALS_SECRET_ARN"] = ( + "arn:aws:secretsmanager:us-east-1:111111111111:secret:xxxxxx/xxxxxx-yyyyyy" + ) import app # noqa: F401 @@ -64,9 +64,9 @@ def test_rds_settings(stack_defaults): def test_rds_settings_missing_hostname(stack_defaults): os.environ["SEEDFARMER_PARAMETER_RDS_PORT"] = "3306" os.environ["SEEDFARMER_PARAMETER_RDS_SECURITY_GROUP_ID"] = "sg-12345" - os.environ[ - "SEEDFARMER_PARAMETER_RDS_CREDENTIALS_SECRET_ARN" - ] = "arn:aws:secretsmanager:us-east-1:111111111111:secret:xxxxxx/xxxxxx-yyyyyy" + os.environ["SEEDFARMER_PARAMETER_RDS_CREDENTIALS_SECRET_ARN"] = ( + "arn:aws:secretsmanager:us-east-1:111111111111:secret:xxxxxx/xxxxxx-yyyyyy" + ) with pytest.raises(ValueError): import app # noqa: F401 diff --git a/modules/mlflow/mlflow-image/pyproject.toml b/modules/mlflow/mlflow-image/pyproject.toml index 69c4a70f..17223773 100644 --- a/modules/mlflow/mlflow-image/pyproject.toml +++ b/modules/mlflow/mlflow-image/pyproject.toml @@ -1,32 +1,24 @@ -[tool.black] +[tool.ruff] +exclude = [ + ".eggs", + ".git", + ".hg", + ".mypy_cache", + ".ruff_cache", + ".tox", + ".venv", + "_build", + "buck-out", + "build", + "dist", + "codeseeder", +] line-length = 120 -target-version = ["py38", "py39", "py310"] -exclude = ''' -/( - \.eggs - | \.git - | \.hg - | \.mypy_cache - | \.tox - | \.venv - | \.env - | _build - | buck-out - | build - | dist - | codeseeder.out -)/ -''' +target-version = "py38" -[tool.isort] -multi_line_output = 3 -include_trailing_comma = true -force_grid_wrap = 0 -use_parentheses = true -ensure_newline_before_comments = true -line_length = 120 -py_version = 38 -skip_gitignore = false +[tool.ruff.lint] +select = ["F", "I", "E", "W"] +fixable = ["ALL"] [tool.mypy] python_version = "3.8" diff --git a/modules/mlflow/mlflow-image/requirements-dev.in b/modules/mlflow/mlflow-image/requirements-dev.in index 6412f987..e338a527 100644 --- a/modules/mlflow/mlflow-image/requirements-dev.in +++ b/modules/mlflow/mlflow-image/requirements-dev.in @@ -1,14 +1,12 @@ awscli -black cdk-nag cfn-lint check-manifest -flake8 -isort mypy pip-tools pydot pyroma pytest +ruff types-PyYAML types-setuptools diff --git a/modules/mlflow/mlflow-image/requirements-dev.txt b/modules/mlflow/mlflow-image/requirements-dev.txt index 96ce3195..8957c5de 100644 --- a/modules/mlflow/mlflow-image/requirements-dev.txt +++ b/modules/mlflow/mlflow-image/requirements-dev.txt @@ -4,17 +4,10 @@ # # pip-compile --output-file=requirements-dev.txt requirements-dev.in # -aiohttp==3.9.2 - # via black -aiosignal==1.3.1 - # via aiohttp annotated-types==0.6.0 # via pydantic -async-timeout==4.0.3 - # via aiohttp attrs==23.1.0 # via - # aiohttp # cattrs # jschema-to-python # jsii @@ -33,8 +26,6 @@ aws-sam-translator==1.82.0 # via cfn-lint awscli==1.32.0 # via -r requirements-dev.in -black==23.12.0 - # via -r requirements-dev.in boto3==1.34.0 # via aws-sam-translator botocore==1.34.0 @@ -60,9 +51,7 @@ charset-normalizer==3.3.2 check-manifest==0.49 # via -r requirements-dev.in click==8.1.7 - # via - # black - # pip-tools + # via pip-tools colorama==0.4.4 # via awscli constructs==10.3.0 @@ -77,24 +66,14 @@ exceptiongroup==1.2.0 # via # cattrs # pytest -flake8==6.1.0 - # via -r requirements-dev.in -frozenlist==1.4.0 - # via - # aiohttp - # aiosignal idna==3.6 - # via - # requests - # yarl + # via requests importlib-metadata==7.0.0 # via build importlib-resources==6.1.1 # via jsii iniconfig==2.0.0 # via pytest -isort==5.13.2 - # via -r requirements-dev.in jmespath==1.0.1 # via # boto3 @@ -123,38 +102,25 @@ jsonschema-specifications==2023.11.2 # via jsonschema junit-xml==1.9 # via cfn-lint -mccabe==0.7.0 - # via flake8 mpmath==1.3.0 # via sympy -multidict==6.0.4 - # via - # aiohttp - # yarl mypy==1.7.1 # via -r requirements-dev.in mypy-extensions==1.0.0 - # via - # black - # mypy + # via mypy networkx==3.2.1 # via cfn-lint packaging==23.2 # via - # black # build # pyroma # pytest -pathspec==0.12.1 - # via black pbr==6.0.0 # via # jschema-to-python # sarif-om pip-tools==7.3.0 # via -r requirements-dev.in -platformdirs==4.1.0 - # via black pluggy==1.3.0 # via pytest publication==0.0.3 @@ -168,16 +134,12 @@ publication==0.0.3 # jsii pyasn1==0.5.1 # via rsa -pycodestyle==2.11.1 - # via flake8 pydantic==2.5.2 # via aws-sam-translator pydantic-core==2.14.5 # via pydantic pydot==1.4.2 # via -r requirements-dev.in -pyflakes==3.1.0 - # via flake8 pygments==2.17.2 # via pyroma pyparsing==3.1.1 @@ -210,6 +172,8 @@ rpds-py==0.13.2 # referencing rsa==4.7.2 # via awscli +ruff==0.2.2 + # via -r requirements-dev.in s3transfer==0.9.0 # via # awscli @@ -224,7 +188,6 @@ sympy==1.12 # via cfn-lint tomli==2.0.1 # via - # black # build # check-manifest # mypy @@ -249,7 +212,6 @@ types-setuptools==69.0.0.0 typing-extensions==4.9.0 # via # aws-sam-translator - # black # cattrs # jsii # mypy @@ -261,8 +223,6 @@ urllib3==1.26.18 # requests wheel==0.42.0 # via pip-tools -yarl==1.9.4 - # via aiohttp zipp==3.17.0 # via # importlib-metadata diff --git a/modules/mlflow/mlflow-image/setup.cfg b/modules/mlflow/mlflow-image/setup.cfg deleted file mode 100644 index e97ef4c3..00000000 --- a/modules/mlflow/mlflow-image/setup.cfg +++ /dev/null @@ -1,13 +0,0 @@ -[flake8] -max-line-length = 120 -extend-ignore = E203, W503 -exclude = - .git, - __pycache__, - docs/source/conf.py, - old, - build, - dist, - .venv, - codeseeder.out, - bundle diff --git a/modules/sagemaker/sagemaker-endpoint/pyproject.toml b/modules/sagemaker/sagemaker-endpoint/pyproject.toml index 1f856efe..ef8db5f9 100644 --- a/modules/sagemaker/sagemaker-endpoint/pyproject.toml +++ b/modules/sagemaker/sagemaker-endpoint/pyproject.toml @@ -1,35 +1,41 @@ -[tool.black] +[tool.ruff] +exclude = [ + ".eggs", + ".git", + ".hg", + ".mypy_cache", + ".ruff_cache", + ".tox", + ".venv", + "_build", + "buck-out", + "build", + "dist", + "codeseeder", +] line-length = 120 -target-version = ["py36", "py37", "py38"] -exclude = ''' -/( - \.eggs - | \.git - | \.hg - | \.mypy_cache - | \.tox - | \.venv - | \.env - | _build - | buck-out - | build - | dist - | codeseeder.out -)/ -''' +target-version = "py38" -[tool.isort] -multi_line_output = 3 -include_trailing_comma = true -force_grid_wrap = 0 -use_parentheses = true -ensure_newline_before_comments = true -line_length = 120 -py_version = 36 -skip_gitignore = false +[tool.ruff.lint] +select = ["F", "I", "E", "W"] +fixable = ["ALL"] + +[tool.mypy] +python_version = "3.8" +strict = true +ignore_missing_imports = true +disallow_untyped_decorators = false +exclude = "codeseeder.out/|example/|tests/" +warn_unused_ignores = false [tool.pytest.ini_options] -addopts = "-v --cov=. --cov-report term --cov-config=coverage.ini --cov-fail-under=80" +addopts = "-v --cov=. --cov-report term" pythonpath = [ "." -] \ No newline at end of file +] + +[tool.coverage.run] +omit = ["tests/*"] + +[tool.coverage.report] +fail_under = 80 diff --git a/modules/sagemaker/sagemaker-endpoint/requirements-dev.in b/modules/sagemaker/sagemaker-endpoint/requirements-dev.in index 6412f987..e338a527 100644 --- a/modules/sagemaker/sagemaker-endpoint/requirements-dev.in +++ b/modules/sagemaker/sagemaker-endpoint/requirements-dev.in @@ -1,14 +1,12 @@ awscli -black cdk-nag cfn-lint check-manifest -flake8 -isort mypy pip-tools pydot pyroma pytest +ruff types-PyYAML types-setuptools diff --git a/modules/sagemaker/sagemaker-endpoint/requirements-dev.txt b/modules/sagemaker/sagemaker-endpoint/requirements-dev.txt index 59d38e3f..8957c5de 100644 --- a/modules/sagemaker/sagemaker-endpoint/requirements-dev.txt +++ b/modules/sagemaker/sagemaker-endpoint/requirements-dev.txt @@ -2,19 +2,12 @@ # This file is autogenerated by pip-compile with Python 3.9 # by the following command: # -# pip-compile requirements-dev.in +# pip-compile --output-file=requirements-dev.txt requirements-dev.in # -aiohttp==3.9.2 - # via black -aiosignal==1.3.1 - # via aiohttp annotated-types==0.6.0 # via pydantic -async-timeout==4.0.3 - # via aiohttp attrs==23.1.0 # via - # aiohttp # cattrs # jschema-to-python # jsii @@ -33,8 +26,6 @@ aws-sam-translator==1.82.0 # via cfn-lint awscli==1.32.0 # via -r requirements-dev.in -black==23.12.0 - # via -r requirements-dev.in boto3==1.34.0 # via aws-sam-translator botocore==1.34.0 @@ -60,9 +51,7 @@ charset-normalizer==3.3.2 check-manifest==0.49 # via -r requirements-dev.in click==8.1.7 - # via - # black - # pip-tools + # via pip-tools colorama==0.4.4 # via awscli constructs==10.3.0 @@ -77,24 +66,14 @@ exceptiongroup==1.2.0 # via # cattrs # pytest -flake8==6.1.0 - # via -r requirements-dev.in -frozenlist==1.4.0 - # via - # aiohttp - # aiosignal idna==3.6 - # via - # requests - # yarl + # via requests importlib-metadata==7.0.0 # via build importlib-resources==6.1.1 # via jsii iniconfig==2.0.0 # via pytest -isort==5.13.2 - # via -r requirements-dev.in jmespath==1.0.1 # via # boto3 @@ -123,38 +102,25 @@ jsonschema-specifications==2023.11.2 # via jsonschema junit-xml==1.9 # via cfn-lint -mccabe==0.7.0 - # via flake8 mpmath==1.3.0 # via sympy -multidict==6.0.4 - # via - # aiohttp - # yarl mypy==1.7.1 # via -r requirements-dev.in mypy-extensions==1.0.0 - # via - # black - # mypy + # via mypy networkx==3.2.1 # via cfn-lint packaging==23.2 # via - # black # build # pyroma # pytest -pathspec==0.12.1 - # via black pbr==6.0.0 # via # jschema-to-python # sarif-om pip-tools==7.3.0 # via -r requirements-dev.in -platformdirs==4.1.0 - # via black pluggy==1.3.0 # via pytest publication==0.0.3 @@ -168,16 +134,12 @@ publication==0.0.3 # jsii pyasn1==0.5.1 # via rsa -pycodestyle==2.11.1 - # via flake8 pydantic==2.5.2 # via aws-sam-translator pydantic-core==2.14.5 # via pydantic pydot==1.4.2 # via -r requirements-dev.in -pyflakes==3.1.0 - # via flake8 pygments==2.17.2 # via pyroma pyparsing==3.1.1 @@ -210,6 +172,8 @@ rpds-py==0.13.2 # referencing rsa==4.7.2 # via awscli +ruff==0.2.2 + # via -r requirements-dev.in s3transfer==0.9.0 # via # awscli @@ -224,7 +188,6 @@ sympy==1.12 # via cfn-lint tomli==2.0.1 # via - # black # build # check-manifest # mypy @@ -249,7 +212,6 @@ types-setuptools==69.0.0.0 typing-extensions==4.9.0 # via # aws-sam-translator - # black # cattrs # jsii # mypy @@ -261,8 +223,6 @@ urllib3==1.26.18 # requests wheel==0.42.0 # via pip-tools -yarl==1.9.4 - # via aiohttp zipp==3.17.0 # via # importlib-metadata diff --git a/modules/sagemaker/sagemaker-endpoint/setup.cfg b/modules/sagemaker/sagemaker-endpoint/setup.cfg deleted file mode 100644 index 6136e2bb..00000000 --- a/modules/sagemaker/sagemaker-endpoint/setup.cfg +++ /dev/null @@ -1,28 +0,0 @@ -[metadata] -license_files = - LICENSE - NOTICE - VERSION - -[flake8] -max-line-length = 120 -extend-ignore = E203, W503 -exclude = - .git, - __pycache__, - docs/source/conf.py, - old, - build, - dist, - .venv, - codeseeder.out, - bundle - -[mypy] -python_version = 3.7 -strict = True -ignore_missing_imports = True -allow_untyped_decorators = True -exclude = - codeseeder.out/|example/|tests/ -warn_unused_ignores = False \ No newline at end of file diff --git a/modules/sagemaker/sagemaker-notebook/app.py b/modules/sagemaker/sagemaker-notebook/app.py index e0879903..8a64f869 100644 --- a/modules/sagemaker/sagemaker-notebook/app.py +++ b/modules/sagemaker/sagemaker-notebook/app.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 """Create a Sagemaker Model Stack.""" + import aws_cdk as cdk from sagemaker_notebook.settings import ApplicationSettings diff --git a/modules/sagemaker/sagemaker-notebook/coverage.ini b/modules/sagemaker/sagemaker-notebook/coverage.ini deleted file mode 100644 index c3878739..00000000 --- a/modules/sagemaker/sagemaker-notebook/coverage.ini +++ /dev/null @@ -1,3 +0,0 @@ -[run] -omit = - tests/* \ No newline at end of file diff --git a/modules/sagemaker/sagemaker-notebook/pyproject.toml b/modules/sagemaker/sagemaker-notebook/pyproject.toml index 1f856efe..2596b06b 100644 --- a/modules/sagemaker/sagemaker-notebook/pyproject.toml +++ b/modules/sagemaker/sagemaker-notebook/pyproject.toml @@ -1,35 +1,41 @@ -[tool.black] +[tool.ruff] +exclude = [ + ".eggs", + ".git", + ".hg", + ".mypy_cache", + ".ruff_cache", + ".tox", + ".venv", + "_build", + "buck-out", + "build", + "dist", + "codeseeder", +] line-length = 120 -target-version = ["py36", "py37", "py38"] -exclude = ''' -/( - \.eggs - | \.git - | \.hg - | \.mypy_cache - | \.tox - | \.venv - | \.env - | _build - | buck-out - | build - | dist - | codeseeder.out -)/ -''' +target-version = "py38" -[tool.isort] -multi_line_output = 3 -include_trailing_comma = true -force_grid_wrap = 0 -use_parentheses = true -ensure_newline_before_comments = true -line_length = 120 -py_version = 36 -skip_gitignore = false +[tool.ruff.lint] +select = ["F", "I", "E", "W"] +fixable = ["ALL"] + +[tool.mypy] +python_version = "3.8" +strict = true +ignore_missing_imports = true +disallow_untyped_decorators = false +exclude = "codeseeder.out/|example/|tests/|.venv" +warn_unused_ignores = false [tool.pytest.ini_options] -addopts = "-v --cov=. --cov-report term --cov-config=coverage.ini --cov-fail-under=80" +addopts = "-v --cov=. --cov-report term" pythonpath = [ "." -] \ No newline at end of file +] + +[tool.coverage.run] +omit = ["tests/*"] + +[tool.coverage.report] +fail_under = 80 diff --git a/modules/sagemaker/sagemaker-notebook/setup.cfg b/modules/sagemaker/sagemaker-notebook/setup.cfg deleted file mode 100644 index 99bdc5b7..00000000 --- a/modules/sagemaker/sagemaker-notebook/setup.cfg +++ /dev/null @@ -1,28 +0,0 @@ -[metadata] -license_files = - LICENSE - NOTICE - VERSION - -[flake8] -max-line-length = 120 -extend-ignore = E203, W503 -exclude = - .git, - __pycache__, - docs/source/conf.py, - old, - build, - dist, - .venv, - codeseeder.out, - bundle - -[mypy] -python_version = 3.7 -strict = True -ignore_missing_imports = True -allow_untyped_decorators = True -exclude = - codeseeder.out/|example/|tests/|.venv -warn_unused_ignores = False \ No newline at end of file diff --git a/modules/sagemaker/sagemaker-studio/coverage.ini b/modules/sagemaker/sagemaker-studio/coverage.ini deleted file mode 100644 index c3878739..00000000 --- a/modules/sagemaker/sagemaker-studio/coverage.ini +++ /dev/null @@ -1,3 +0,0 @@ -[run] -omit = - tests/* \ No newline at end of file diff --git a/modules/sagemaker/sagemaker-studio/pyproject.toml b/modules/sagemaker/sagemaker-studio/pyproject.toml index 361877d5..5d866daa 100644 --- a/modules/sagemaker/sagemaker-studio/pyproject.toml +++ b/modules/sagemaker/sagemaker-studio/pyproject.toml @@ -1,35 +1,41 @@ -[tool.black] +[tool.ruff] +exclude = [ + ".eggs", + ".git", + ".hg", + ".mypy_cache", + ".ruff_cache", + ".tox", + ".venv", + "_build", + "buck-out", + "build", + "dist", + "codeseeder", +] line-length = 120 -target-version = ["py36", "py37", "py38", "py39"] -exclude = ''' -/( - \.eggs - | \.git - | \.hg - | \.mypy_cache - | \.tox - | \.venv - | \.env - | _build - | buck-out - | build - | dist - | codeseeder.out -)/ -''' +target-version = "py38" -[tool.isort] -multi_line_output = 3 -include_trailing_comma = true -force_grid_wrap = 0 -use_parentheses = true -ensure_newline_before_comments = true -line_length = 120 -py_version = 38 -skip_gitignore = false +[tool.ruff.lint] +select = ["F", "I", "E", "W"] +fixable = ["ALL"] + +[tool.mypy] +python_version = "3.8" +strict = true +ignore_missing_imports = true +disallow_untyped_decorators = false +exclude = "codeseeder.out/|example/|tests/|functions/sm_studio/enable_sm_projects/|scripts/" +warn_unused_ignores = false [tool.pytest.ini_options] -addopts = "-v --cov=. --cov-report term --cov-config=coverage.ini --cov-fail-under=80" +addopts = "-v --cov=. --cov-report term" pythonpath = [ "." -] \ No newline at end of file +] + +[tool.coverage.run] +omit = ["tests/*"] + +[tool.coverage.report] +fail_under = 80 diff --git a/modules/sagemaker/sagemaker-studio/setup.cfg b/modules/sagemaker/sagemaker-studio/setup.cfg deleted file mode 100644 index 8995857f..00000000 --- a/modules/sagemaker/sagemaker-studio/setup.cfg +++ /dev/null @@ -1,29 +0,0 @@ -[metadata] -license_files = - LICENSE - NOTICE - VERSION - -[flake8] -max-line-length = 120 -extend-ignore = E203, W503 -exclude = - .git, - __pycache__, - docs/source/conf.py, - old, - build, - dist, - .venv, - codeseeder.out, - bundle - tests - -[mypy] -python_version = 3.7 -strict = True -ignore_missing_imports = True -allow_untyped_decorators = True -exclude = - codeseeder.out/|example/|tests/|functions/sm_studio/enable_sm_projects/|scripts/ -warn_unused_ignores = False diff --git a/modules/sagemaker/sagemaker-studio/stack.py b/modules/sagemaker/sagemaker-studio/stack.py index 3ac796f1..f0be1e9e 100644 --- a/modules/sagemaker/sagemaker-studio/stack.py +++ b/modules/sagemaker/sagemaker-studio/stack.py @@ -174,15 +174,15 @@ def sagemaker_studio_domain( """ custom_kernel_settings = {} if app_image_config_name is not None and image_name is not None: - custom_kernel_settings[ - "kernel_gateway_app_settings" - ] = sagemaker.CfnDomain.KernelGatewayAppSettingsProperty( - custom_images=[ - sagemaker.CfnDomain.CustomImageProperty( - app_image_config_name=app_image_config_name, - image_name=image_name, - ), - ], + custom_kernel_settings["kernel_gateway_app_settings"] = ( + sagemaker.CfnDomain.KernelGatewayAppSettingsProperty( + custom_images=[ + sagemaker.CfnDomain.CustomImageProperty( + app_image_config_name=app_image_config_name, + image_name=image_name, + ), + ], + ) ) return sagemaker.CfnDomain( diff --git a/modules/sagemaker/sagemaker-templates-service-catalog/coverage.ini b/modules/sagemaker/sagemaker-templates-service-catalog/coverage.ini deleted file mode 100644 index c3878739..00000000 --- a/modules/sagemaker/sagemaker-templates-service-catalog/coverage.ini +++ /dev/null @@ -1,3 +0,0 @@ -[run] -omit = - tests/* \ No newline at end of file diff --git a/modules/sagemaker/sagemaker-templates-service-catalog/pyproject.toml b/modules/sagemaker/sagemaker-templates-service-catalog/pyproject.toml index d03cfa02..f674942b 100644 --- a/modules/sagemaker/sagemaker-templates-service-catalog/pyproject.toml +++ b/modules/sagemaker/sagemaker-templates-service-catalog/pyproject.toml @@ -1,38 +1,47 @@ -[tool.black] +[tool.ruff] line-length = 120 -target-version = ["py36", "py37", "py38"] -exclude = ''' -/( - \.eggs - | \.git - | \.hg - | \.mypy_cache - | \.tox - | \.venv - | \.env - | _build - | buck-out - | build - | dist - | codeseeder.out -)/ -''' +target-version = "py38" +extend-include = ["*.ipynb"] -[tool.isort] -multi_line_output = 3 -include_trailing_comma = true -force_grid_wrap = 0 -use_parentheses = true -ensure_newline_before_comments = true -line_length = 120 -py_version = 36 -skip_gitignore = false +exclude = [ + ".eggs", + ".git", + ".hg", + ".mypy_cache", + ".ruff_cache", + ".tox", + ".env", + ".venv", + "_build", + "buck-out", + "build", + "dist", + "codeseeder.out", +] + +[tool.ruff.lint] +select = ["F", "I", "E", "W"] +fixable = ["ALL"] + +[tool.mypy] +python_version = "3.8" +strict = true +ignore_missing_imports = true +disallow_untyped_decorators = false +exclude = "codeseeder.out/|example/|tests/|.venv" +warn_unused_ignores = false [tool.pytest.ini_options] -addopts = "-v --cov=. --cov-report term --cov-config=coverage.ini --cov-fail-under=80" +addopts = "-v --cov=. --cov-report term" pythonpath = [ "." ] testpaths = [ "tests" -] \ No newline at end of file +] + +[tool.coverage.run] +omit = ["tests/*"] + +[tool.coverage.report] +fail_under = 80 diff --git a/modules/sagemaker/sagemaker-templates-service-catalog/setup.cfg b/modules/sagemaker/sagemaker-templates-service-catalog/setup.cfg deleted file mode 100644 index 6136e2bb..00000000 --- a/modules/sagemaker/sagemaker-templates-service-catalog/setup.cfg +++ /dev/null @@ -1,28 +0,0 @@ -[metadata] -license_files = - LICENSE - NOTICE - VERSION - -[flake8] -max-line-length = 120 -extend-ignore = E203, W503 -exclude = - .git, - __pycache__, - docs/source/conf.py, - old, - build, - dist, - .venv, - codeseeder.out, - bundle - -[mypy] -python_version = 3.7 -strict = True -ignore_missing_imports = True -allow_untyped_decorators = True -exclude = - codeseeder.out/|example/|tests/ -warn_unused_ignores = False \ No newline at end of file diff --git a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/ml_pipelines/_utils.py b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/ml_pipelines/_utils.py index 3c505204..77ee101b 100644 --- a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/ml_pipelines/_utils.py +++ b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/ml_pipelines/_utils.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 """Provides utilities for SageMaker Pipeline CLI.""" + from __future__ import absolute_import import ast diff --git a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/ml_pipelines/get_pipeline_definition.py b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/ml_pipelines/get_pipeline_definition.py index 16fb6899..db0aac63 100644 --- a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/ml_pipelines/get_pipeline_definition.py +++ b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/ml_pipelines/get_pipeline_definition.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 """A CLI to get pipeline definitions from pipeline modules.""" + from __future__ import absolute_import import argparse diff --git a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/ml_pipelines/run_pipeline.py b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/ml_pipelines/run_pipeline.py index 523a7c37..bc9fa3c7 100644 --- a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/ml_pipelines/run_pipeline.py +++ b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/ml_pipelines/run_pipeline.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 """A CLI to create or update and run pipelines.""" + from __future__ import absolute_import import argparse diff --git a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/ml_pipelines/training/pipeline.py b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/ml_pipelines/training/pipeline.py index 48da0d8e..7d753439 100644 --- a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/ml_pipelines/training/pipeline.py +++ b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/ml_pipelines/training/pipeline.py @@ -11,6 +11,7 @@ Implements a get_pipeline(**kwargs) method. """ + import logging from typing import Any, Optional diff --git a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/notebooks/sm_pipelines_runbook.ipynb b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/notebooks/sm_pipelines_runbook.ipynb index bbc0902e..932365d8 100644 --- a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/notebooks/sm_pipelines_runbook.ipynb +++ b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/notebooks/sm_pipelines_runbook.ipynb @@ -223,7 +223,7 @@ " ProcessingOutput(output_name=\"validation\", source=\"/opt/ml/processing/validation\"),\n", " ProcessingOutput(output_name=\"test\", source=\"/opt/ml/processing/test\"),\n", " ],\n", - " code=\"source_scripts/preprocessing/prepare_abalone_data/main.py\", # we must figure out this path to get it from step_source directory\n", + " code=\"source_scripts/preprocessing/prepare_abalone_data/main.py\", # we must figure out this path to get it from step_source directory # noqa: E501\n", " job_arguments=[\"--input-data\", input_data],\n", ")" ] diff --git a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/source_scripts/evaluate/evaluate_xgboost/main.py b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/source_scripts/evaluate/evaluate_xgboost/main.py index 1d3cf199..5269f891 100644 --- a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/source_scripts/evaluate/evaluate_xgboost/main.py +++ b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/source_scripts/evaluate/evaluate_xgboost/main.py @@ -16,6 +16,7 @@ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """Evaluation script for measuring mean squared error.""" + import json import logging import pathlib diff --git a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/source_scripts/preprocessing/prepare_abalone_data/main.py b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/source_scripts/preprocessing/prepare_abalone_data/main.py index 5f60c85a..a94fc2e5 100644 --- a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/source_scripts/preprocessing/prepare_abalone_data/main.py +++ b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/build_app/source_scripts/preprocessing/prepare_abalone_data/main.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 """Feature engineers the abalone dataset.""" + import argparse import logging import os diff --git a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/deploy_app/config/config_mux.py b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/deploy_app/config/config_mux.py index 53b4d8b1..92726970 100644 --- a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/deploy_app/config/config_mux.py +++ b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/deploy_app/config/config_mux.py @@ -2,12 +2,12 @@ # SPDX-License-Identifier: Apache-2.0 from abc import ABCMeta +from dataclasses import dataclass from pathlib import Path from typing import Any import constructs from aws_cdk import Stack, Stage -from dataclasses import dataclass from yamldataclassconfig.config import YamlDataClassConfig DEFAULT_STAGE_NAME = "dev" diff --git a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/deploy_app/deploy_endpoint/deploy_endpoint_stack.py b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/deploy_app/deploy_endpoint/deploy_endpoint_stack.py index 4950b2da..c5495473 100644 --- a/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/deploy_app/deploy_endpoint/deploy_endpoint_stack.py +++ b/modules/sagemaker/sagemaker-templates-service-catalog/templates/multi_account_basic/seed_code/deploy_app/deploy_endpoint/deploy_endpoint_stack.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 +from dataclasses import dataclass from datetime import datetime, timezone from pathlib import Path from typing import Any @@ -19,7 +20,6 @@ PROJECT_ID, PROJECT_NAME, ) -from dataclasses import dataclass from yamldataclassconfig import create_file_path_field from .get_approved_package import get_approved_package diff --git a/requirements-dev.txt b/requirements-dev.txt index ba7d81ec..8234fd49 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -18,3 +18,4 @@ types-setuptools~=57.4.17 wheel~=0.37.1 cdk-nag==2.12.29 click==8.0.2 +ruff~=0.3.0 diff --git a/scripts/fix.sh b/scripts/fix.sh index 38c41fb7..64b666be 100755 --- a/scripts/fix.sh +++ b/scripts/fix.sh @@ -47,8 +47,8 @@ echo "Fixing: ${FIX_PATH}, Language: ${LANGUAGE}" if [[ $LANGUAGE == "python" ]]; then echo "Running isort, black" - isort . - black . + ruff format . + ruff check --fix . elif [[ $LANGUAGE == "typescript" ]]; then echo "Running prettier" npx prettier --write . diff --git a/scripts/validate.sh b/scripts/validate.sh index 176cdd5f..32044a6b 100755 --- a/scripts/validate.sh +++ b/scripts/validate.sh @@ -52,9 +52,9 @@ echo "Validating: ${VALIDATE_PATH}, Language: ${LANGUAGE}" echo "Validating Formatting" if [[ $LANGUAGE == "python" ]]; then - echo "Checking isort, black" - isort --check . - black --check . + echo "Checking ruff" + ruff format --check . + ruff check . elif [[ $LANGUAGE == "typescript" ]]; then echo "Checking prettier" npx prettier -c . @@ -66,9 +66,8 @@ fi if [[ $SKIP_STATIC_CHECKS == "false" ]]; then echo "Validating Static Checks" if [[ $LANGUAGE == "python" ]]; then - echo "Checking flake8, mypy" - flake8 . - mypy --ignore-missing-imports . + echo "Checking mypy" + mypy . elif [[ $LANGUAGE == "typescript" ]]; then echo "Checking eslint" npx eslint . --ext .js,.jsx,.ts,.tsx