Skip to content

Commit 8fae62d

Browse files
Multiple changes:
- Upgrade all images to python3.11 - Upgrade all requirements - Upgrade CI configs - Remove everything kubernetes-related due to support difficulty
1 parent 3801774 commit 8fae62d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+150
-1466
lines changed

.github/workflows/release.yml

+11-6
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,33 @@ jobs:
1010
runs-on: ubuntu-22.04
1111
steps:
1212
- name: Checkout code
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v3
1414

1515
- name: Get the version
1616
id: get_version
1717
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
1818

1919
- name: Set up QEMU
20-
uses: docker/setup-qemu-action@v2
20+
uses: docker/setup-qemu-action@v3
21+
with:
22+
platforms: amd64,arm64
2123

2224
- name: Set up Docker Buildx
23-
uses: docker/setup-buildx-action@v2
25+
uses: docker/setup-buildx-action@v3
26+
with:
27+
install: true
28+
platforms: linux/amd64,linux/arm64
2429

2530
- name: Login to GitHub Container Registry
26-
uses: docker/login-action@v2
31+
uses: docker/login-action@v3
2732
with:
2833
registry: ghcr.io
2934
username: ${{ github.repository_owner }}
3035
password: ${{ github.token }}
3136

3237
- name: Build and push
3338
id: docker_build
34-
uses: docker/build-push-action@v3
39+
uses: docker/build-push-action@v5
3540
with:
3641
context: .
3742
file: docker_config/base_images/backend.Dockerfile
@@ -42,7 +47,7 @@ jobs:
4247
ghcr.io/${{ github.repository_owner }}/forcad_base:${{ steps.get_version.outputs.VERSION }}
4348
4449
- name: Set up Node 16
45-
uses: actions/setup-node@v2
50+
uses: actions/setup-node@v3
4651
with:
4752
node-version: "16"
4853

.github/workflows/tests.yml

+16-42
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,26 @@ jobs:
3030

3131
steps:
3232
- name: Checkout
33-
uses: actions/checkout@v2
33+
uses: actions/checkout@v3
3434

35-
- name: Setup python
36-
uses: actions/setup-python@v2
35+
- uses: actions/setup-python@v4
3736
with:
38-
python-version: "3.9"
39-
40-
- uses: actions/cache@v2
41-
with:
42-
path: ~/.cache/pip
43-
key: ${{ runner.os }}-pip-${{ hashFiles('backend/requirements.txt') }}-${{ hashFiles('cli/requirements.txt') }}-${{ hashFiles('tests/requirements.txt') }}
44-
restore-keys: |
45-
${{ runner.os }}-pip-
46-
47-
- name: Setup tests
48-
run: python tests/setup_forcad.py
37+
python-version: "3.11"
38+
cache: "pip"
39+
cache-dependency-path: |
40+
cli/requirements.txt
41+
tests/requirements.txt
42+
backend/requirements.txt
4943
5044
- name: Install requirements
5145
run: |
5246
pip install -r cli/requirements.txt
5347
pip install -r tests/requirements.txt
5448
pip install -r backend/requirements.txt
5549
50+
- name: Setup tests
51+
run: python tests/setup_forcad.py
52+
5653
- name: Setup ForcAD
5754
run: ./control.py setup
5855

@@ -79,12 +76,11 @@ jobs:
7976
runs-on: ubuntu-22.04
8077
steps:
8178
- name: Checkout
82-
uses: actions/checkout@v2
79+
uses: actions/checkout@v3
8380

84-
- name: Setup python
85-
uses: actions/setup-python@v2
81+
- uses: actions/setup-python@v4
8682
with:
87-
python-version: "3.9"
83+
python-version: "3.11"
8884

8985
- name: Install dependencies
9086
run: pip install flake8
@@ -99,10 +95,10 @@ jobs:
9995
runs-on: ubuntu-22.04
10096
steps:
10197
- name: Checkout
102-
uses: actions/checkout@v2
98+
uses: actions/checkout@v3
10399

104100
- name: Set up Node 16
105-
uses: actions/setup-node@v2
101+
uses: actions/setup-node@v3
106102
with:
107103
node-version: "16"
108104

@@ -123,25 +119,3 @@ jobs:
123119
- name: Check the frontend compiles
124120
working-directory: front
125121
run: yarn build
126-
127-
terraform_checks:
128-
runs-on: ubuntu-22.04
129-
defaults:
130-
run:
131-
working-directory: deploy/terraform
132-
steps:
133-
- name: Checkout
134-
uses: actions/checkout@v2
135-
136-
- name: Setup Terraform
137-
uses: hashicorp/setup-terraform@v1
138-
139-
- name: Terraform fmt
140-
run: terraform fmt -check
141-
continue-on-error: true
142-
143-
- name: Terraform Init
144-
run: terraform init
145-
146-
- name: Terraform Validate
147-
run: terraform validate

