From db710adf042727610a2b1c18273afc6f5980e19d Mon Sep 17 00:00:00 2001 From: Luna Stadler Date: Thu, 15 Feb 2024 11:51:54 +0100 Subject: [PATCH 1/4] Update Python version to 3.12 Now supported by `fastapi`, so let's use it. --- .github/workflows/python.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 4efa1c1..30518a2 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.10'] + python-version: ['3.12'] steps: - uses: actions/checkout@v2 diff --git a/Dockerfile b/Dockerfile index 27cd987..bca66c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.10 +FROM python:3.12 WORKDIR /app From f4507cbb3239e798286fb96eaa47fef908cd2808 Mon Sep 17 00:00:00 2001 From: Luna Stadler Date: Thu, 15 Feb 2024 14:43:01 +0100 Subject: [PATCH 2/4] Bump dependencies to support Python 3.12 These had C parts that did not compile with Python 3.12 before, with the updates they now do. --- requirements.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4079606..018fd27 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,9 +11,9 @@ click==8.1.3 elastic-transport==8.4.0 elasticsearch==8.6.1 fastapi==0.109.2 -frozenlist==1.3.3 +frozenlist==1.4.1 h11==0.14.0 -httptools==0.5.0 +httptools==0.6.1 idna==3.4 itsdangerous==2.1.2 Jinja2==3.1.3 @@ -26,8 +26,8 @@ sniffio==1.3.0 starlette==0.36.3 typing_extensions==4.9.0 urllib3==1.26.18 -uvicorn==0.20.0 -uvloop==0.17.0 +uvicorn==0.27.1 +uvloop==0.19.0 websockets==10.4 Werkzeug==3.0.1 -yarl==1.8.2 +yarl==1.9.4 From 3cc4e7e4ae9ce631c87cc608fbe0ecf84c504e2f Mon Sep 17 00:00:00 2001 From: Luna Stadler Date: Thu, 15 Feb 2024 14:45:29 +0100 Subject: [PATCH 3/4] Update GitHub actions to their latest versions --- .github/workflows/docker-image.yml | 8 ++++---- .github/workflows/python.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 06448d1..32c6ccc 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -20,11 +20,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Log in to the Container registry if: github.event_name != 'pull_request' - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -32,12 +32,12 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push Docker image - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . push: ${{ github.event_name != 'pull_request' }} diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 30518a2..9bf8d82 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -18,9 +18,9 @@ jobs: python-version: ['3.12'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies From 136a8598e6319773eaa8f76b8ec6302a05264ef5 Mon Sep 17 00:00:00 2001 From: Luna Stadler Date: Sat, 24 Feb 2024 20:58:43 +0100 Subject: [PATCH 4/4] Fix new flake8 lint errors They seem to only happen with Python 3.12, which I don't have locally yet and I am not seeing these lint errors locally either. --- es_stream_logs.py | 4 ++-- tinygraph.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/es_stream_logs.py b/es_stream_logs.py index 6eb05be..2a6ff3b 100644 --- a/es_stream_logs.py +++ b/es_stream_logs.py @@ -399,7 +399,7 @@ async def aggregation_svg(es, request: Request, query: Query): bucket_data['sub_buckets'].insert(0, { 'key': f"no value for {query.aggregation_terms}", 'count': amount, - 'percentage': f"{(amount/max_count) * 100:.2f}%", + 'percentage': f"{(amount / max_count) * 100:.2f}%", 'height': int((amount / max_count) * 100), 'offset_y': offset_y - int((amount / max_count) * 100), 'color': '#dddddd', @@ -418,7 +418,7 @@ async def aggregation_svg(es, request: Request, query: Query): continue pos_y = 100 - scale_percentile.map(value) if width_scale: - percentile_lines[percentile] += f" {width_scale.map(bucket_data['pos_x']+bucket_width/2)},{pos_y/100 * height}" + percentile_lines[percentile] += f" {width_scale.map(bucket_data['pos_x'] + bucket_width / 2)},{pos_y / 100 * height}" percentile = float(percentile) pretty_percentile = int(percentile) if percentile.is_integer() else percentile diff --git a/tinygraph.py b/tinygraph.py index 858810f..9a893d4 100644 --- a/tinygraph.py +++ b/tinygraph.py @@ -91,5 +91,5 @@ def pretty_duration(duration_s: int): elif duration_s < 24 * HOUR: fmt = f"{duration_s // HOUR}h" else: - fmt = f"{duration_s // (24*HOUR)}d" + fmt = f"{duration_s // (24 * HOUR)}d" return fmt