Skip to content

Upgrade paasta to python 3.10 #4065

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

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from
Draft
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
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
toxenv:
- py38-linux
- py310-linux
- docs
- mypy
- tests
Expand All @@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: '3.10'
- run: python -m pip install --upgrade pip
- run: pip install -r requirements-gha.txt
- run: tox -e ${{ matrix.toxenv }}
Expand All @@ -40,7 +40,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: '3.10'
- run: python -m pip install --upgrade pip virtualenv
- run: curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
- run: python -m pip install --upgrade pip
Expand All @@ -51,12 +51,12 @@ jobs:
strategy:
fail-fast: false
matrix:
dist: [bionic, jammy, noble]
dist: [jammy, noble]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: '3.10'
- run: sudo apt-get update
- run: sudo apt-get install -yq devscripts
- run: make itest_${{ matrix.dist }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ jobs:
fail-fast: false
matrix:
toxenv:
- py38-linux,docs,mypy,tests
- py310-linux,docs,mypy,tests
- general_itests
env:
DOCKER_REGISTRY: ""
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: '3.10'
- run: python -m pip install --upgrade pip
- run: pip install -r requirements-gha.txt
- run: tox -e ${{ matrix.toxenv }}
Expand All @@ -35,7 +35,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: '3.10'
- run: pip install build
# this will create both a source distribution and a wheel
- run: python -m build
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
default_language_version:
python: python3.8
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
Expand Down Expand Up @@ -42,7 +42,7 @@ repos:
rev: 22.3.0
hooks:
- id: black
args: ['--target-version', 'py38']
args: ['--target-version', 'py310']
exclude: ^paasta_tools/paastaapi
- repo: https://github.com/PyCQA/flake8
rev: 3.7.7
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.8"
python: "3.10"
# You can also specify other tool versions:
# nodejs: "20"
# rust: "1.70"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ dev-api: .tox/py38-linux
.paasta/bin/tox -e dev-api

.paasta/bin/activate: requirements.txt requirements-dev.txt
test -d .paasta/bin/activate || virtualenv -p python3.8 .paasta
test -d .paasta/bin/activate || virtualenv -p python3.10 .paasta
.paasta/bin/pip install -r requirements-bootstrap.txt
.paasta/bin/pip install -U tox==3.28.0
touch .paasta/bin/activate
Expand Down
4 changes: 2 additions & 2 deletions contrib/python-k8s-client.diff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- a/debian/paasta/opt/venvs/paasta/lib/python3.8/site-packages/kubernetes/client/api_client.py
+++ b/debian/paasta/opt/venvs/paasta/lib/python3.8/site-packages/kubernetes/client/api_client.py
--- a/debian/paasta/opt/venvs/paasta/lib/python3.10/site-packages/kubernetes/client/api_client.py
+++ b/debian/paasta/opt/venvs/paasta/lib/python3.10/site-packages/kubernetes/client/api_client.py
@@ -629,7 +629,7 @@
'get_real_child_model'):
return data
Expand Down
4 changes: 2 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ Source: paasta-tools
Section: python
Priority: optional
Maintainer: Compute Infrastructure <[email protected]>
Build-Depends: debhelper (>= 7), python3.8, dh-virtualenv
Build-Depends: debhelper (>= 7), python3.10, dh-virtualenv
Standards-Version: 3.8.3

