Skip to content

Commit

Permalink
Changes for 3.12 and v4 (#3583)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstvz authored Dec 11, 2024
1 parent f13303e commit 81f9097
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 183 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/upgrade-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ jobs:
- name: Upgrade JS dependencies
# prettier-ignore
run: >
docker-compose run --no-deps web /bin/sh -c '
docker compose run --no-deps web /bin/sh -c '
rm -f yarn.lock &&
chown -R $(whoami):$(whoami) . &&
npx --yes yarn-upgrade-all
'
- name: Upgrade Python dependencies
# prettier-ignore
run: >
docker-compose run --no-deps web /bin/sh -c '
docker compose run --no-deps web /bin/sh -c '
pip install --upgrade pip pip-tools &&
pip-compile --upgrade -o requirements/prod.txt requirements/prod.in &&
pip-compile --upgrade -o requirements/dev.txt requirements/dev.in
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ docs/_build/
# Component library documentation
storybook-static/

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version: 2
build:
os: ubuntu-20.04
tools:
python: '3.9'
python: '3.12'
# You can also specify other tool versions:
# nodejs: "16"
# rust: "1.55"
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ provided in [./docs/running.md](./docs/running.md).

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

docker-compose up -d
docker-compose exec web bash
docker compose up -d
docker compose exec web bash

If you are not using Docker or are using the VS Code integrated terminal inside
the Docker container simply execute the commands in your project's root
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG BUILD_ENV=development
ARG PROD_ASSETS
ARG OMNIOUT_TOKEN
FROM node:22 AS node_base
FROM python:3.9
FROM python:3.12

# Node and npm
COPY --from=node_base /usr/local/lib/node_modules /usr/local/lib/node_modules
Expand Down
12 changes: 6 additions & 6 deletions derrick
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#!/bin/bash -e

function dcr {
docker-compose run --rm web $@
docker compose run --rm web $@
}

function dcrq {
docker-compose run --rm --no-deps web $@
docker compose run --rm --no-deps web $@
}

case "$1" in
"up")
docker-compose up
docker compose up
;;
"down")
docker-compose down
docker compose down
;;
"build")
docker-compose build
docker compose build
;;
"manage")
dcr python manage.py "${@:2}"
Expand Down Expand Up @@ -49,7 +49,7 @@ case "$1" in
dcrq yarn test:js "${@:2}"
;;
"storybook")
docker-compose run --rm --no-deps --service-ports web yarn storybook "${@:2}"
docker compose run --rm --no-deps --service-ports web yarn storybook "${@:2}"
;;
"add:js")
dcrq yarn add "${@:2}"
Expand Down
6 changes: 3 additions & 3 deletions docs/running.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@

## Making A Virtual Env

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

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

mkvirtualenv metadeploy --python=$(which python3.9)
mkvirtualenv metadeploy --python=$(which python3.12)
setvirtualenvproject

Install Python requirements:
Expand Down
54 changes: 27 additions & 27 deletions docs/running_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ _You should see something like the following:_

: `Docker version 20.10.14, build a224086`

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

docker-compose -v
docker compose -v

_You should see something like the following:_

Docker Compose version v2.5.1

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

### Running MetaDeploy In Docker

Expand Down Expand Up @@ -106,17 +106,17 @@ a plan.
Code](#docker-development-using-vs-code).


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

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

docker-compose build
docker compose build

## Running Your Docker Containers

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

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

Then run the following command:

docker-compose up -d
docker compose up -d
or
docker-compose up (for debug mode)
docker compose up (for debug mode)

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

## Docker Commands

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

docker-compose stop
docker compose stop

To start your virtual containers run the following command:

docker-compose start
docker compose start

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

docker-compose up -d
docker compose up -d

To bring your virtual containers down run the following command:

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

docker-compose down
docker compose down

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

docker-compose rm
docker compose rm

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

To view all running services run the following command:

docker-compose ps
docker compose ps

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

docker-compose exec web bash
docker compose exec web bash

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

Or you could directly run a command like this:

docker-compose exec web python manage.py makemigrations
docker compose exec web python manage.py makemigrations

## Docker development using VS Code

Expand All @@ -212,19 +212,19 @@ extension pack.

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

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

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

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

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

$ python manage.py promote_superuser <your email>
$ yarn test:js
Expand Down
26 changes: 14 additions & 12 deletions metadeploy/api/tests/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
enqueuer,
expire_preflights,
finalize_result,
JobLogStatus,
JobType,
preflight,
run_flows,
)
Expand Down Expand Up @@ -220,9 +222,9 @@ def test_finalize_result_worker_died(job_factory, caplog):
log_record = next(r for r in caplog.records if "interrupted" in r.message)

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


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

assert log_record.message == f"Job {job.id} canceled"
assert log_record.context["event"] == "job"
assert log_record.context["event"] == f"{JobType.JOB}"
assert log_record.context["context"] == "test-product/1.0/sample-plan"
assert log_record.context["status"] == "canceled"
assert log_record.context["status"] == f"{JobLogStatus.CANCELED}"
assert "duration" in log_record.context


Expand Down Expand Up @@ -273,9 +275,9 @@ def test_finalize_result_preflight_worker_died(
log_record.message
== f"PreflightResult {preflight.id} interrupted by dyno restart"
)
assert log_record.context["event"] == "preflight"
assert log_record.context["event"] == f"{JobType.PREFLIGHT}"
assert log_record.context["context"] == "test-product/1.0/sample-plan"
assert log_record.context["status"] == "terminated"
assert log_record.context["status"] == f"{JobLogStatus.TERMINATED}"
assert "duration" in log_record.context


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

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


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

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


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

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


Expand Down
Loading

0 comments on commit 81f9097

Please sign in to comment.