Skip to main content

152 posts tagged with "uv"

uv, the Fast Python Package and Project Manager, Its Commands and pyproject.toml

View All Tags

How to Get the Current Time in UTC in Python

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

Times stored or sent between systems are safest in UTC, the time zone that never changes for daylight saving. In Python, datetime.now(tz=timezone.utc) gives you the current time in UTC, labelled as UTC, so nothing downstream has to guess which zone it's in.

How to Write a Docstring in Python

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

A docstring is the short description that sits at the top of a function and says what it does. Unlike a comment, Python keeps it with the function, so help(), editors and documentation tools can show it to anyone who uses your code.

How to Add Type Hints to a Python Function

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

A type hint writes down what kind of value a function expects and returns: a float here, an int there. Editors use the hints to warn you early, and readers see at a glance what to pass, but Python itself doesn't check them when the code runs.

How to Prepare an MLflow Model's Environment Before Serving It

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

Before mlflow models serve can start a model, it builds an environment with the model's Python version and packages. mlflow models prepare-env does that step on its own, ahead of time, so serve finds the environment ready. This guide prepares one and serves the model after it, with real output and times from MLflow 3.18.0 on a Mac.

Fixed: "MlflowException: Could not find the pyenv binary" When You Run mlflow models serve

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

I ran mlflow models serve the way MLflow's local deployment guide shows it, and it stopped before the server started, with mlflow.exceptions.MlflowException: Could not find the pyenv binary. Without --env-manager, the command builds the model's environment with virtualenv, which needs pyenv to install the model's Python version, and pyenv isn't installed on my Mac. --env-manager uv fixed it.

Fixed: "Detected one or more mismatches between the model's dependencies and the current Python environment" in MLflow

· 9 min read
Jagdish Kumawat
Founder @ Dewiride

I upgraded a project's packages and then scored some sessions with a model I had logged before the upgrade. MLflow printed WARNING mlflow.utils.requirements_utils: Detected one or more mismatches between the model's dependencies and the current Python environment, with five packages one release apart. MLflow had pinned the project's whole lockfile into the model when it logged it; running the model in its own environment, built from those pins, fixed it.

How to Log SHAP Explanations with mlflow.models.evaluate

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

Metrics say how well a model does; they don't say why. SHAP values explain each prediction column by column: how much each input pushed it up or down. mlflow.models.evaluate computes them and logs three plots by itself, as soon as the shap package is installed. This guide installs it, evaluates a diabetes model and reads the plots, with real output and UI from MLflow 3.18.0.