Package: paasta-tools
Architecture: any
Depends: python3.8, ${shlibs:Depends}, ${misc:Depends}
Depends: python3.10, ${shlibs:Depends}, ${misc:Depends}
Description: CLI tools for PaaSTA
Conflicts: service-deployment-tools
4 changes: 2 additions & 2 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ DH_VIRTUALENV_INSTALL_ROOT=/opt/venvs
DH_VENV_DIR=debian/$(PACKAGE)$(DH_VIRTUALENV_INSTALL_ROOT)/$(PACKAGE)
override_dh_virtualenv:
dh_virtualenv \
--python=/usr/bin/python3.8 \
--python=/usr/bin/python3.10 \
--preinstall no-manylinux1 \
--preinstall=-rrequirements-bootstrap.txt
cp yelp_package/gopath/paasta_go $(DH_VENV_DIR)/bin/paasta_go
@echo patching k8s client lib
patch $(DH_VENV_DIR)/lib/python3.8/site-packages/kubernetes/client/api_client.py contrib/python-k8s-client.diff
patch $(DH_VENV_DIR)/lib/python3.10/site-packages/kubernetes/client/api_client.py contrib/python-k8s-client.diff

override_dh_shlibdeps:
# pylibmc manylinux bundle libraries fail unless this is passed.
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[mypy]
python_version = 3.8
python_version = 3.10
check_untyped_defs = False
warn_incomplete_stub = True
follow_imports = silent
Expand Down
5 changes: 3 additions & 2 deletions paasta_tools/api/tweens/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,16 @@ def __call__(self, request: Request) -> Response:
)
return self.handler(request)

@cachetools.func.ttl_cache(maxsize=AUTH_CACHE_SIZE, ttl=AUTH_CACHE_TTL)
@cachetools.func.ttl_cache(maxsize=AUTH_CACHE_SIZE, ttl=AUTH_CACHE_TTL) # type: ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think that we might be able to get rid of this ignore if we install types-cachetools in requirements-dev

def is_request_authorized(
self,
path: str,
token: str,
method: str,
service: Optional[str],
) -> AuthorizationOutcome:
"""Check if API request is authorized
"""
Check if API request is authorized

