Skip to content

Commit 81f9097

Browse files
authored
Changes for 3.12 and v4 (#3583)
1 parent f13303e commit 81f9097

File tree

13 files changed

+85
-183
lines changed

13 files changed

+85
-183
lines changed

.github/workflows/upgrade-deps.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ jobs:
2424
- name: Upgrade JS dependencies
2525
# prettier-ignore
2626
run: >
27-
docker-compose run --no-deps web /bin/sh -c '
27+
docker compose run --no-deps web /bin/sh -c '
2828
rm -f yarn.lock &&
2929
chown -R $(whoami):$(whoami) . &&
3030
npx --yes yarn-upgrade-all
3131
'
3232
- name: Upgrade Python dependencies
3333
# prettier-ignore
3434
run: >
35-
docker-compose run --no-deps web /bin/sh -c '
35+
docker compose run --no-deps web /bin/sh -c '
3636
pip install --upgrade pip pip-tools &&
3737
pip-compile --upgrade -o requirements/prod.txt requirements/prod.in &&
3838
pip-compile --upgrade -o requirements/dev.txt requirements/dev.in

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ docs/_build/
7777
# Component library documentation
7878
storybook-static/
7979

80-
# pyenv
81-
.python-version
82-
8380
# celery beat schedule file
8481
celerybeat-schedule
8582

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ version: 2
99
build:
1010
os: ubuntu-20.04
1111
tools:
12-
python: '3.9'
12+
python: '3.12'
1313
# You can also specify other tool versions:
1414
# nodejs: "16"
1515
# rust: "1.55"

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ provided in [./docs/running.md](./docs/running.md).
1414

1515
To run these tests with Docker first run the following commands,
1616

17-
docker-compose up -d
18-
docker-compose exec web bash
17+
docker compose up -d
18+
docker compose exec web bash
1919

2020
If you are not using Docker or are using the VS Code integrated terminal inside
2121
the Docker container simply execute the commands in your project's root

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ARG BUILD_ENV=development
22
ARG PROD_ASSETS
33
ARG OMNIOUT_TOKEN
44
FROM node:22 AS node_base
5-
FROM python:3.9
5+
FROM python:3.12
66

77
# Node and npm
88
COPY --from=node_base /usr/local/lib/node_modules /usr/local/lib/node_modules

derrick

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#!/bin/bash -e
22

33
function dcr {
4-
docker-compose run --rm web $@
4+
docker compose run --rm web $@
55
}
66

77
function dcrq {
8-
docker-compose run --rm --no-deps web $@
8+
docker compose run --rm --no-deps web $@
99
}
1010

1111
case "$1" in
1212
"up")
13-
docker-compose up
13+
docker compose up
1414
;;
1515
"down")
16-
docker-compose down
16+
docker compose down
1717
;;
1818
"build")
19-
docker-compose build
19+
docker compose build
2020
;;
2121
"manage")
2222
dcr python manage.py "${@:2}"
@@ -49,7 +49,7 @@ case "$1" in
4949
dcrq yarn test:js "${@:2}"
5050
;;
5151
"storybook")
52-
docker-compose run --rm --no-deps --service-ports web yarn storybook "${@:2}"
52+
docker compose run --rm --no-deps --service-ports web yarn storybook "${@:2}"
5353
;;
5454
"add:js")
5555
dcrq yarn add "${@:2}"

docs/running.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77

88
## Making A Virtual Env
99

10-
MetaDeploy development requires Python v3.9. If `which python3.9` returns a
10+
MetaDeploy development requires Python v3.12. If `which python3.12` returns a
1111
non-empty path, it's already installed and you can continue to the next step. If
12-
it returns nothing, then install Python v3.9 using `brew install python`, or
12+
it returns nothing, then install Python v3.12 using `brew install python`, or
1313
from [Python.org](https://www.python.org/downloads/).
1414

1515
Assuming you're in the repo root, do the following to create a virtualenv (once
1616
you have
1717
[virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/)
1818
installed locally):
1919

20-
mkvirtualenv metadeploy --python=$(which python3.9)
20+
mkvirtualenv metadeploy --python=$(which python3.12)
2121
setvirtualenvproject
2222

2323
Install Python requirements:

docs/running_docker.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ _You should see something like the following:_
1818

1919
: `Docker version 20.10.14, build a224086`
2020

21-
The latest version of Docker Desktop comes with docker-compose installed. To
22-
verify you have successfully installed docker-compose, run:
21+
The latest version of Docker Desktop comes with docker compose installed. To
22+
verify you have successfully installed docker compose, run:
2323

24-
docker-compose -v
24+
docker compose -v
2525

2626
_You should see something like the following:_
2727

2828
Docker Compose version v2.5.1
2929

30-
If docker-compose is not installed, visit
30+
If docker compose is not installed, visit
3131
<https://docs.docker.com/compose/install/> and follow the installation
32-
instructions to download docker-compose.
32+
instructions to download docker compose.
3333

