Skip to content

Commit 8ba7b6d

Browse files
committed
feat: add prefect server guide ; docs: update mlflow's README.md
1 parent 8cfaa19 commit 8ba7b6d

File tree

16 files changed

+476
-1
lines changed

16 files changed

+476
-1
lines changed

mlflow-server/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ The necessary env vars are:
1515
- `MLFLOW_HOST = 0.0.0.0`
1616
- `MLFLOW_PORT = 80`
1717

18-
Each description of the `MLFLOW_` variables is present in the reference: https://mlflow.org/docs/latest/cli.html
18+
Each description of the `MLFLOW_` variables is present in the reference:
19+
20+
- https://mlflow.org/docs/latest/cli.html
21+
22+
To authenticate in the API, you must configure in the client the env vars `MLFLOW_TRACKING_USERNAME`, `MLFLOW_TRACKING_PASSWORD` and `MLFLOW_TRACKING_URI` with the same values as the server's.

prefect-server/.dockerignore

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# IDEs
2+
.idea
3+
.vscode
4+
5+
# Environments
6+
.env
7+
.venv
8+
env/
9+
venv/
10+
ENV/
11+
env.bak/
12+
venv.bak/
13+
14+
# Project stuff
15+
.DS_Store
16+
mysql_data
17+
postgres_data
18+
19+
# Git
20+
.git
21+
.gitignore
22+
23+
# Byte-compiled / optimized / DLL files
24+
__pycache__/
25+
*.py[cod]
26+
*$py.class
27+
28+
29+
# IPython
30+
profile_default/
31+
ipython_config.py
32+
33+
# C extensions
34+
*.so
35+
36+
# Docker
37+
Dockerfile
38+
Dockerfile.local
39+
docker-compose.yml
40+
41+
# Documents
42+
README.md
43+
DEVGUIDE.md
44+
.pre-commit.yaml
45+
.coverage
46+
47+
# Tests
48+
/tests

prefect-server/.gitignore

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# AI Project
2+
secrets/
3+
data/
4+
chroma/
5+
Dockerfile.local
6+
7+
# Common Files
8+
*.pdf
9+
*.docx
10+
*.csv
11+
*.parquet
12+
*.txt
13+
*.jpg
14+
*.jpeg
15+
*.png
16+
17+
# Byte-compiled / optimized / DLL files
18+
__pycache__/
19+
*.py[cod]
20+
*$py.class
21+
22+
# C extensions
23+
*.so
24+
25+
# Distribution / packaging
26+
.Python
27+
build/
28+
develop-eggs/
29+
dist/
30+
downloads/
31+
eggs/
32+
.eggs/
33+
lib/
34+
lib64/
35+
parts/
36+
sdist/
37+
var/
38+
wheels/
39+
share/python-wheels/
40+
*.egg-info/
41+
.installed.cfg
42+
*.egg
43+
MANIFEST
44+
45+
# PyInstaller
46+
*.manifest
47+
*.spec
48+
49+
# Installer logs
50+
pip-log.txt
51+
pip-delete-this-directory.txt
52+
53+
# Unit test / coverage reports
54+
htmlcov/
55+
.tox/
56+
.nox/
57+
.coverage
58+
.coverage.*
59+
.cache
60+
nosetests.xml
61+
coverage.xml
62+
*.cover
63+
*.py,cover
64+
.hypothesis/
65+
.pytest_cache/
66+
cover/
67+
68+
# Translations
69+
*.mo
70+
*.pot
71+
72+
# Django stuff:
73+
*.log
74+
local_settings.py
75+
db.sqlite3
76+
db.sqlite3-journal
77+
78+
# Flask stuff:
79+
instance/
80+
.webassets-cache
81+
82+
# Scrapy stuff:
83+
.scrapy
84+
85+
# Sphinx documentation
86+
docs/_build/
87+
88+
# PyBuilder
89+
.pybuilder/
90+
target/
91+
92+
# Jupyter Notebook
93+
.ipynb_checkpoints
94+
95+
# IPython
96+
profile_default/
97+
ipython_config.py
98+
99+
# pyenv
100+
.python-version
101+
102+
# pipenv
103+
Pipfile.lock
104+
105+
# poetry
106+
poetry.lock
107+
108+
# pdm
109+
.pdm.toml
110+
.pdm-python
111+
.pdm-build/
112+
113+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
114+
__pypackages__/
115+
116+
# Celery stuff
117+
celerybeat-schedule
118+
celerybeat.pid
119+
120+
# SageMath parsed files
121+
*.sage.py
122+
123+
# Environments
124+
.env
125+
.venv
126+
env/
127+
venv/
128+
ENV/
129+
env.bak/
130+
venv.bak/
131+
132+
# Spyder project settings
133+
.spyderproject
134+
.spyproject
135+
136+
# Rope project settings
137+
.ropeproject
138+
139+
# mkdocs documentation
140+
/site
141+
142+
# mypy
143+
.mypy_cache/
144+
.dmypy.json
145+
dmypy.json
146+
147+
# ruff
148+
.ruff_cache
149+
150+
# Pyre type checker
151+
.pyre/
152+
153+
# pytype static type analyzer
154+
.pytype/
155+
156+
# Cython debug symbols
157+
cython_debug/
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: check-yaml
6+
always_run: true
7+
- id: end-of-file-fixer
8+
always_run: true
9+
- id: trailing-whitespace
10+
always_run: true
11+
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
rev: v0.8.4
14+
hooks:
15+
- id: ruff
16+
always_run: true
17+
types_or: [ python, pyi ]
18+
args: [ --fix, --exclude=__init__.py]
19+
- id: ruff-format
20+
always_run: true
21+
types_or: [ python, pyi]
22+
args: [--line-length=85]
23+
24+
- repo: https://github.com/pre-commit/mirrors-mypy
25+
rev: v1.13.0
26+
hooks:
27+
- id: mypy
28+
args: [--ignore-missing-imports,
29+
--allow-redefinition,
30+
--follow-imports=silent,
31+
--disallow-untyped-defs,
32+
--warn-unreachable,
33+
--show-error-context,
34+
--exclude=__init__.py]

