Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP python 3.12 upgrade #657

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ orbs:
jobs:
install_and_update_dependencies:
machine:
image: ubuntu-2204:2023.10.1
image: ubuntu-2404:2024.05.1
steps:
- checkout
- restore_cache:
Expand All @@ -23,6 +23,7 @@ jobs:
pkg-manager: pipenv
args: --dev
- run: pipenv run pipenv check # before save_cache so an insecure cache is never saved
- run: pipenv run pipenv verify
- save_cache:
when: on_success
paths:
Expand All @@ -31,7 +32,7 @@ jobs:

run-tests:
machine:
image: ubuntu-2204:2023.10.1
image: ubuntu-2404:2024.05.1
steps:
- checkout
- attach_workspace:
Expand Down Expand Up @@ -69,7 +70,7 @@ jobs:

deploy:
machine:
image: ubuntu-2204:2022.10.2
image: ubuntu-2404:2024.05.1
parameters:
dc-environment:
type: enum
Expand Down
9 changes: 5 additions & 4 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name = "pypi"

[packages]
# Matches the Node version of the CDK in package.json
"aws-cdk-lib" = ">=2.105.0,< 2.106.0"
"aws-cdk-lib" = "<3.0.0,>=2.162.1"
"aws_cdk.aws_lambda_python_alpha" = ">= 2.0.0alpha1"
"aws-cdk.aws-kinesisfirehose-alpha" = ">= 2.104.0a0"
"aws-cdk.aws-kinesisfirehose-destinations-alpha" = ">= 2.104.0a0"
Expand All @@ -15,9 +15,10 @@ cachetools = "==v5.2.0"
wheel = "==0.38.4"
urllib3 = "==1.26.19"
dc-logging-utils = {file = "."}
attrs = "==23.1.0"

[dev-packages]
boto3 = ">=1.20,<1.30"
boto3 = "==1.35.*"
mypy-boto3-organizations = "*"
mypy-boto3-ssm = "1.26.97"
ruff = "==0.1.8"
Expand All @@ -31,9 +32,9 @@ psycopg = {extras = ["binary"], version = "*"}
tqdm = "*"

[requires]
python_version = "3.10"
python_version = "3.12"

[scripts]
ruff-check = "ruff ."
ruff-check = "ruff check ."
ruff-format-check = "ruff format --check ."
pytest = "pytest --ruff --junitxml=test-results/junit.xml --cov=dc_logging_client"
118 changes: 65 additions & 53 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The logging client provides four things:

Docker is required on the local system to run test.

* Install Python dependencies: `pipenv install --dev`
* Install Python dependencies: `pipenv sync --dev`
* Run the test suite: `pytest`
* Run lint checks: `ruff .`
* Auto-format: `ruff format`
Expand All @@ -35,8 +35,7 @@ Install the desired version using pip or pipenv.
For pipenv, especially on projects deployed on AWS Lambda, it's advised to use
the `zip` package from the release page:

`pipenv install https://github.
com/DemocracyClub/dc_logging/archive/refs/tags/[VERSION].zip`
`pipenv install https://github.com/DemocracyClub/dc_logging/archive/refs/tags/[VERSION].zip`


### Using the library
Expand Down
4 changes: 2 additions & 2 deletions dc_logging_aws/stacks/dc_logs_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def create_lambda_function(self, cls):
client_layer = lambda_python.PythonLayerVersion(
self,
"logging_client_layer",
compatible_runtimes=[aws_lambda.Runtime.PYTHON_3_10],
compatible_runtimes=[aws_lambda.Runtime.PYTHON_3_12],
entry="./dc_logging_client",
)

Expand All @@ -205,7 +205,7 @@ def create_lambda_function(self, cls):
function_name=f"ingest-{cls.stream_name}-{self.dc_environment}",
entry="./dc_logging_aws/lambdas/ingest",
index="handler.py",
runtime=aws_lambda.Runtime.PYTHON_3_10,
runtime=aws_lambda.Runtime.PYTHON_3_12,
timeout=Duration.minutes(2),
environment={
"STREAM_NAME": cls.stream_name,
Expand Down
4 changes: 4 additions & 0 deletions dc_logging_client/log_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def log(self, data: BaseLogEntry):
logger.warning(
f"Failed to log `{data.as_log_line()}`. Got `{response}`"
)
if response.get("FunctionError"):
logger.warning(
f"Failed to log `{data.as_log_line()}`. Got `{response["Payload"].read().decode('utf-8')}`"
)


class DCWidePostcodeLoggingClient(BaseLoggingClient):
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading