Skip to content

Commit 50d757c

Browse files
authored
updating app versions (in container) (#63)
* updating app versions (in container) we need to use an updated pydantic-settings and fastapi. This likely will work best in a container, or will need additional tweaks to install the correct version after. It does not seem to resolve perfectly in one requirements.txt, unfortunately. Signed-off-by: vsoch <[email protected]>
1 parent 588d7ce commit 50d757c

File tree

25 files changed

+182
-143
lines changed

25 files changed

+182
-143
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
1-
FROM ghcr.io/rse-ops/pokemon:app-latest
1+
FROM fluxrm/flux-sched:jammy
22

33
LABEL maintainer="Vanessasaurus <@vsoch>"
44

55
# Pip not provided in this version
66
USER root
7-
RUN apt-get update && apt-get install -y python3-venv systemctl
7+
RUN apt-get update && apt-get install -y python3-venv systemctl python3-pip
88
COPY ./requirements.txt /requirements.txt
99
COPY ./.github/dev-requirements.txt /dev-requirements.txt
1010
COPY ./docs/requirements.txt /docs-requirements.txt
1111

1212
EXPOSE 5000
13-
ENV PYTHONPATH=/usr/lib/flux/python3.8
13+
ENV PYTHONPATH=/usr/lib/flux/python3.10
1414

1515
# For easier Python development.
1616
RUN python3 -m pip install IPython && \
1717
python3 -m pip install -r /requirements.txt && \
1818
python3 -m pip install -r /dev-requirements.txt && \
1919
python3 -m pip install -r /docs-requirements.txt
2020

21-
RUN python3 -m venv /env && \
22-
. /env/bin/activate && \
23-
pip install -r /requirements.txt && \
24-
pip install -r /dev-requirements.txt && \
25-
pip install -r /docs-requirements.txt && \
26-
# Only for development - don't add this to a production container
27-
sudo useradd -m -p $(openssl passwd '12345') "flux"
28-
2921
RUN mkdir -p /run/flux /var/lib/flux mkdir /etc/flux/system/cron.d /mnt/curve && \
3022
flux keygen /mnt/curve/curve.cert && \
3123
# These need to be owned by flux
32-
chown -R flux /run/flux /var/lib/flux /mnt/curve && \
24+
chown -R fluxuser /run/flux /var/lib/flux /mnt/curve && \
3325
# flux-imp needs setuid permission
3426
chmod u+s /usr/libexec/flux/flux-imp
3527

.devcontainer/devcontainer.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "Flux Core Python 3.6",
2+
"name": "Flux RESTFul Python 3.10",
33
"dockerFile": "Dockerfile",
44
"context": "../",
55

@@ -10,12 +10,12 @@
1010

1111
// Ensure that Python autocomplete works out of the box
1212
"python.autoComplete.extraPaths": [
13-
"/usr/lib/flux/python3.8",
14-
"/usr/lib/python3.8/site-packages",
13+
"/usr/lib/flux/python3.10",
14+
"/usr/lib/python3.10/site-packages",
1515
],
1616
"python.analysis.extraPaths": [
17-
"/usr/lib/flux/python3.8",
18-
"/usr/lib/python3.8/site-packages",
17+
"/usr/lib/flux/python3.10",
18+
"/usr/lib/python3.10/site-packages",
1919
]
2020
},
2121
// Note to Flux Developers! We can add extensions here that you like
@@ -24,6 +24,7 @@
2424
],
2525
},
2626
},
27-
// Needed for git security feature, and flux config
28-
"postStartCommand": "git config --global --add safe.directory /workspaces/flux-python-api && flux R encode --hosts=$(hostname) > /etc/flux/system/R && sed -i 's@HOSTNAME@'$(hostname)'@' /etc/flux/system/conf.d/broker.toml && sudo service munge start"
27+
// Needed for git security feature, and flux config (not added / needed yet)
28+
//"postStartCommand": "git config --global --add safe.directory /workspaces/flux-restful-api && flux R encode --hosts=$(hostname) > /etc/flux/system/R && sed -i 's@HOSTNAME@'$(hostname)'@' /etc/flux/system/conf.d/broker.toml && sudo service munge start"
29+
"postStartCommand": "git config --global --add safe.directory /workspaces/flux-restful-api && flux R encode --hosts=$(hostname) > /etc/flux/system/R && sudo service munge start"
2930
}

.github/dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pre-commit
2-
black
2+
black==23.3.0
33
isort
44
flake8
55
pytest

.github/workflows/build-deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616
jobs:
1717
build:
1818
env:
19-
container: ghcr.io/flux-framework/flux-restful-api
19+
container: ghcr.io/flux-framework/flux-restful-api:test
2020
permissions:
2121
packages: write
2222

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
formatting:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515

1616
- name: Setup black linter
1717
run: conda create --quiet --name black pyflakes

.github/workflows/python-tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
needs: [prepare-container]
2323
services:
2424
api:
25-
image: ghcr.io/flux-framework/flux-restful-api:latest
25+
image: ghcr.io/flux-framework/flux-restful-api:test
2626
ports:
2727
- 5000:5000
2828
env:
@@ -44,7 +44,7 @@ jobs:
4444
env:
4545
INSTALL_BRANCH: ${{ needs.prepare-container.outputs.branch }}
4646
INSTALL_REPO: ${{ github.repository }}
47-
image: ghcr.io/flux-framework/flux-restful-api:latest
47+
image: ghcr.io/flux-framework/flux-restful-api:test
4848
ports:
4949
- 5000:5000
5050
steps:

.github/workflows/tests.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
needs: [prepare-container]
1919
container:
20-
image: ghcr.io/flux-framework/flux-restful-api:latest
20+
image: ghcr.io/flux-framework/flux-restful-api:test
2121
ports:
2222
- 5000
2323
env:
@@ -30,8 +30,10 @@ jobs:
3030
- uses: actions/checkout@v3
3131
- name: Install Dependencies (in case changes)
3232
run: pip install -r requirements.txt
33+
3334
- name: Run tests
3435
run: |
36+
pip freeze
3537
# Tests for the API with auth disabled
3638
flux start pytest -xs tests/test_api.py
3739

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM fluxrm/flux-sched:focal
1+
FROM fluxrm/flux-sched:jammy
22

33
# docker build -t ghcr.io/flux-framework/flux-restful-api .
44

@@ -14,7 +14,7 @@ ENV HOST=${host:-0.0.0.0}
1414
ENV WORKERS=${workers:-1}
1515

1616
USER root
17-
RUN apt-get update
17+
RUN apt-get update && apt-get install -y python3-pip
1818
COPY ./requirements.txt /requirements.txt
1919

2020
EXPOSE ${port}

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.13
1+
0.2.0

app/core/config.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import secrets
55
import shlex
66
import string
7+
from typing import Optional
78

8-
from pydantic import BaseSettings
9+
from pydantic_settings import BaseSettings
910

1011
logger = logging.getLogger(__name__)
1112

@@ -85,8 +86,8 @@ class Settings(BaseSettings):
8586

8687
# If you change this, also change in alembic.ini
8788
db_file: str = "sqlite:///./flux-restful.db"
88-
flux_user: str = os.environ.get("FLUX_USER")
89-
flux_token: str = os.environ.get("FLUX_TOKEN")
89+
flux_user: str = os.environ.get("FLUX_USER") or "fluxuser"
90+
flux_token: Optional[str] = os.environ.get("FLUX_TOKEN")
9091
secret_key: str = os.environ.get("FLUX_SECRET_KEY") or generate_secret_key()
9192

9293
# Expires in 10 hours

0 commit comments

Comments
 (0)