prefect-server/Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM --platform=linux/amd64 python:3.12.6-slim
2+
3+
ENV PORT 80
4+
ENV APP_NAME prefect_server
5+
ENV WORKDIR /app
6+
7+
ENV PYTHONPATH ${WORKDIR}/${APP_NAME}
8+
ENV PYTHONUNBUFFERED 1
9+
10+
WORKDIR ${WORKDIR}
11+
EXPOSE ${PORT}
12+
13+
# System update
14+
RUN apt-get update && \
15+
apt-get install -y --no-install-recommends netcat-openbsd curl git wget bash && \
16+
rm -rf /var/lib/apt/lists/* /var/tmp/*
17+
18+
# Install Poetry
19+
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry POETRY_VERSION=1.8.5 python && \
20+
cd /usr/local/bin && \
21+
ln -s /opt/poetry/bin/poetry && \
22+
poetry config virtualenvs.create true && \
23+
poetry config virtualenvs.path --unset && \
24+
poetry config virtualenvs.in-project true
25+
26+
# Copy poetry.lock* in case it doesn't exist in the repo
27+
COPY ./pyproject.toml ./poetry.lock* ./
28+
29+
30+
# Installing poetry dependencies
31+
RUN poetry lock --no-update && \
32+
poetry install --no-root --only main
33+
34+
COPY . ./
35+
36+
RUN wget https://github.com/Droplr/aws-env/raw/master/bin/aws-env-linux-amd64 -O /app/aws-env
37+
RUN chmod +x /app/aws-env
38+
39+
# Running app with FastAPI
40+
RUN poetry run pip install "fastapi[standard]"
41+
CMD ["/bin/bash", "-c", \
42+
"eval $(./aws-env) && \
43+
poetry run fastapi run \
44+
src/${APP_NAME}/api/app.py \
45+
--port ${PORT}"]

prefect-server/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# MLflow Server Deploy Guide
2+
3+
This repository contains a `Dockerfile` and an environment with `Poetry` that can be used to deploy a self-hosted Prefect server, considering your env vars are configured in AWS Systems Manager. Besides, the server has basic auth, that is, you must authenticate using an username and a password.
4+
5+
The necessary env vars are:
6+
7+
- `AWS_ACCESS_KEY_ID`
8+
- `AWS_REGION`
9+
- `AWS_SECRET_ACCESS_KEY`
10+
- `PREFECT_API_DATABASE_CONNECTION_URL`
11+
- `PREFECT_API_URL`
12+
- `PREFECT_RUNNER_HEARTBEAT_FREQUENCY`
13+
- `PREFECT_RUNNER_ENABLE`
14+
- `PREFECT_RUNNER_MISSED_POOLS_TOLERANCE`
15+
- `PREFECT_RUNNER_PROCESS_LIMIT`
16+
- `PREFECT_RUNNER_POOL_FREQUENCY`
17+
- `PREFECT_SERVER_API_HOST = 0.0.0.0`
18+
- `PREFECT_SERVER_API_PORT = 80`
19+
- `PREFECT_SERVER_API_AUTH_STRING` (must be in the format `<username>:<password>`)
20+
21+
Each description of the `PREFECT_` variables is present in the references:
22+
23+
- https://docs-2.prefect.io/latest/api-ref/prefect/settings/
24+
- https://docs-2.prefect.io/latest/guides/settings/
25+
26+
To authenticate in the API, you must configure in the client an env var called `PREFECT_API_AUTH_STRING` that must have the same value as the `PREFECT_SERVER_API_AUTH_STRING` server variable, and the env var `PREFECT_API_URL` with the same value as the server's.

prefect-server/poetry.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[virtualenvs]
2+
in-project = true

prefect-server/pyproject.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[tool.poetry]
2+
name = "prefect_server"
3+
version = "1.0.0"
4+
description = ""
5+
authors = ["Samir Nunes da Silva"]
6+
readme = "README.md"
7+
packages = [{include = "prefect_server", from="src"}]
8+
9+
[tool.poetry.dependencies]
10+
python = "^3.12"
11+
prefect = "^3.1.9"
12+
boto3 = "^1.35.87"
13+
asyncpg = "^0.30.0"
14+
pydantic-settings = "^2.7.0"
15+
prometheus-client = "^0.21.1"
16+
fastapi = "^0.115.6"
17+
18+
[tool.poetry.group.dev.dependencies]
19+
pytest = "^8.3.2"
20+
pytest-cov = "^5.0.0"
21+
ipykernel = "^6.29.5"
22+
pytest-asyncio = "^0.24.0"
23+
isort = "^5.13.2"
24+
black = "^24.10.0"
25+
mypy = "^1.13.0"
26+
pre-commit = "^4.0.1"
27+
pytest-deadfixtures = "^2.2.1"
28+
29+
[build-system]
30+
requires = ["poetry-core"]
31+
build-backend = "poetry.core.masonry.api"

prefect-server/src/prefect_server/__init__.py

Whitespace-only changes.

prefect-server/src/prefect_server/api/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)