backend/lib/config/models.py

+20-17
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,37 @@
22
from typing import List
33

44
from pydantic import BaseModel, Field
5+
from pydantic_settings import BaseSettings, SettingsConfigDict
56

67

7-
def env_field(key: str) -> Field:
8-
return Field(default_factory=lambda: os.environ[key])
8+
class Redis(BaseSettings):
9+
model_config = SettingsConfigDict(env_prefix='redis_')
910

10-
11-
class Redis(BaseModel):
12-
host: str = env_field('REDIS_HOST')
13-
port: int = env_field('REDIS_PORT')
14-
password: str = env_field('REDIS_PASSWORD')
11+
host: str
12+
port: int
13+
password: str
1514
db: int = 0
1615

1716
@property
1817
def url(self) -> str:
1918
return f'redis://:{self.password}@{self.host}:{self.port}/{self.db}'
2019

2120

22-
class WebCredentials(BaseModel):
23-
username: str = env_field('ADMIN_USERNAME')
24-
password: str = env_field('ADMIN_PASSWORD')
21+
class WebCredentials(BaseSettings):
22+
model_config = SettingsConfigDict(env_prefix='admin_')
23+
24+
username: str
25+
password: str
26+
2527

28+
class Database(BaseSettings):
29+
model_config = SettingsConfigDict(env_prefix='postgres_')
2630

27-
class Database(BaseModel):
28-
host: str = env_field('POSTGRES_HOST')
29-
port: int = env_field('POSTGRES_PORT')
30-
user: str = env_field('POSTGRES_USER')
31-
password: str = env_field('POSTGRES_PASSWORD')
32-
dbname: str = env_field('POSTGRES_DB')
31+
host: str
32+
port: int
33+
user: str
34+
password: str
35+
dbname: str = Field(validation_alias='postgres_db')
3336

3437

3538
class Celery(BaseModel):
@@ -39,7 +42,7 @@ class Celery(BaseModel):
3942

4043
worker_prefetch_multiplier: int = 1
4144

42-
result_expires = 15 * 60
45+
result_expires: int = 15 * 60
4346
redis_socket_timeout: int = 10
4447
redis_socket_keepalive: bool = True
4548
redis_retry_on_timeout: bool = True

backend/lib/storage/utils.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from contextlib import contextmanager
2+
from typing import TypeVar
23

34
import kombu
45
import redis
56
import socketio
6-
from psycopg2 import pool, extras
7-
87
from lib import config
9-
from lib.helpers.singleton import Singleton, T
8+
from lib.helpers.singleton import Singleton
9+
from psycopg2 import extras, pool
1010

1111

1212
class DBPool(Singleton[pool.SimpleConnectionPool]):
@@ -17,7 +17,7 @@ def create() -> pool.SimpleConnectionPool:
1717
return pool.SimpleConnectionPool(
1818
minconn=5,
1919
maxconn=20,
20-
**database_config.dict(),
20+
**database_config.model_dump(),
2121
)
2222

2323

@@ -26,7 +26,7 @@ class RedisStorage(Singleton[redis.Redis]):
2626
@staticmethod
2727
def create() -> redis.Redis:
2828
redis_config = config.get_redis_config()
29-
return redis.Redis(decode_responses=True, **redis_config.dict())
29+
return redis.Redis(decode_responses=True, **redis_config.model_dump())
3030

3131

3232
class SIOManager(Singleton[socketio.KombuManager]):
@@ -41,7 +41,7 @@ def create(*, write_only: bool = False) -> socketio.KombuManager:
4141
)
4242

4343
@classmethod
44-
def get(cls, *, write_only: bool) -> T:
44+
def get(cls, *, write_only: bool) -> socketio.KombuManager:
4545
return super().get(write_only=write_only)
4646

4747
@classmethod

backend/requirements.txt