:param str path: API path
:param str token: authentication token
Expand Down
4 changes: 2 additions & 2 deletions paasta_tools/cli/cmds/local_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,12 +977,12 @@ def run_docker_container(
# First try to write the file as a string
# This is for text like config files
with open(temp_secret_filename, "w") as f:
f.write(secret_content)
f.write(secret_content) # type: ignore
except TypeError:
# If that fails, try to write it as bytes
# This is for binary files like TLS keys
with open(temp_secret_filename, "wb") as fb:
fb.write(secret_content)
fb.write(secret_content) # type: ignore
Comment on lines +980 to +985
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious: why were these ignored?


# Append this to the list of volumes passed to docker run
volumes.append(f"{temp_secret_filename}:{container_mount_path}:ro")
Expand Down
2 changes: 1 addition & 1 deletion paasta_tools/contrib/bounce_log_latency_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3.8
#!/usr/bin/env python3.10
import itertools
import json
import sys
Expand Down
28 changes: 14 additions & 14 deletions paasta_tools/contrib/ide_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ def install_vscode_support() -> None:
"python": "${workspaceFolder}/.paasta/bin/python",
"program": "${workspaceFolder}/.paasta/bin/tox",
"subProcess": True,
"args": ["-e", "py38-linux,docs,mypy,tests"],
"args": ["-e", "py310-linux,docs,mypy,tests"],
},
{
"name": "paasta cli",
"cwd": "${workspaceFolder}",
"python": "${workspaceFolder}/.tox/py38-linux/bin/python",
"python": "${workspaceFolder}/.tox/py310-linux/bin/python",
"type": "python",
"request": "launch",
"module": "paasta_tools.cli.cli",
},
{
"name": "paasta rollback",
"cwd": "${workspaceFolder}",
"python": "${workspaceFolder}/.tox/py38-linux/bin/python",
"python": "${workspaceFolder}/.tox/py310-linux/bin/python",
"type": "python",
"request": "launch",
"module": "paasta_tools.cli.cli",
Expand All @@ -83,7 +83,7 @@ def install_vscode_support() -> None:
{
"name": "paasta mark-for-deployment",
"cwd": "${workspaceFolder}",
"python": "${workspaceFolder}/.tox/py38-linux/bin/python",
"python": "${workspaceFolder}/.tox/py310-linux/bin/python",
"type": "python",
"request": "launch",
"module": "paasta_tools.cli.cli",
Expand All @@ -101,7 +101,7 @@ def install_vscode_support() -> None:
{
"name": "paasta status",
"cwd": "${workspaceFolder}",
"python": "${workspaceFolder}/.tox/py38-linux/bin/python",
"python": "${workspaceFolder}/.tox/py310-linux/bin/python",
"type": "python",
"request": "launch",
"module": "paasta_tools.cli.cli",
Expand All @@ -118,7 +118,7 @@ def install_vscode_support() -> None:
{
"name": "paasta playground",
"cwd": "${workspaceFolder}",
"python": "${workspaceFolder}/.tox/py38-linux/bin/python",
"python": "${workspaceFolder}/.tox/py310-linux/bin/python",
"type": "python",
"request": "launch",
"module": "paasta_tools.cli.cli",
Expand All @@ -138,7 +138,7 @@ def install_vscode_support() -> None:
{
"name": "paasta status playground",
"cwd": "${workspaceFolder}",
"python": "${workspaceFolder}/.tox/py38-linux/bin/python",
"python": "${workspaceFolder}/.tox/py310-linux/bin/python",
"type": "python",
"request": "launch",
"module": "paasta_tools.cli.cli",
Expand All @@ -157,7 +157,7 @@ def install_vscode_support() -> None:
{
"name": "paasta logs",
"cwd": "${workspaceFolder}",
"python": "${workspaceFolder}/.tox/py38-linux/bin/python",
"python": "${workspaceFolder}/.tox/py310-linux/bin/python",
"type": "python",
"request": "launch",
"module": "paasta_tools.cli.cli",
Expand All @@ -175,7 +175,7 @@ def install_vscode_support() -> None:
"name": "paasta validate",
# This command has to be ran from inside the service repo in yelpsoa-configs
"cwd": "${userHome}/pg/yelpsoa-configs/",
"python": "${workspaceFolder}/.tox/py38-linux/bin/python",
"python": "${workspaceFolder}/.tox/py310-linux/bin/python",
"type": "python",
"request": "launch",
"module": "paasta_tools.cli.cli",
Expand All @@ -184,10 +184,10 @@ def install_vscode_support() -> None:
{
# 1) Follow step 1 in "Running the PaaSTA HTTP API Locally" wiki
# 2) Run this "paasta API" test to debug paasta API
# 3) Run client command, e.g. PAASTA_SYSTEM_CONFIG_DIR=./etc_paasta_for_development/ .tox/py38-linux/bin/python paasta_tools/cli/cli.py status --clusters norcal-devc --service katamari_test_service
# 3) Run client command, e.g. PAASTA_SYSTEM_CONFIG_DIR=./etc_paasta_for_development/ .tox/py310-linux/bin/python paasta_tools/cli/cli.py status --clusters norcal-devc --service katamari_test_service
"name": "paasta API",
"cwd": "${workspaceFolder}",
"python": "${workspaceFolder}/.tox/py38-linux/bin/python",
"python": "${workspaceFolder}/.tox/py310-linux/bin/python",
"type": "python",
"request": "launch",
"module": "paasta_tools.run-paasta-api-in-dev-mode",
Expand All @@ -203,7 +203,7 @@ def install_vscode_support() -> None:
{
"name": "paasta API playground",
"cwd": "${workspaceFolder}",
"python": "${workspaceFolder}/.tox/py38-linux/bin/python",
"python": "${workspaceFolder}/.tox/py310-linux/bin/python",
"type": "python",
"request": "launch",
"module": "paasta_tools.run-paasta-api-playground",
Expand All @@ -221,7 +221,7 @@ def install_vscode_support() -> None:
{
"name": "Run setup k8s job in playground",
"cwd": "${workspaceFolder}",
"python": "${workspaceFolder}/.tox/py38-linux/bin/python",
"python": "${workspaceFolder}/.tox/py310-linux/bin/python",
"type": "python",
"request": "launch",
"module": "paasta_tools.setup_kubernetes_job",
Expand All @@ -244,7 +244,7 @@ def install_vscode_support() -> None:
{
"name": "Generate deployments.json in playground",
"cwd": "${workspaceFolder}",
"python": "${workspaceFolder}/.tox/py38-linux/bin/python",
"python": "${workspaceFolder}/.tox/py310-linux/bin/python",
"type": "python",
"request": "launch",
"module": "paasta_tools.generate_deployments_for_service",
Expand Down
2 changes: 1 addition & 1 deletion paasta_tools/contrib/mock_patch_checker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3.8
#!/usr/bin/env python3.10
import ast
import sys

Expand Down
2 changes: 1 addition & 1 deletion paasta_tools/contrib/render_template.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3.8
#!/usr/bin/env python3.10
import argparse
import os
import re
Expand Down
2 changes: 1 addition & 1 deletion paasta_tools/contrib/shared_ip_check.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3.8
#!/usr/bin/env python3.10
import sys
from collections import defaultdict

Expand Down
20 changes: 10 additions & 10 deletions paasta_tools/instance/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ async def kubernetes_status_v2(
kube_client, job_config, job_config.get_kubernetes_namespace()
)
)
tasks.append(autoscaling_task)
tasks.append(autoscaling_task) # type: ignore
else:
autoscaling_task = None

Expand All @@ -653,7 +653,7 @@ async def kubernetes_status_v2(
namespaces=relevant_namespaces,
)
)
tasks.append(pods_task)
tasks.append(pods_task) # type: ignore

service_namespace_config = kubernetes_tools.load_service_namespace_config(
service=service,
Expand All @@ -674,9 +674,9 @@ async def kubernetes_status_v2(
)
)
backends_task = asyncio.create_task(
get_backends_from_mesh_status(mesh_status_task)
get_backends_from_mesh_status(mesh_status_task) # type: ignore
)
tasks.extend([mesh_status_task, backends_task])
tasks.extend([mesh_status_task, backends_task]) # type: ignore
else:
mesh_status_task = None
backends_task = None
Expand All @@ -685,7 +685,7 @@ async def kubernetes_status_v2(
pod_status_by_sha_and_readiness_task = asyncio.create_task(
get_pod_status_tasks_by_sha_and_readiness(
pods_task,
backends_task,
backends_task, # type: ignore
kube_client,
verbose,
)
Expand All @@ -696,15 +696,15 @@ async def kubernetes_status_v2(
service=service,
instance=instance,
namespaces=relevant_namespaces,
pod_status_by_sha_and_readiness_task=pod_status_by_sha_and_readiness_task,
pod_status_by_sha_and_readiness_task=pod_status_by_sha_and_readiness_task, # type: ignore
)
)
tasks.extend([pod_status_by_sha_and_readiness_task, versions_task])
tasks.extend([pod_status_by_sha_and_readiness_task, versions_task]) # type: ignore
else:
pod_status_by_replicaset_task = asyncio.create_task(
get_pod_status_tasks_by_replicaset(
pods_task,
backends_task,
backends_task, # type: ignore
kube_client,
verbose,
)
Expand All @@ -715,10 +715,10 @@ async def kubernetes_status_v2(
service=service,
instance=instance,
namespaces=relevant_namespaces,
pod_status_by_replicaset_task=pod_status_by_replicaset_task,
pod_status_by_replicaset_task=pod_status_by_replicaset_task, # type: ignore
)
)
tasks.extend([pod_status_by_replicaset_task, versions_task])
tasks.extend([pod_status_by_replicaset_task, versions_task]) # type: ignore

await asyncio.gather(*tasks, return_exceptions=True)

Expand Down
Loading
Loading