Skip to main content

How to Send a Parquet File to an MLflow Model Server

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Besides JSON and CSV, an MLflow model server reads Parquet, the column-based file format pandas and many data tools write. MLflow's guide doesn't mention it, but the server lists it among the types it accepts: application/vnd.apache.parquet. A Parquet file stores each column's type, so the server gets decimals as decimals. This guide sends one, with real output from MLflow 3.18.0.

Syntax​

Syntax
curl http://HOST:PORT/invocations -H "Content-Type: application/vnd.apache.parquet" --data-binary @FILE.parquet
PartWhat it means
application/vnd.apache.parquetThe content type the server reads as Parquet
--data-binary @FILE.parquetSends the file's bytes unchanged; -InFile in PowerShell

Where the type comes from: the server's answer to an unknown type lists the three it accepts, ['text/csv', 'application/json', 'application/vnd.apache.parquet'], and MLflow 3.18.0's mlflow/pyfunc/scoring_server/__init__.py reads a Parquet body with pandas.read_parquet.

Prerequisites​

  • An MLflow tracking server at http://127.0.0.1:8080, such as mlflow server --port 8080.
  • mlflow and scikit-learn in your project, for example with uv add mlflow scikit-learn pandas. MLflow installs pyarrow, which pandas needs to write Parquet.

Step 1: Log a Model and Write a Parquet File​

The example fits a Lasso regression on scikit-learn's diabetes data, which predicts how far the disease progresses in a year from ten measurements, and saves two patients with pandas' to_parquet:

The log_parquet_model.py script in a macOS-style code window: a Lasso model with alpha 0.1 trained on the diabetes data, logged with an input example, and the first two rows written to patients.parquet with to_parquet.

log_parquet_model.py
import mlflow
from sklearn.datasets import load_diabetes
from sklearn.linear_model import Lasso

mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("parquet-request-example")

X, y = load_diabetes(return_X_y=True, as_frame=True)
model = Lasso(alpha=0.1).fit(X, y)
with mlflow.start_run():
info = mlflow.sklearn.log_model(model, name="model", input_example=X.head(3))
print("Model URI:", info.model_uri)

X.head(2).to_parquet("patients.parquet", index=False)
Terminal
uv run python log_parquet_model.py
Output (last line)
Model URI: models:/m-8a7987aef3064333b88e1ad487a65095

Step 2: Serve the Model​

Terminal 2
export MLFLOW_TRACKING_URI=http://127.0.0.1:8080
uv run mlflow models serve -m "models:/m-8a7987aef3064333b88e1ad487a65095" -p 5001 --env-manager uv

Step 3: Send the Parquet File​

Terminal 3
curl http://127.0.0.1:5001/invocations -H "Content-Type: application/vnd.apache.parquet" --data-binary @patients.parquet
Output
{"predictions": [202.6686592452554, 73.83952927045901]}

curl's output in a terminal: predictions 202.6686592452554 and 73.83952927045901 as JSON, for the two patients in patients.parquet.

One prediction per patient: a progression score of about 203 for the first and 74 for the second.

Common Mistakes​

MistakeWhat happensDo this instead
--data @patients.parquetcurl removes the file's line-break bytes, and the server can't read what's left--data-binary
Content-Type: application/octet-stream415: the server accepts only its three typesapplication/vnd.apache.parquet

Troubleshooting​

SymptomLikely causeFix
Failed to parse input as a Pandas DataFrame ... Could not open Parquet input source '<Buffer>': Parquet file size is 5632 bytes, smaller than the size reported by footer'sThe file was sent with --data, which changed its bytesSend it with --data-binary
Model is missing inputsThe file's columns don't match the signatureWrite the same columns the model was trained on

FAQ​

Why send Parquet instead of CSV?​

A Parquet file stores each column's type with the data, so nothing has to be read back from text: decimals arrive as decimals.

Is Parquet documented?​

Not in MLflow's guide to the local server, which lists CSV and JSON. The server's own list of accepted types, in its 415 answer, includes it.

Conclusion​

Two patients saved with to_parquet and sent with Content-Type: application/vnd.apache.parquet and --data-binary came back from the diabetes model as two predictions, 202.67 and 73.84.

Additional Resources​