+50-50
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
1-
amqp==5.0.9
2-
async-timeout==4.0.2
3-
autopep8==1.6.0
4-
bidict==0.21.2
5-
billiard==3.6.4.0
6-
celery==5.2.7
7-
certifi==2020.12.5
8-
charset-normalizer==2.1.0
9-
click==8.0.3
10-
click-didyoumean==0.0.3
1+
amqp==5.1.1
2+
annotated-types==0.6.0
3+
bidict==0.22.1
4+
billiard==4.1.0
5+
blinker==1.6.3
6+
celery==5.3.4
7+
certifi==2023.7.22
8+
charset-normalizer==3.3.1
9+
click==8.1.7
10+
click-didyoumean==0.3.0
1111
click-plugins==1.1.1
12-
click-repl==0.2.0
13-
Deprecated==1.2.13
14-
dnspython==1.16.0
15-
eventlet==0.30.2
16-
Flask==2.2.2
17-
Flask-Cors==3.0.10
18-
Flask-SocketIO==5.3.2
19-
flower==1.2.0
20-
greenlet==1.1.2
21-
gunicorn==20.1.0
22-
hiredis==2.0.0
23-
humanize==3.12.0
24-
idna==3.3
25-
importlib-metadata==4.12.0
26-
itsdangerous==2.0.1
12+
click-repl==0.3.0
13+
dnspython==2.4.2
14+
eventlet==0.33.3
15+
Flask==3.0.0
16+
Flask-Cors==4.0.0
17+
Flask-SocketIO==5.3.6
18+
flower==2.0.1
19+
greenlet==3.0.0
20+
gunicorn==21.2.0
21+
h11==0.14.0
22+
hiredis==2.2.3
23+
humanize==4.8.0
24+
idna==3.4
25+
itsdangerous==2.1.2
2726
Jinja2==3.1.2
28-
kombu==5.2.3
29-
MarkupSafe==2.1.1
30-
packaging==21.3
31-
prometheus-client==0.15.0
32-
prometheus-flask-exporter==0.21.0
33-
prompt-toolkit==3.0.18
34-
psycopg2==2.9.5
35-
pycodestyle==2.8.0
36-
pydantic==1.10.2
37-
pyparsing==3.0.6
38-
python-dateutil==2.8.1
39-
python-engineio==4.3.3
40-
python-socketio==5.7.2
41-
pytz==2022.6
42-
PyYAML==6.0
43-
redis==4.3.5
44-
requests==2.28.1
27+
kombu==5.3.2
28+
MarkupSafe==2.1.3
29+
packaging==23.2
30+
prometheus-client==0.17.1
31+
prometheus-flask-exporter==0.22.4
32+
prompt-toolkit==3.0.39
33+
psycopg2==2.9.9
34+
pydantic==2.4.2
35+
pydantic-settings==2.0.3
36+
pydantic_core==2.10.1
37+
python-dateutil==2.8.2
38+
python-dotenv==1.0.0
39+
python-engineio==4.8.0
40+
python-socketio==5.10.0
41+
pytz==2023.3.post1
42+
PyYAML==6.0.1
43+
redis==5.0.1
44+
requests==2.31.0
45+
simple-websocket==1.0.0
4546
six==1.16.0
46-
toml==0.10.2
47-
tornado==6.1
48-
typing_extensions==4.4.0
49-
urllib3==1.26.10
47+
tornado==6.3.3
48+
typing_extensions==4.8.0
49+
tzdata==2023.3
50+
urllib3==2.0.7
5051
vine==5.0.0
51-
wcwidth==0.2.5
52-
Werkzeug==2.2.2
53-
wrapt==1.13.3
54-
zipp==3.8.1
52+
wcwidth==0.2.8
53+
Werkzeug==3.0.0
54+
wsproto==1.2.0

backend/services/admin/viewsets/api_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class ApiSet:
10-
model: str = None
10+
model: str
1111

1212
def get_id_kwarg(self) -> str:
1313
return f'{self.model}_id'

backend/services/tasks/celery_factory.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from celery import Celery
2-
32
from lib import config
43

54

@@ -13,5 +12,5 @@ def get_celery_app():
1312
],
1413
)
1514

16-
app.conf.update(celery_config.dict())
15+
app.conf.update(celery_config.model_dump())
1716
return app

backend/services/tasks/handlers.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
from celery import shared_task
44
from celery.result import AsyncResult
55
from celery.utils.log import get_task_logger
6-
7-
from lib import storage, models
6+
from lib import models, storage
87
from lib.helpers.jobs import JobNames
9-
from lib.models import TaskStatus, Action
8+
from lib.models import Action, TaskStatus
109

1110
logger = get_task_logger(__name__)
1211

1312

1413
@shared_task(name=JobNames.error_handler)
1514
def exception_callback(result: AsyncResult, exc: Exception, traceback: str) -> None:
15+
print('!!!', result, type(result))
1616
action_name = result.task.split('.')[-1].split('_')[0].upper()
1717
action = Action[action_name]
1818

0 commit comments

Comments
 (0)