3434
### Running MetaDeploy In Docker
3535

@@ -106,17 +106,17 @@ a plan.
106106
Code](#docker-development-using-vs-code).
107107

108108

109-
This next section assumes you have installed `docker` and `docker-compose`.
109+
This next section assumes you have installed `docker` and `docker compose`.
110110
Additionally it assumes you have a `.env` file in the root directory of this
111111
project, a template of variables needed can be found in `env.example`.
112112

113113
To configure and run your environment you must run two commands in the project
114-
root. Note that `docker-compose build` will take some significant time to build
114+
root. Note that `docker compose build` will take some significant time to build
115115
the first time but will be much faster for subsequent builds. It is also
116116
important to note that once you bring up the web application it will take a
117117
minute or two to build.
118118

119-
docker-compose build
119+
docker compose build
120120

121121
## Running Your Docker Containers
122122

@@ -125,16 +125,16 @@ and the creation of a default admin user.
125125

126126
If you would like to disable this functionality please add a
127127
`DJANGO_SETTINGS_MODULE` environment variable in the web service section of the
128-
docker-compose file to set it from its default value (set in Dockerfile) from
128+
docker compose file to set it from its default value (set in Dockerfile) from
129129
`config.settings.local` to `config.settings.production`. For examples of how to
130-
do this please see [setting docker-compose environment
130+
do this please see [setting docker compose environment
131131
variables](https://docs.docker.com/compose/environment-variables/).
132132

133133
Then run the following command:
134134

135-
docker-compose up -d
135+
docker compose up -d
136136
or
137-
docker-compose up (for debug mode)
137+
docker compose up (for debug mode)
138138

139139
This command may take a few minutes to finish. Once it's done, visit
140140
`localhost:8000/admin/login` and login with the following credentials if
@@ -149,27 +149,27 @@ account will not be created when `BUILD_ENV` is set to `production`.
149149

150150
## Docker Commands
151151

152-
To stop your virtual containers run the following command (the docker-compose
152+
To stop your virtual containers run the following command (the docker compose
153153
stop command will stop your containers, but it won't remove them):
154154

155-
docker-compose stop
155+
docker compose stop
156156

157157
To start your virtual containers run the following command:
158158

159-
docker-compose start
159+
docker compose start
160160

161161
To bring your virtual containers up for the first time run the following
162162
command:
163163

164-
docker-compose up -d
164+
docker compose up -d
165165

166166
To bring your virtual containers down run the following command:
167167

168168
> **Note**
169-
> The docker-compose down command will stop your containers, but also removes
169+
> The docker compose down command will stop your containers, but also removes
170170
the stopped containers as well as any networks that were created.
171171

172-
docker-compose down
172+
docker compose down
173173

174174
Removes stopped service containers. To remove your stopped containers enter the
175175
following commands
@@ -178,28 +178,28 @@ following commands
178178
> This will destroy anything that is in the virtual environment, however the
179179
database data will persist
180180

181-
docker-compose rm
181+
docker compose rm
182182

183183
(then enter `y` when prompted. If you would like to clear the database as well
184-
include a -v flag i.e. `docker-compose down -v`)
184+
include a -v flag i.e. `docker compose down -v`)
185185

186186
To view all running services run the following command:
187187

188-
docker-compose ps
188+
docker compose ps
189189

190190
If you'd like to test something out manually in that test environment for any
191191
reason you can run the following: In order to run relevant management commands
192192
like `manage.py makemigrations`, or if you'd like to test something
193193
out manually in that test environment for any reason you can run the following:
194194

195-
docker-compose exec web bash
195+
docker compose exec web bash
196196

197197
After this you will be inside of a linux commandline, and are free to test
198198
around in your container.
199199

200200
Or you could directly run a command like this:
201201

202-
docker-compose exec web python manage.py makemigrations
202+
docker compose exec web python manage.py makemigrations
203203

204204
## Docker development using VS Code
205205

@@ -212,19 +212,19 @@ extension pack.
212212

213213
Once you have the extension pack installed, when you open the MetaDeploy folder
214214
in VS Code, you will be prompted to "Reopen in Container". Doing so will
215-
effectively run `docker-compose up` and reload your window, now running inside
215+
effectively run `docker compose up` and reload your window, now running inside
216216
the Docker container. If you do not see the prompt, run the "Remote-Containers:
217217
Open Folder in Container\..." command from the VS Code Command Palette to start
218218
the Docker container.
219219

220220
A number of project-specific VS Code extensions will be automatically installed
221221
for you within the Docker container. See `.devcontainer/devcontainer.json` and
222-
`.devcontainer/docker-compose.dev.yml` for Docker-specific VS Code settings.
222+
`.devcontainer/docker compose.dev.yml` for Docker-specific VS Code settings.
223223

224224
The first build will take a number of minutes, but subsequent builds will be
225225
significantly faster.
226226

227-
Similarly to the behavior of `docker-compose up`, VS Code automatically runs
227+
Similarly to the behavior of `docker compose up`, VS Code automatically runs
228228
database migrations and starts the development server/watcher. To run any local
229229
commands, open an
230230
[integrated terminal](https://code.visualstudio.com/docs/editor/integrated-terminal)
@@ -236,7 +236,7 @@ RUNNING.RST and CONTRIBUTING.RST):
236236
$ yarn serve # start the development server/watcher
237237

238238
For any commands, when using the VS Code integrated terminal inside the Docker
239-
container, omit any `docker-compose run --rm web...` prefix, e.g.:
239+
container, omit any `docker compose run --rm web...` prefix, e.g.:
240240

241241
$ python manage.py promote_superuser <your email>
242242
$ yarn test:js

metadeploy/api/tests/test_jobs.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
enqueuer,
2626
expire_preflights,
2727
finalize_result,
28+
JobLogStatus,
29+
JobType,
2830
preflight,
2931
run_flows,
3032
)
@@ -220,9 +222,9 @@ def test_finalize_result_worker_died(job_factory, caplog):
220222
log_record = next(r for r in caplog.records if "interrupted" in r.message)
221223

222224
assert log_record.message == f"Job {job.id} interrupted by dyno restart"
223-
assert log_record.context["event"] == "job"
225+
assert log_record.context["event"] == f"{JobType.JOB}"
224226
assert log_record.context["context"] == "test-product/1.0/sample-plan"
225-
assert log_record.context["status"] == "terminated"
227+
assert log_record.context["status"] == f"{JobLogStatus.TERMINATED}"
226228
assert "duration" in log_record.context
227229

228230

@@ -243,9 +245,9 @@ def test_finalize_result_canceled_job(job_factory, caplog):
243245
log_record = next(r for r in caplog.records if "canceled" in r.message)
244246

245247
assert log_record.message == f"Job {job.id} canceled"
246-
assert log_record.context["event"] == "job"
248+
assert log_record.context["event"] == f"{JobType.JOB}"
247249
assert log_record.context["context"] == "test-product/1.0/sample-plan"
248-
assert log_record.context["status"] == "canceled"
250+
assert log_record.context["status"] == f"{JobLogStatus.CANCELED}"
249251
assert "duration" in log_record.context
250252

251253

@@ -273,9 +275,9 @@ def test_finalize_result_preflight_worker_died(
273275
log_record.message
274276
== f"PreflightResult {preflight.id} interrupted by dyno restart"
275277
)
276-
assert log_record.context["event"] == "preflight"
278+
assert log_record.context["event"] == f"{JobType.PREFLIGHT}"
277279
assert log_record.context["context"] == "test-product/1.0/sample-plan"
278-
assert log_record.context["status"] == "terminated"
280+
assert log_record.context["status"] == f"{JobLogStatus.TERMINATED}"
279281
assert "duration" in log_record.context
280282

281283

@@ -296,9 +298,9 @@ def test_finalize_result_preflight_failed(
296298
log_record = next(r for r in caplog.records if "failed" in r.message)
297299

298300
assert log_record.message == f"PreflightResult {preflight.id} failed"
299-
assert log_record.context["event"] == "preflight"
301+
assert log_record.context["event"] == f"{JobType.PREFLIGHT}"
300302
assert log_record.context["context"] == "test-product/1.0/sample-plan"
301-
assert log_record.context["status"] == "failure"
303+
assert log_record.context["status"] == f"{JobLogStatus.FAILURE}"
302304
assert "duration" in log_record.context
303305

304306

@@ -322,9 +324,9 @@ def test_finalize_result_mdapi_error(job_factory, caplog):
322324
log_record = next(r for r in caplog.records if "errored" in r.message)
323325

324326
assert log_record.message == f"Job {job.id} errored"
325-
assert log_record.context["event"] == "job"
327+
assert log_record.context["event"] == f"{JobType.JOB}"
326328
assert log_record.context["context"] == "test-product/1.0/sample-plan"
327-
assert log_record.context["status"] == "error"
329+
assert log_record.context["status"] == f"{JobLogStatus.ERROR}"
328330
assert "duration" in log_record.context
329331

330332

@@ -341,9 +343,9 @@ def test_finalize_result_job_success(job_factory, caplog):
341343
log_record = next(r for r in caplog.records if "succeeded" in r.message)
342344

343345
assert log_record.message == f"Job {job.id} succeeded"
344-
assert log_record.context["event"] == "job"
346+
assert log_record.context["event"] == f"{JobType.JOB}"
345347
assert log_record.context["context"] == "test-product/1.0/sample-plan"
346-
assert log_record.context["status"] == "success"
348+
assert log_record.context["status"] == f"{JobLogStatus.SUCCESS}"
347349
assert "duration" in log_record.context
348350

349351

0 commit comments

Comments
 (0)