Skip to content

Commit 6b88bb7

Browse files
B-Step62harupy
andauthored
Move psutil to test requirements and do optimistic load (mlflow#10342)
Signed-off-by: B-Step62 <[email protected]> Signed-off-by: Yuki Watanabe <[email protected]> Co-authored-by: Harutaka Kawamura <[email protected]>
1 parent 5d1126d commit 6b88bb7

File tree

8 files changed

+17
-17
lines changed

8 files changed

+17
-17
lines changed

.github/workflows/gateway.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: |
3535
pip install .[gateway] \
3636
pytest pytest-timeout pytest-asyncio \
37-
httpx sentence-transformers transformers
37+
httpx psutil sentence-transformers transformers
3838
# Ensure pydantic v2 is installed
3939
pip freeze | tail -n +1 | grep -q '^pydantic==2\.'
4040
- name: Run tests with pydantic v2

dev/Dockerfile.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ADD ./requirements /app/requirements
2020
RUN \
2121
# install required python packages
2222
pip install -r requirements/test-requirements.txt --no-cache-dir \
23-
-r requirements/lint-requirements.txt psutil
23+
-r requirements/lint-requirements.txt
2424

2525
ADD . /app
2626

docker/Dockerfile

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
11
FROM python:3.10-slim-bullseye
22
ARG VERSION
3-
# NB: installing gcc is required in order to build a wheel file
4-
# for psutil, which is a dependency of mlflow.
5-
# The binaries for psutil do not support Python 3.10, requiring
6-
# a build from source. psutil has a large amount of cython within
7-
# its code base, necessitating gcc being present in the image.
8-
RUN apt-get update && \
9-
apt-get install -y gcc && \
10-
apt-get clean && \
11-
rm -rf /var/lib/apt/lists/*
123
RUN pip install --no-cache mlflow==$VERSION

mlflow/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
]
210210

211211

212-
# `mlflow.gateway` depends on optional dependencies such as pydantic and has version
212+
# `mlflow.gateway` depends on optional dependencies such as pydantic, psutil, and has version
213213
# restrictions for dependencies. Importing this module fails if they are not installed or
214214
# if invalid versions of these required packages are installed.
215215
with contextlib.suppress(Exception):

mlflow/tracking/fluent.py

+12
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,18 @@ def start_run(
380380
# if `log_system_metrics` is not specified, we will check environment variable.
381381
log_system_metrics = MLFLOW_ENABLE_SYSTEM_METRICS_LOGGING.get()
382382
if log_system_metrics:
383+
# Ensure psutil is installed. It was moved to an optional dependency, as it doesn't
384+
# have binary for Arm64 Linux and requires build from CPython which is a headache.
385+
# https://github.com/giampaolo/psutil/issues/1972
386+
if importlib.util.find_spec("psutil") is None:
387+
raise MlflowException(
388+
"Failed to start system metrics monitoring as package `psutil` is not "
389+
"installed. Run `pip install psutil` to resolve the issue, "
390+
"otherwise you can disable system metrics logging by passing "
391+
"`log_system_metrics=False` to `start_run()` or setting environment "
392+
f"variable {MLFLOW_ENABLE_SYSTEM_METRICS_LOGGING} to False."
393+
)
394+
383395
try:
384396
from mlflow.system_metrics.system_metrics_monitor import SystemMetricsMonitor
385397

requirements/core-requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ markdown<4,>=3.3
1818
Jinja2<4,>=2.11; platform_system != 'Windows'
1919
Jinja2<4,>=3.0; platform_system == 'Windows'
2020
matplotlib<4
21-
psutil<6

requirements/core-requirements.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,3 @@ Jinja2-windows:
8181
matplotlib:
8282
pip_release: matplotlib
8383
max_major_version: 3
84-
85-
psutil:
86-
pip_release: psutil
87-
max_major_version: 5

requirements/test-requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@ databricks-sdk
4242
# Required for LLM eval in `mlflow.evaluate`
4343
# TODO: Unpin once we support openai 1.0
4444
openai<1.0
45+
# Required for showing pytest stats
46+
psutil

0 commit comments

Comments
 (0)