chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:22:34 +08:00
commit 4b22cfda96
9037 changed files with 2363717 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
.examples
+268
View File
@@ -0,0 +1,268 @@
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS = -W --keep-going -n -T
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build
# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don\'t have Sphinx installed, grab it from http://sphinx-doc.org/)
endif
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
.PHONY: default
default: html
.PHONY: help
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " applehelp to make an Apple Help Book"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " epub3 to make an epub3"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo " coverage to run coverage check of the documentation (if enabled)"
@echo " dummy to check syntax errors of document sources"
.PHONY: clean
clean:
rm -rf $(BUILDDIR)/*
.PHONY: javadocs
javadocs:
./build-javadoc.sh
.PHONY: rdocs
rdocs:
./build-rdoc.sh
.PHONY: tsdocs
tsdocs:
./build-tsdoc.sh
.PHONY: test-examples
test-examples:
@pytest --no-cov .examples
.PHONY: gateway-api-docs
gateway-api-docs:
@python gateway_api_docs.py
# Builds only the RST-based documentation (i.e., everything but Java & R docs)
.PHONY: rsthtml
rsthtml: gateway-api-docs
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
@echo "Use 'make view' to preview docs."
.PHONY: view
view:
python -m http.server --directory build/html
.PHONY: html
html: rdocs rsthtml javadocs tsdocs
.PHONY: dirhtml
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
.PHONY: singlehtml
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
.PHONY: livehtml
livehtml:
# Remove `--keep-going` option because `sphinx-autobuild` doesn't support it and raises an error.
# See: https://github.com/executablebooks/sphinx-autobuild/blob/master/src/sphinx_autobuild/build.py#L7
sphinx-autobuild -b html $(shell echo $(ALLSPHINXOPTS) | sed -e "s/--keep-going//g") $(BUILDDIR)/html
.PHONY: pickle
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
.PHONY: json
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
.PHONY: htmlhelp
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
.PHONY: qthelp
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/twitterpandas.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/twitterpandas.qhc"
.PHONY: applehelp
applehelp:
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
@echo
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
@echo "N.B. You won't be able to view it unless you put it in" \
"~/Library/Documentation/Help or install it in your application" \
"bundle."
.PHONY: devhelp
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/twitterpandas"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/twitterpandas"
@echo "# devhelp"
.PHONY: epub
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
.PHONY: epub3
epub3:
$(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3
@echo
@echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3."
.PHONY: latex
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
.PHONY: latexpdf
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
.PHONY: latexpdfja
latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
.PHONY: text
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
.PHONY: man
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
.PHONY: texinfo
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
.PHONY: info
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
.PHONY: gettext
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
.PHONY: changes
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
.PHONY: linkcheck
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
.PHONY: doctest
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
.PHONY: coverage
coverage:
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
@echo "Testing of coverage in the sources finished, look at the " \
"results in $(BUILDDIR)/coverage/python.txt."
.PHONY: xml
xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
.PHONY: pseudoxml
pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
.PHONY: dummy
dummy:
$(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy
@echo
@echo "Build finished. Dummy builder generates no files."
+90
View File
@@ -0,0 +1,90 @@
# MLflow API Documentation
This directory contains the MLflow API reference. The source code (`.rst` files) is relatively minimal, as the API docs are mainly populated by docstrings in the MLflow Python source.
## Building the docs
First, install dependencies for building docs as described in the [Environment Setup and Python configuration](https://github.com/mlflow/mlflow/blob/master/CONTRIBUTING.md#environment-setup-and-python-configuration) section of the main MLflow contribution guide.
Building documentation requires [Pandoc](https://pandoc.org/index.html). It should have already been
installed if you used the automated env setup script
([dev-env-setup.sh](https://github.com/mlflow/mlflow/blob/master/dev/dev-env-setup.sh)),
but if you are manually installing dependencies, please follow [the official instruction](https://pandoc.org/installing.html).
Also, check the version of your installation via `pandoc --version` and ensure it is 2.2.1 or above.
If you are using Mac OSX, be aware that the Homebrew installation of Pandoc may be outdated. If you are using Linux,
you should use a deb installer or install from the source, instead of running `apt` / `apt-get` commands. Pandoc package available on official
repositories is an older version and contains several bugs. You can find newer versions at <https://github.com/jgm/pandoc/releases>.
To generate a live preview of Python & other rst documentation, run the
following snippet. Note that R & Java API docs must be regenerated
separately after each change and are not live-updated; see subsequent
sections for instructions on generating R and Java docs.
```bash
cd docs
make livehtml
```
Generate R API rst doc files via:
```bash
cd docs
make rdocs
```
---
**NOTE**
If you attempt to build the R documentation on an ARM-based platform (Apple silicon M1, M2, etc.)
you will likely get an error when trying to execute the Docker build process for the make command.
To address this, set the default docker platform environment variable as follows:
```bash
export DOCKER_DEFAULT_PLATFORM=linux/amd64
```
---
Generate Java API rst doc files via:
```bash
cd docs
make javadocs
```
Generate API docs for all languages via:
```bash
cd docs
make html
```
Generate only the main .rst based documentation:
```bash
cd docs
make rsthtml
```
After running these commands, a build folder containing the generated
HTML will be generated at `build/html`.
If changing existing Python APIs or adding new APIs under existing
modules, ensure that references to the modified APIs are updated in
existing docs under `docs/source`. Note that the Python doc generation
process will automatically produce updated API docs, but you should
still audit for usages of the modified APIs in guides and examples.
If adding a new public Python module, create a corresponding doc file
for the module under `docs/source/python_api` - [see
here](https://github.com/mlflow/mlflow/blob/v0.9.1/docs/source/python_api/mlflow.tracking.rst#mlflowtracking)
for an example.
> Note: If you are experiencing issues with rstcheck warning of failures in files that you did not modify, try:
```bash
cd docs
make clean; make html
```
File diff suppressed because it is too large Load Diff
+72
View File
@@ -0,0 +1,72 @@
import contextlib
import socket
import subprocess
import sys
import time
import requests
from scrapy.crawler import CrawlerProcess
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule
def get_safe_port():
with contextlib.closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
sock.bind(("localhost", 0))
return sock.getsockname()[1]
@contextlib.contextmanager
def server(port):
with subprocess.Popen(
[sys.executable, "-m", "http.server", str(port), "--directory", "build/html"],
stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
) as prc:
try:
for _ in range(5):
try:
if requests.get(f"http://localhost:{port}").ok:
break
except requests.exceptions.ConnectionError:
time.sleep(0.5)
else:
raise RuntimeError("Server did not start")
yield
finally:
prc.terminate()
def main():
port = get_safe_port()
class Crawler(CrawlSpider):
name = "broken-links"
allowed_domains = ["localhost"]
start_urls = [f"http://localhost:{port}/"]
handle_httpstatus_list = [404]
rules = (Rule(LinkExtractor(), callback="parse_item", follow=True),)
links = set()
def parse_item(self, response):
if response.status == 404:
self.links.add((
response.url,
response.request.headers.get("Referer", None).decode("utf-8"),
))
with server(port):
process = CrawlerProcess(settings={"LOG_LEVEL": "ERROR"})
process.crawl(Crawler)
process.start()
if Crawler.links:
print("Broken links found:")
for link, referer in Crawler.links:
print(f"{link} in {referer}")
sys.exit(1)
if __name__ == "__main__":
main()
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
# Builds the MLflow Javadoc and places it into build/html/java_api/
set -ex
pushd ../../mlflow/java/client/
# the MAVEN_JAVADOC_ARGS env var is used to dynamically pass
# args to the mvn command. this can be used to direct maven to use
# a mirror, in case we encounter rate limiting from maven central
mvn clean javadoc:javadoc ${MAVEN_JAVADOC_ARGS} -q
popd
rm -rf build/html/java_api/
mkdir -p build/html/java_api/
cp -r ../../mlflow/java/client/target/site/apidocs/* build/html/java_api/
echo "Copied JavaDoc into docs/build/html/java_api/"
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -ex
pushd ../../mlflow/R/mlflow
image_name="mlflow-r-dev"
docker build -f Dockerfile.dev -t $image_name . --platform linux/amd64
docker run \
--rm \
-v $(pwd):/mlflow/mlflow/R/mlflow \
-v $(pwd)/../../../docs/api_reference/source:/mlflow/docs/api_reference/source \
$image_name \
Rscript -e 'source(".build-doc.R", echo = TRUE)'
popd
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
set -ex
# Function to build TypeDoc for a package
build_tsdoc() {
local package_path=$1
local package_name=$2
local output_path=$3
echo "Building TypeDoc for $package_name..."
# Store the absolute path to the analytics file before changing directories
local analytics_js_path="$(cd "$(dirname "$0")" && pwd)/typedoc-analytics.js"
pushd "$package_path"
# Generate TypeDoc documentation
npm exec -- typedoc \
--out "$output_path" \
--name "$package_name" \
--readme README.md \
--tsconfig tsconfig.json \
--excludePrivate \
--excludeProtected \
--excludeExternals \
--includeVersion \
--searchInComments \
--navigation \
--excludeNotDocumented false \
--customJs "$analytics_js_path" \
src/index.ts
popd
}
# Base paths
TYPESCRIPT_BASE="../../libs/typescript"
DOCS_OUTPUT_BASE="build/html/typescript_api"
# First ensure dependencies are installed at workspace root
echo "Ensuring TypeScript workspace dependencies are installed..."
pushd "$TYPESCRIPT_BASE"
npm ci
popd
# Remove existing docs if they exist
rm -rf "$DOCS_OUTPUT_BASE"
# Create output directory
mkdir -p "$DOCS_OUTPUT_BASE"
# Build documentation for @mlflow/core
build_tsdoc \
"$TYPESCRIPT_BASE/core" \
"@mlflow/core" \
"$(pwd)/$DOCS_OUTPUT_BASE/mlflow-core"
# Build documentation for @mlflow/openai
build_tsdoc \
"$TYPESCRIPT_BASE/integrations/openai" \
"@mlflow/openai" \
"$(pwd)/$DOCS_OUTPUT_BASE/mlflow-openai"
# Copy the HTML template to create index.html
cp "$(dirname "$0")/tsdoc.index.html.template" "$DOCS_OUTPUT_BASE/index.html"
echo "Copied TypeScript documentation into docs/build/html/typescript_api/"
+28
View File
@@ -0,0 +1,28 @@
import os
import pytest
import mlflow
@pytest.fixture(autouse=True)
def tracking_uri_mock(tmp_path, monkeypatch):
tracking_uri = "sqlite:///{}".format(tmp_path / "mlruns.sqlite")
mlflow.set_tracking_uri(tracking_uri)
monkeypatch.setenv("MLFLOW_TRACKING_URI", tracking_uri)
yield
mlflow.set_tracking_uri(None)
@pytest.fixture(autouse=True)
def reset_active_experiment_id():
yield
mlflow.tracking.fluent._active_experiment_id = None
os.environ.pop("MLFLOW_EXPERIMENT_ID", None)
@pytest.fixture(autouse=True)
def reset_mlflow_uri():
yield
os.environ.pop("MLFLOW_TRACKING_URI", None)
os.environ.pop("MLFLOW_REGISTRY_URI", None)
+93
View File
@@ -0,0 +1,93 @@
import json
import tempfile
from pathlib import Path
from mlflow.gateway.app import create_app_from_path
# This HTML was obtained by sending a request to the `/docs` route and saving the response.
# To hide the "try it out" button, we set `supportedSubmitMethods` to an empty list.
# The url was changed to "./openapi.json" from "/openapi.json" because `api.html` and `openapi.json`
# are served from the same directory.
API_HTML = """
<!DOCTYPE html>
<html>
<head>
<link
type="text/css"
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css"
/>
<link
rel="shortcut icon"
href="../_static/favicon.ico"
/>
<title>MLflow AI Gateway - Swagger UI</title>
</head>
<body>
<div id="swagger-ui"></div>
<script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui-bundle.js"></script>
<!-- `SwaggerUIBundle` is now available on the page -->
<script>
const ui = SwaggerUIBundle({
supportedSubmitMethods: [],
url: "./openapi.json",
dom_id: "#swagger-ui",
layout: "BaseLayout",
deepLinking: true,
showExtensions: true,
showCommonExtensions: true,
oauth2RedirectUrl: window.location.origin + "/docs/oauth2-redirect",
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset,
],
});
</script>
</body>
</html>
"""
def main():
config = """
endpoints:
- name: chat
endpoint_type: llm/v1/chat
model:
provider: openai
name: gpt-4o-mini
config:
openai_api_key: key
- name: completions
endpoint_type: llm/v1/completions
model:
provider: openai
name: gpt-4o-mini
config:
openai_api_key: key
- name: embeddings
endpoint_type: llm/v1/embeddings
model:
provider: openai
name: text-embedding-ada-002
config:
openai_api_key: key
"""
with tempfile.TemporaryDirectory() as tmpdir:
config_path = Path(tmpdir).joinpath("config.yaml")
config_path.write_text(config)
app = create_app_from_path(config_path)
docs_build = Path("build/html/llms/deployments")
docs_build.mkdir(parents=True, exist_ok=True)
with docs_build.joinpath("openapi.json").open("w") as f:
json.dump(app.openapi(), f)
with docs_build.joinpath("api.html").open("w") as f:
f.write(API_HTML)
if __name__ == "__main__":
main()
@@ -0,0 +1,19 @@
---
title: MLflow Tracking
---
flowchart LR
id4[(Datalake)]
A[Data Prep] -->B[Train]
B --> id1
B --> B
id1 --> C
C[Review & Select]
C --> id2
C --> B
id2 --> D[Deploy]
D --> E[Monitor]
E --> id4
id4 --> A
id1[(Tracking backend)]
id2[(Model Registry)]
+281
View File
@@ -0,0 +1,281 @@
@ECHO OFF
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set BUILDDIR=build
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source
set I18NSPHINXOPTS=%SPHINXOPTS% source
if NOT "%PAPER%" == "" (
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
)
if "%1" == "" goto help
if "%1" == "help" (
:help
echo.Please use `make ^<target^>` where ^<target^> is one of
echo. html to make standalone HTML files
echo. dirhtml to make HTML files named index.html in directories
echo. singlehtml to make a single large HTML file
echo. pickle to make pickle files
echo. json to make JSON files
echo. htmlhelp to make HTML files and a HTML help project
echo. qthelp to make HTML files and a qthelp project
echo. devhelp to make HTML files and a Devhelp project
echo. epub to make an epub
echo. epub3 to make an epub3
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
echo. text to make text files
echo. man to make manual pages
echo. texinfo to make Texinfo files
echo. gettext to make PO message catalogs
echo. changes to make an overview over all changed/added/deprecated items
echo. xml to make Docutils-native XML files
echo. pseudoxml to make pseudoxml-XML files for display purposes
echo. linkcheck to check all external links for integrity
echo. doctest to run all doctests embedded in the documentation if enabled
echo. coverage to run coverage check of the documentation if enabled
echo. dummy to check syntax errors of document sources
goto end
)
if "%1" == "clean" (
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
del /q /s %BUILDDIR%\*
goto end
)
REM Check if sphinx-build is available and fallback to Python version if any
%SPHINXBUILD% 1>NUL 2>NUL
if errorlevel 9009 goto sphinx_python
goto sphinx_ok
:sphinx_python
set SPHINXBUILD=python -m sphinx.__init__
%SPHINXBUILD% 2> nul
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
:sphinx_ok
if "%1" == "html" (
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
goto end
)
if "%1" == "dirhtml" (
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
goto end
)
if "%1" == "singlehtml" (
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
goto end
)
if "%1" == "pickle" (
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the pickle files.
goto end
)
if "%1" == "json" (
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the JSON files.
goto end
)
if "%1" == "htmlhelp" (
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run HTML Help Workshop with the ^
.hhp project file in %BUILDDIR%/htmlhelp.
goto end
)
if "%1" == "qthelp" (
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run "qcollectiongenerator" with the ^
.qhcp project file in %BUILDDIR%/qthelp, like this:
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\twitterpandas.qhcp
echo.To view the help file:
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\twitterpandas.ghc
goto end
)
if "%1" == "devhelp" (
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished.
goto end
)
if "%1" == "epub" (
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The epub file is in %BUILDDIR%/epub.
goto end
)
if "%1" == "epub3" (
%SPHINXBUILD% -b epub3 %ALLSPHINXOPTS% %BUILDDIR%/epub3
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The epub3 file is in %BUILDDIR%/epub3.
goto end
)
if "%1" == "latex" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
if errorlevel 1 exit /b 1
echo.
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "latexpdf" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
cd %BUILDDIR%/latex
make all-pdf
cd %~dp0
echo.
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "latexpdfja" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
cd %BUILDDIR%/latex
make all-pdf-ja
cd %~dp0
echo.
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "text" (
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The text files are in %BUILDDIR%/text.
goto end
)
if "%1" == "man" (
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The manual pages are in %BUILDDIR%/man.
goto end
)
if "%1" == "texinfo" (
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
goto end
)
if "%1" == "gettext" (
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
goto end
)
if "%1" == "changes" (
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
if errorlevel 1 exit /b 1
echo.
echo.The overview file is in %BUILDDIR%/changes.
goto end
)
if "%1" == "linkcheck" (
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
if errorlevel 1 exit /b 1
echo.
echo.Link check complete; look for any errors in the above output ^
or in %BUILDDIR%/linkcheck/output.txt.
goto end
)
if "%1" == "doctest" (
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
if errorlevel 1 exit /b 1
echo.
echo.Testing of doctests in the sources finished, look at the ^
results in %BUILDDIR%/doctest/output.txt.
goto end
)
if "%1" == "coverage" (
%SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage
if errorlevel 1 exit /b 1
echo.
echo.Testing of coverage in the sources finished, look at the ^
results in %BUILDDIR%/coverage/python.txt.
goto end
)
if "%1" == "xml" (
%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The XML files are in %BUILDDIR%/xml.
goto end
)
if "%1" == "pseudoxml" (
%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
goto end
)
if "%1" == "dummy" (
%SPHINXBUILD% -b dummy %ALLSPHINXOPTS% %BUILDDIR%/dummy
if errorlevel 1 exit /b 1
echo.
echo.Build finished. Dummy builder generates no files.
goto end
)
:end
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

@@ -0,0 +1,3 @@
<svg height="1024" width="896" xmlns="http://www.w3.org/2000/svg">
<path d="M128 768h256v64H128v-64z m320-384H128v64h320v-64z m128 192V448L384 640l192 192V704h320V576H576z m-288-64H128v64h160v-64zM128 704h160v-64H128v64z m576 64h64v128c-1 18-7 33-19 45s-27 18-45 19H64c-35 0-64-29-64-64V192c0-35 29-64 64-64h192C256 57 313 0 384 0s128 57 128 128h192c35 0 64 29 64 64v320h-64V320H64v576h640V768zM128 256h512c0-35-29-64-64-64h-64c-35 0-64-29-64-64s-29-64-64-64-64 29-64 64-29 64-64 64h-64c-35 0-64 29-64 64z" />
</svg>

After

Width:  |  Height:  |  Size: 519 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<svg width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M896 128q209 0 385.5 103t279.5 279.5 103 385.5-103 385.5-279.5 279.5-385.5 103-385.5-103-279.5-279.5-103-385.5 103-385.5 279.5-279.5 385.5-103zm128 1247v-190q0-14-9-23.5t-22-9.5h-192q-13 0-23 10t-10 23v190q0 13 10 23t23 10h192q13 0 22-9.5t9-23.5zm-2-344l18-621q0-12-10-18-10-8-24-8h-220q-14 0-24 8-10 6-10 18l17 621q0 10 10 17.5t24 7.5h185q14 0 23.5-7.5t10.5-17.5z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 524 B

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="19px" height="16px" viewBox="0 0 19 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 40 (33762) - http://www.bohemiancoding.com/sketch -->
<title>house</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="1" transform="translate(-11.000000, -237.000000)" stroke-width="1.5" stroke="#0193E1">
<g id="leftnav" transform="translate(0.000000, 74.000000)">
<g id="house" transform="translate(12.000000, 164.000000)">
<g id="Group-5">
<polyline id="Stroke-1" points="3 4.10584211 3 13.9431579 14 13.9431579 14 4.10584211"></polyline>
<polyline id="Stroke-3" points="17 6.71168421 8.5004837 0.5 0 6.71168421"></polyline>
</g>
<path d="M8.75,13.5 L8.75,10.5" id="Line" stroke-linecap="square"></path>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<svg width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M532 1108l152 152-52 52h-56v-96h-96v-56zm414-390q14 13-3 30l-291 291q-17 17-30 3-14-13 3-30l291-291q17-17 30-3zm-274 690l544-544-288-288-544 544v288h288zm608-608l92-92q28-28 28-68t-28-68l-152-152q-28-28-68-28t-68 28l-92 92zm384-384v960q0 119-84.5 203.5t-203.5 84.5h-960q-119 0-203.5-84.5t-84.5-203.5v-960q0-119 84.5-203.5t203.5-84.5h960q119 0 203.5 84.5t84.5 203.5z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 526 B

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<svg width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1120 576q0 13-9.5 22.5t-22.5 9.5-22.5-9.5-9.5-22.5q0-46-54-71t-106-25q-13 0-22.5-9.5t-9.5-22.5 9.5-22.5 22.5-9.5q50 0 99.5 16t87 54 37.5 90zm160 0q0-72-34.5-134t-90-101.5-123-62-136.5-22.5-136.5 22.5-123 62-90 101.5-34.5 134q0 101 68 180 10 11 30.5 33t30.5 33q128 153 141 298h228q13-145 141-298 10-11 30.5-33t30.5-33q68-79 68-180zm128 0q0 155-103 268-45 49-74.5 87t-59.5 95.5-34 107.5q47 28 47 82 0 37-25 64 25 27 25 64 0 52-45 81 13 23 13 47 0 46-31.5 71t-77.5 25q-20 44-60 70t-87 26-87-26-60-70q-46 0-77.5-25t-31.5-71q0-24 13-47-45-29-45-81 0-37 25-64-25-27-25-64 0-54 47-82-4-50-34-107.5t-59.5-95.5-74.5-87q-103-113-103-268 0-99 44.5-184.5t117-142 164-89 186.5-32.5 186.5 32.5 164 89 117 142 44.5 184.5z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 868 B

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<svg width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1024 1375v-190q0-14-9.5-23.5t-22.5-9.5h-192q-13 0-22.5 9.5t-9.5 23.5v190q0 14 9.5 23.5t22.5 9.5h192q13 0 22.5-9.5t9.5-23.5zm-2-374l18-459q0-12-10-19-13-11-24-11h-220q-11 0-24 11-10 7-10 21l17 457q0 10 10 16.5t24 6.5h185q14 0 23.5-6.5t10.5-16.5zm-14-934l768 1408q35 63-2 126-17 29-46.5 46t-63.5 17h-1536q-34 0-63.5-17t-46.5-46q-37-63-2-126l768-1408q17-31 47-49t65-18 65 18 47 49z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 539 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

@@ -0,0 +1,20 @@
document.addEventListener("DOMContentLoaded", function () {
var script = document.createElement("script");
script.type = "module";
script.id = "runllm-widget-script"
script.src = "https://widget.runllm.com";
script.setAttribute("runllm-keyboard-shortcut", "Mod+j"); // cmd-j or ctrl-j to open the widget.
script.setAttribute("runllm-name", "MLflow");
script.setAttribute("runllm-position", "BOTTOM_RIGHT");
script.setAttribute("runllm-assistant-id", "116");
script.setAttribute("runllm-theme-color", "#008ED9");
script.setAttribute("runllm-brand-logo", "https://mlflow.org/img/mlflow-favicon.ico");
script.setAttribute("runllm-community-type", "slack");
script.setAttribute("runllm-community-url", "https://mlflow.org/slack");
script.setAttribute("runllm-disable-ask-a-person", "true");
script.async = true;
document.head.appendChild(script);
});
@@ -0,0 +1,22 @@
.. _auth-python-api:
================================
MLflow Authentication Python API
================================
mlflow.server.auth.client
=========================
.. autoclass:: mlflow.server.auth.client.AuthServiceClient()
:members:
:undoc-members:
:show-inheritance:
mlflow.server.auth.entities
===========================
.. automodule:: mlflow.server.auth.entities
:members:
:undoc-members:
:show-inheritance:
+503
View File
@@ -0,0 +1,503 @@
.. _auth-rest-api:
==============================
MLflow Authentication REST API
==============================
The MLflow Authentication REST API allows you to create, get, update and delete users,
experiment permissions and registered model permissions.
The API is hosted under the ``/api`` route on the MLflow tracking server. For example, to list
experiments on a tracking server hosted at ``http://localhost:5000``, access
``http://localhost:5000/api/2.0/mlflow/users/create``.
.. important::
The MLflow REST API requires content type ``application/json`` for all POST requests.
.. contents:: Table of Contents
:local:
:depth: 1
===========================
.. _mlflowAuthServiceCreateUser:
Create User
===========
+-----------------------------+-------------+
| Endpoint | HTTP Method |
+=============================+=============+
| ``2.0/mlflow/users/create`` | ``POST`` |
+-----------------------------+-------------+
.. _mlflowCreateUser:
Request Structure
-----------------
+------------+------------+-------------+
| Field Name | Type | Description |
+============+============+=============+
| username | ``STRING`` | Username. |
+------------+------------+-------------+
| password | ``STRING`` | Password. |
+------------+------------+-------------+
.. _mlflowCreateUserResponse:
Response Structure
------------------
+------------+-------------------+----------------+
| Field Name | Type | Description |
+============+===================+================+
| user | :ref:`mlflowUser` | A user object. |
+------------+-------------------+----------------+
===========================
.. _mlflowAuthServiceGetUser:
Get User
========
+--------------------------+-------------+
| Endpoint | HTTP Method |
+==========================+=============+
| ``2.0/mlflow/users/get`` | ``GET`` |
+--------------------------+-------------+
.. _mlflowGetUser:
Request Structure
-----------------
+------------+------------+-------------+
| Field Name | Type | Description |
+============+============+=============+
| username | ``STRING`` | Username. |
+------------+------------+-------------+
.. _mlflowGetUserResponse:
Response Structure
------------------
+------------+-------------------+----------------+
| Field Name | Type | Description |
+============+===================+================+
| user | :ref:`mlflowUser` | A user object. |
+------------+-------------------+----------------+
===========================
.. _mlflowAuthServiceUpdateUserPassword:
Update User Password
====================
+--------------------------------------+-------------+
| Endpoint | HTTP Method |
+======================================+=============+
| ``2.0/mlflow/users/update-password`` | ``PATCH`` |
+--------------------------------------+-------------+
.. _mlflowUpdateUserPassword:
Request Structure
-----------------
+------------+------------+---------------+
| Field Name | Type | Description |
+============+============+===============+
| username | ``STRING`` | Username. |
+------------+------------+---------------+
| password | ``STRING`` | New password. |
+------------+------------+---------------+
===========================
.. _mlflowAuthServiceUpdateUserAdmin:
Update User Admin
=================
+-----------------------------------+-------------+
| Endpoint | HTTP Method |
+===================================+=============+
| ``2.0/mlflow/users/update-admin`` | ``PATCH`` |
+-----------------------------------+-------------+
.. _mlflowUpdateUserAdmin:
Request Structure
-----------------
+------------+-------------+-------------------+
| Field Name | Type | Description |
+============+=============+===================+
| username | ``STRING`` | Username. |
+------------+-------------+-------------------+
| is_admin | ``BOOLEAN`` | New admin status. |
+------------+-------------+-------------------+
===========================
.. _mlflowAuthServiceDeleteUser:
Delete User
===========
+-----------------------------+-------------+
| Endpoint | HTTP Method |
+=============================+=============+
| ``2.0/mlflow/users/delete`` | ``DELETE`` |
+-----------------------------+-------------+
.. _mlflowDeleteUser:
Request Structure
-----------------
+------------+------------+-------------+
| Field Name | Type | Description |
+============+============+=============+
| username | ``STRING`` | Username. |
+------------+------------+-------------+
===========================
.. _mlflowAuthServiceCreateExperimentPermission:
Create Experiment Permission
============================
+-----------------------------------------------+-------------+
| Endpoint | HTTP Method |
+===============================================+=============+
| ``2.0/mlflow/experiments/permissions/create`` | ``POST`` |
+-----------------------------------------------+-------------+
.. _mlflowCreateExperimentPermission:
Request Structure
-----------------
+---------------+-------------------------+----------------------+
| Field Name | Type | Description |
+===============+=========================+======================+
| experiment_id | ``STRING`` | Experiment id. |
+---------------+-------------------------+----------------------+
| username | ``STRING`` | Username. |
+---------------+-------------------------+----------------------+
| permission | :ref:`mlflowPermission` | Permission to grant. |
+---------------+-------------------------+----------------------+
.. _mlflowCreateExperimentPermissionResponse:
Response Structure
------------------
+-----------------------+-----------------------------------+----------------------------------+
| Field Name | Type | Description |
+=======================+===================================+==================================+
| experiment_permission | :ref:`mlflowExperimentPermission` | An experiment permission object. |
+-----------------------+-----------------------------------+----------------------------------+
===========================
.. _mlflowAuthServiceGetExperimentPermission:
Get Experiment Permission
=========================
+--------------------------------------------+-------------+
| Endpoint | HTTP Method |
+============================================+=============+
| ``2.0/mlflow/experiments/permissions/get`` | ``GET`` |
+--------------------------------------------+-------------+
.. _mlflowGetExperimentPermission:
Request Structure
-----------------
+---------------+------------+----------------+
| Field Name | Type | Description |
+===============+============+================+
| experiment_id | ``STRING`` | Experiment id. |
+---------------+------------+----------------+
| username | ``STRING`` | Username. |
+---------------+------------+----------------+
.. _mlflowGetExperimentPermissionResponse:
Response Structure
------------------
+-----------------------+-----------------------------------+----------------------------------+
| Field Name | Type | Description |
+=======================+===================================+==================================+
| experiment_permission | :ref:`mlflowExperimentPermission` | An experiment permission object. |
+-----------------------+-----------------------------------+----------------------------------+
===========================
.. _mlflowAuthServiceUpdateExperimentPermission:
Update Experiment Permission
============================
+-----------------------------------------------+-------------+
| Endpoint | HTTP Method |
+===============================================+=============+
| ``2.0/mlflow/experiments/permissions/update`` | ``PATCH`` |
+-----------------------------------------------+-------------+
.. _mlflowUpdateExperimentPermission:
Request Structure
-----------------
+---------------+-------------------------+--------------------------+
| Field Name | Type | Description |
+===============+=========================+==========================+
| experiment_id | ``STRING`` | Experiment id. |
+---------------+-------------------------+--------------------------+
| username | ``STRING`` | Username. |
+---------------+-------------------------+--------------------------+
| permission | :ref:`mlflowPermission` | New permission to grant. |
+---------------+-------------------------+--------------------------+
===========================
.. _mlflowAuthServiceDeleteExperimentPermission:
Delete Experiment Permission
============================
+-----------------------------------------------+-------------+
| Endpoint | HTTP Method |
+===============================================+=============+
| ``2.0/mlflow/experiments/permissions/delete`` | ``DELETE`` |
+-----------------------------------------------+-------------+
.. _mlflowDeleteExperimentPermission:
Request Structure
-----------------
+---------------+------------+----------------+
| Field Name | Type | Description |
+===============+============+================+
| experiment_id | ``STRING`` | Experiment id. |
+---------------+------------+----------------+
| username | ``STRING`` | Username. |
+---------------+------------+----------------+
===========================
.. _mlflowAuthServiceCreateRegisteredModelPermission:
Create Registered Model Permission
==================================
+-----------------------------------------------------+-------------+
| Endpoint | HTTP Method |
+=====================================================+=============+
| ``2.0/mlflow/registered-models/permissions/create`` | ``CREATE`` |
+-----------------------------------------------------+-------------+
.. _mlflowCreateRegisteredModelPermission:
Request Structure
-----------------
+------------+-------------------------+------------------------+
| Field Name | Type | Description |
+============+=========================+========================+
| name | ``STRING`` | Registered model name. |
+------------+-------------------------+------------------------+
| username | ``STRING`` | Username. |
+------------+-------------------------+------------------------+
| permission | :ref:`mlflowPermission` | Permission to grant. |
+------------+-------------------------+------------------------+
.. _mlflowCreateRegisteredModelPermissionResponse:
Response Structure
------------------
+-----------------------------+----------------------------------------+---------------------------------------+
| Field Name | Type | Description |
+=============================+========================================+=======================================+
| registered_model_permission | :ref:`mlflowRegisteredModelPermission` | A registered model permission object. |
+-----------------------------+----------------------------------------+---------------------------------------+
===========================
.. _mlflowAuthServiceGetRegisteredModelPermission:
Get Registered Model Permission
===============================
+--------------------------------------------------+-------------+
| Endpoint | HTTP Method |
+==================================================+=============+
| ``2.0/mlflow/registered-models/permissions/get`` | ``GET`` |
+--------------------------------------------------+-------------+
.. _mlflowGetRegisteredModelPermission:
Request Structure
-----------------
+------------+------------+------------------------+
| Field Name | Type | Description |
+============+============+========================+
| name | ``STRING`` | Registered model name. |
+------------+------------+------------------------+
| username | ``STRING`` | Username. |
+------------+------------+------------------------+
.. _mlflowGetRegisteredModelPermissionResponse:
Response Structure
------------------
+-----------------------------+----------------------------------------+---------------------------------------+
| Field Name | Type | Description |
+=============================+========================================+=======================================+
| registered_model_permission | :ref:`mlflowRegisteredModelPermission` | A registered model permission object. |
+-----------------------------+----------------------------------------+---------------------------------------+
===========================
.. _mlflowAuthServiceUpdateRegisteredModelPermission:
Update Registered Model Permission
==================================
+-----------------------------------------------------+-------------+
| Endpoint | HTTP Method |
+=====================================================+=============+
| ``2.0/mlflow/registered-models/permissions/update`` | ``PATCH`` |
+-----------------------------------------------------+-------------+
.. _mlflowUpdateRegisteredModelPermission:
Request Structure
-----------------
+------------+-------------------------+--------------------------+
| Field Name | Type | Description |
+============+=========================+==========================+
| name | ``STRING`` | Registered model name. |
+------------+-------------------------+--------------------------+
| username | ``STRING`` | Username. |
+------------+-------------------------+--------------------------+
| permission | :ref:`mlflowPermission` | New permission to grant. |
+------------+-------------------------+--------------------------+
===========================
.. _mlflowAuthServiceDeleteRegisteredModelPermission:
Delete Registered Model Permission
==================================
+-----------------------------------------------------+-------------+
| Endpoint | HTTP Method |
+=====================================================+=============+
| ``2.0/mlflow/registered-models/permissions/delete`` | ``DELETE`` |
+-----------------------------------------------------+-------------+
.. _mlflowDeleteRegisteredModelPermission:
Request Structure
-----------------
+------------+------------+------------------------+
| Field Name | Type | Description |
+============+============+========================+
| name | ``STRING`` | Registered model name. |
+------------+------------+------------------------+
| username | ``STRING`` | Username. |
+------------+------------+------------------------+
.. _auth-rest-struct:
Data Structures
===============
.. _mlflowUser:
User
----
+------------------------------+----------------------------------------------------+------------------------------------------------------------------+
| Field Name | Type | Description |
+==============================+====================================================+==================================================================+
| id | ``STRING`` | User ID. |
+------------------------------+----------------------------------------------------+------------------------------------------------------------------+
| username | ``STRING`` | Username. |
+------------------------------+----------------------------------------------------+------------------------------------------------------------------+
| is_admin | ``BOOLEAN`` | Whether the user is an admin. |
+------------------------------+----------------------------------------------------+------------------------------------------------------------------+
| experiment_permissions | An array of :ref:`mlflowExperimentPermission` | All experiment permissions explicitly granted to the user. |
+------------------------------+----------------------------------------------------+------------------------------------------------------------------+
| registered_model_permissions | An array of :ref:`mlflowRegisteredModelPermission` | All registered model permissions explicitly granted to the user. |
+------------------------------+----------------------------------------------------+------------------------------------------------------------------+
.. _mlflowPermission:
Permission
----------
Permission of a user to an experiment or a registered model.
+----------------+--------------------------------------+
| Name | Description |
+================+======================================+
| READ | Can read. |
+----------------+--------------------------------------+
| EDIT | Can read and update. |
+----------------+--------------------------------------+
| MANAGE | Can read, update, delete and manage. |
+----------------+--------------------------------------+
| NO_PERMISSIONS | No permissions. |
+----------------+--------------------------------------+
.. _mlflowExperimentPermission:
ExperimentPermission
--------------------
+---------------+-------------------------+---------------------+
| Field Name | Type | Description |
+===============+=========================+=====================+
| experiment_id | ``STRING`` | Experiment id. |
+---------------+-------------------------+---------------------+
| user_id | ``STRING`` | User id. |
+---------------+-------------------------+---------------------+
| permission | :ref:`mlflowPermission` | Permission granted. |
+---------------+-------------------------+---------------------+
.. _mlflowRegisteredModelPermission:
RegisteredModelPermission
-------------------------
+------------+-------------------------+------------------------+
| Field Name | Type | Description |
+============+=========================+========================+
| name | ``STRING`` | Registered model name. |
+------------+-------------------------+------------------------+
| user_id | ``STRING`` | User id. |
+------------+-------------------------+------------------------+
| permission | :ref:`mlflowPermission` | Permission granted. |
+------------+-------------------------+------------------------+
+27
View File
@@ -0,0 +1,27 @@
.. _cli:
Command-Line Interface
======================
The MLflow command-line interface (CLI) provides a simple interface to various functionality in MLflow. You can use the CLI to run projects, start the tracking UI, create and list experiments, download run artifacts,
serve MLflow Python Function and scikit-learn models, serve MLflow Python Function and scikit-learn models, and serve models on
`Microsoft Azure Machine Learning <https://azure.microsoft.com/en-us/services/machine-learning-service/>`_
and `Amazon SageMaker <https://aws.amazon.com/sagemaker/>`_.
Each individual command has a detailed help screen accessible via ``mlflow command_name --help``.
.. attention::
It is advisable to set the ``MLFLOW_TRACKING_URI`` environment variable by default,
as the CLI does not automatically connect to a tracking server. Without this,
the CLI will default to using the local filesystem where the command is executed,
rather than connecting to a localhost or remote HTTP server.
Setting ``MLFLOW_TRACKING_URI`` to the URL of your desired tracking server is required for most of the commands below.
.. contents:: Table of Contents
:local:
:depth: 2
.. click:: mlflow.cli:cli
:prog: mlflow
:show-nested:
+466
View File
@@ -0,0 +1,466 @@
#
# MLflow documentation build configuration file, created by
# cookiecutter pipproject
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import os
import subprocess
import sys
from pathlib import Path
from sphinx.application import Sphinx
from sphinx.environment import BuildEnvironment
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath("../.."))
sys.path.insert(0, os.path.abspath("."))
import languagesections
import sphinx.ext.napoleon as _napoleon
from docutils.nodes import Text
from docutils.parsers.rst import directives
from sphinx.addnodes import pending_xref
from sphinx.directives.code import CodeBlock
import mlflow
# Pydantic's BaseModel always has MockValSer placeholders for __pydantic_validator__ and
# __pydantic_serializer__. Accessing __qualname__ on them raises PydanticUserError instead
# of AttributeError, crashing Napoleon's _skip_member. Wrap it before Napoleon's setup()
# registers it so MockValSer objects are silently skipped.
_original_napoleon_skip_member = _napoleon._skip_member
def _napoleon_skip_member_safe(app, what, name, obj, skip, options):
if "MockValSer" in type(obj).__name__:
return True
return _original_napoleon_skip_member(app, what, name, obj, skip, options)
_napoleon._skip_member = _napoleon_skip_member_safe
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"sphinx_click.ext",
"sphinx_tabs.tabs",
"sphinx_reredirects",
]
# Redirects definition in the form of ``("source", "target")``.
# Note that the target is relative to the path of the source and that the
# target must define the final url (i.e. no trailing slash).
redirects = {
"registry": "model-registry.html",
"llms/gateway": "../deployments",
"llms/gateway/index.html": "../deployments/index.html",
"llms/gateway/guides/index.html": "../../deployments/guides/index.html",
"llms/gateway/guides/step1-create-gateway.html": "../../deployments/guides/step1-create-deployments.html",
"llms/gateway/guides/step2-query-gateway.html": "../../deployments/guides/step2-query-deployments.html",
}
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = ".rst"
# The encoding of source files.
# source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = "index"
# General information about the project.
project = "MLflow"
copyright = "MLflow Project, a Series of LF Projects, LLC. All rights reserved"
author = "MLflow"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
import mlflow.version
# The short X.Y version.
version = mlflow.version.VERSION
# The full version, including alpha/beta/rc tags.
release = mlflow.version.VERSION
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
# today = ''
# Else, today_fmt is used as the format for a strftime call.
# today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
# We exclude "registry.rst" because it is an orphan redirect
exclude_patterns = ["registry.rst"]
# The reST default role (used for this markup: `text`) to use for all
# documents.
# default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
# add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
# add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
# show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"
# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
# keep_warnings = False
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_context = {
"gtm_id": os.environ.get("GTM_ID", ""),
}
html_theme_path = ["../theme/"]
html_theme = "mlflow"
html_favicon = "_static/favicon.ico"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
# html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []
# The name for this set of Sphinx documents.
# "<project> v<release> documentation" by default.
# html_title = 'MLflow v0.0.1'
# A shorter title for the navigation bar. Default is the same as html_title.
# html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
# html_logo = None
# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
# html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
html_js_files = ["runllm.js"]
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
# html_extra_path = []
# If not None, a 'Last updated on:' timestamp is inserted at every page
# bottom, using the given strftime format.
# The empty string is equivalent to '%b %d, %Y'.
# html_last_updated_fmt = None
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
# html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
# html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
# html_additional_pages = {}
# If false, no module index is generated.
# html_domain_indices = True
# If false, no index is generated.
# html_use_index = True
# If true, the index is split into individual pages for each letter.
# html_split_index = False
# If true, links to the reST sources are added to the pages.
html_show_sourcelink = False
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
html_show_sphinx = False
html_permalinks_icon = " "
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
# html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
# html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
# html_file_suffix = None
# Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr', 'zh'
# html_search_language = 'en'
# A dictionary with options for the search language support, empty by default.
# 'ja' uses this config value.
# 'zh' user can custom change `jieba` dictionary path.
# html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used.
# html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder.
# Ref: https://sphinx-tabs.readthedocs.io/en/latest/#sphinx-configuration
htmlhelp_basename = "MLflowdoc"
# Disable closing tab for sphinx-tab extension.
sphinx_tabs_disable_tab_closing = True
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
# 'preamble': '',
# Latex figure (float) alignment
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, "MLflow.tex", "MLflow Documentation", "Databricks", "manual"),
]
# Mock torch imports as per suggestion in
# https://github.com/sphinx-doc/sphinx/issues/6521#issuecomment-505765893
autodoc_mock_imports = [
"torch",
"pytorch_lightning",
"langchain_core",
"langgraph",
"langchain_community",
"langchain_community.chat_models",
"langchain_community.llms",
"ragas",
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
# latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
# latex_use_parts = False
# If true, show page references after internal links.
# latex_show_pagerefs = False
# If true, show URL addresses after external links.
# latex_show_urls = False
# Documents to append as an appendix to all manuals.
# latex_appendices = []
# If false, no module index is generated.
# latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "MLflow", "MLflow Documentation", [author], 1)]
# If true, show URL addresses after external links.
# man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(
master_doc,
"MLflow",
"MLflow Documentation",
author,
"MLflow",
"End-to-end machine learning toolkit.",
"Miscellaneous",
),
]
# Documents to append as an appendix to all manuals.
# texinfo_appendices = []
# If false, no module index is generated.
# texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
# texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
# texinfo_no_detailmenu = False
# Enable nitpicky mode to log warnings for broken references
nitpicky = True
nitpick_ignore_regex = [
("py:class", r".+"),
]
def _get_reference_map():
"""
Sphinx computes references for type annotations using fully-qualified classnames,
so references in undocumented modules (even if the referenced object is exposed via
a different module from the one it's defined in) are considered invalid by Sphinx.
Example:
```
def start_run(...) -> ActiveRun:
# ActiveRun is defined in `mlflow/tracking/fluent.py`
...
```
For this code, Sphinx tries to create a link for `ActiveRun` using
`mlflow.tracking.fluent.ActiveRun` as a reference target, but the module
`mlflow.tracking.fluent` is undocumented, so Sphinx raises this warning:
`WARNING: py:class reference target not found: mlflow.tracking.fluent.ActiveRun`.
As a workaround, replace `mlflow.tracking.fluent.ActiveRun` with `mlflow.ActiveRun`.
"""
ref_map = {
# < Invalid reference >: < valid reference >
"mlflow.tracking.fluent.ActiveRun": "mlflow.ActiveRun",
"mlflow.tracking.fluent.ActiveModel": "mlflow.ActiveModel",
"mlflow.store.entities.paged_list.PagedList": "mlflow.store.entities.PagedList",
}
# Tracking entities
for entity_name in mlflow.entities.__all__:
entity_cls = getattr(mlflow.entities, entity_name)
invalid_ref = entity_cls.__module__ + "." + entity_name
valid_ref = f"mlflow.entities.{entity_name}"
ref_map[invalid_ref] = valid_ref
# Model registry entities
for entity_name in mlflow.entities.model_registry.__all__:
entity_cls = getattr(mlflow.entities.model_registry, entity_name)
invalid_ref = entity_cls.__module__ + "." + entity_name
valid_ref = f"mlflow.entities.model_registry.{entity_name}"
ref_map[invalid_ref] = valid_ref
ref_map["mlflow.genai.scorers.base.Scorer"] = "mlflow.genai.Scorer"
return ref_map
REFERENCE_MAP = _get_reference_map()
def resolve_missing_references(app, doctree):
for node in doctree.traverse(condition=pending_xref):
missing_ref = node.get("reftarget", None)
if missing_ref is not None and missing_ref in REFERENCE_MAP:
real_ref = REFERENCE_MAP[missing_ref]
text_to_render = real_ref.split(".")[-1]
node["reftarget"] = real_ref
text_node = next(iter(node.traverse(lambda n: n.tagname == "#text")))
text_node.parent.replace(text_node, Text(text_to_render, ""))
def env_updated(app: Sphinx, env: BuildEnvironment) -> None:
items: list[str] = []
for _domain_name, domain in env.domains.items():
for _name, display_name, obj_type, _doc_name, _anchor, _priority in domain.get_objects():
if obj_type in ("function", "method", "class"):
items.append(display_name)
repo_root = subprocess.check_output(["git", "rev-parse", "--show-toplevel"], text=True).strip()
path = Path(repo_root, "docs", "api_reference", "api_inventory.txt")
if not path.parent.exists():
path.parent.mkdir(parents=True)
path.write_text("\n".join(sorted(items)) + "\n")
class TestCodeBlockDirective(CodeBlock):
"""
Overrides the `code-block` directive to accept the `:test:` option.
The actual test extraction is done by the standalone testcode_block.py script.
"""
option_spec = {**CodeBlock.option_spec, "test": directives.flag}
def setup(app):
languagesections.setup(app)
app.add_directive("code-block", TestCodeBlockDirective, override=True)
app.connect("doctree-read", resolve_missing_references)
app.connect("env-updated", env_updated)
linkcheck_ignore = [
# Ignore local URLs when validating external links
r"http://localhost:\d+/?",
]
+16
View File
@@ -0,0 +1,16 @@
MLflow API Docs
===============
This page hosts the API documentation for MLflow.
.. toctree::
:maxdepth: 1
python_api/index
typescript_api/index
cli
auth/python-api
auth/rest-api
R-api
java_api/index
rest-api
@@ -0,0 +1,6 @@
.. _java_api:
Java API
==========
This file is a placeholder. Javadoc is filled in by the build-javadoc.sh script, executed during "make html".
@@ -0,0 +1,57 @@
import os
from docutils import nodes
from docutils.parsers.rst import Directive
from sphinx.util import logging
from sphinx.util.osutil import copyfile
logger = logging.getLogger(__name__)
JS_FILE = "languagesections.js"
class CodeSectionDirective(Directive):
has_content = True
def run(self):
self.assert_has_content()
text = "\n".join(self.content)
node = nodes.container(text)
node["classes"].append("code-section")
self.add_name(node)
self.state.nested_parse(self.content, self.content_offset, node)
return [node]
class PlainSectionDirective(Directive):
has_content = True
def run(self):
self.assert_has_content()
text = "\n".join(self.content)
node = nodes.container(text)
node["classes"].append("plain-section")
self.add_name(node)
self.state.nested_parse(self.content, self.content_offset, node)
return [node]
def add_assets(app):
app.add_js_file(JS_FILE)
def copy_assets(app, exception):
if app.builder.name != "html" or exception:
return
logger.info("Copying examplecode stylesheet/javascript... ", nonl=True)
dest = os.path.join(app.builder.outdir, "_static", JS_FILE)
source = os.path.join(os.path.abspath(os.path.dirname(__file__)), JS_FILE)
copyfile(source, dest)
logger.info("done")
def setup(app):
app.add_directive("code-section", CodeSectionDirective)
app.add_directive("plain-section", PlainSectionDirective)
app.connect("builder-inited", add_assets)
app.connect("build-finished", copy_assets)
@@ -0,0 +1,80 @@
$(function() {
$('div.code-section').each(function() {
var example_sel = $('<ul />', { class: 'section-selector' });
var i = 0;
$('div[class^="highlight-"]', this).each(function() {
language_name = $(this).attr('class').substring(10).replace('notranslate', '');
language_name = language_name.charAt(0).toUpperCase() + language_name.substr(1);
var sel_item = $('<li />', {
class: $(this).attr('class'),
text: language_name
});
if (i++) {
$(this).hide();
} else {
sel_item.addClass('selected');
}
example_sel.append(sel_item);
$(this).addClass('example');
});
$(this).prepend(example_sel);
example_sel = null;
i = null;
});
$('div.plain-section').each(function() {
var example_sel = $('<ul />', { class: 'section-selector' });
var i = 0;
$('div.container', this).each(function() {
var language_name = $(this).attr('class').replace(' docutils container', '').trim();
language_name = language_name.charAt(0).toUpperCase() + language_name.substr(1);
var sel_item = $('<li />', {
class: $(this).attr('class'),
text: language_name
});
if (i++) {
$(this).hide();
} else {
sel_item.addClass('selected');
}
example_sel.append(sel_item);
$(this).addClass('example');
});
$(this).prepend(example_sel);
example_sel = null;
i = null;
});
$('div.code-section ul.section-selector li,div.plain-section ul.section-selector li').click(function(evt) {
evt.preventDefault();
var sel_class = $(this).attr('class')
.replace(' docutils container', '')
.replace('notranslate', '')
.replace(' selected', '');
$('ul.section-selector li').each(function() {
var parent = $(this).parent().parent();
var my_sel_class = sel_class;
// When the target language is not available, default to bash or python.
if (!$('div.' + sel_class, parent).length) {
if ($('div.highlight-bash', parent).length)
my_sel_class = 'highlight-bash';
else
my_sel_class = 'highlight-python';
}
$('div.example', parent).hide();
$('div.' + my_sel_class, parent).show();
$('ul.section-selector li', parent).removeClass('selected');
$('ul.section-selector li.' + my_sel_class, parent).addClass('selected');
});
});
});
@@ -0,0 +1,15 @@
:orphan:
mlflow.exceptions
=================
.. exception:: mlflow.exceptions.MlflowException(message, error_code=1, **kwargs)
Generic exception thrown when an MLflow operation fails
.. automodule:: mlflow.exceptions
:members:
:undoc-members:
:show-inheritance:
:exclude-members:
MlflowException
@@ -0,0 +1,33 @@
.. _python-api:
Python API
==========
The MLflow Python API is organized into the following modules. The most common functions are
exposed in the :py:mod:`mlflow` module, so we recommend starting there.
.. toctree::
:glob:
:maxdepth: 1
*
See also the :ref:`index of all functions and classes<genindex>`.
Log Levels
----------
MLflow Python APIs log information during execution using the Python Logging API. You can
configure the log level for MLflow logs using the following code snippet. Learn more about Python
log levels at the
`Python language logging guide <https://docs.python.org/3/howto/logging.html>`_.
.. code-block:: python
import logging
logger = logging.getLogger("mlflow")
# Set log level to debugging
logger.setLevel(logging.DEBUG)
@@ -0,0 +1,7 @@
mlflow.ag2
==========
.. automodule:: mlflow.ag2
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.agno
==================
.. automodule:: mlflow.agno
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.anthropic
================
.. automodule:: mlflow.anthropic
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.artifacts
================
.. automodule:: mlflow.artifacts
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.autogen
==============
.. automodule:: mlflow.autogen
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.bedrock
==============
.. automodule:: mlflow.bedrock
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.catboost
===============
.. automodule:: mlflow.catboost
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,9 @@
.. _mlflow.tracking:
mlflow.client
===============
.. automodule:: mlflow.client
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.config
==============
.. automodule:: mlflow.config
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.crewai
==============
.. automodule:: mlflow.crewai
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,169 @@
mlflow.data
============
The ``mlflow.data`` module helps you record your model training and evaluation datasets to
runs with MLflow Tracking, as well as retrieve dataset information from runs. It provides the
following important interfaces:
* :py:class:`Dataset <mlflow.data.dataset.Dataset>`: Represents a dataset used in model training or
evaluation, including features, targets, predictions, and metadata such as the dataset's name, digest (hash)
schema, profile, and source. You can log this metadata to a run in MLflow Tracking using
the :py:func:`mlflow.log_input()` API. ``mlflow.data`` provides APIs for constructing
:py:class:`Datasets <mlflow.data.dataset.Dataset>` from a variety of Python data objects, including
Pandas DataFrames (:py:func:`mlflow.data.from_pandas()`), NumPy arrays
(:py:func:`mlflow.data.from_numpy()`), Spark DataFrames (:py:func:`mlflow.data.from_spark()`
/ :py:func:`mlflow.data.load_delta()`), Polars DataFrames (:py:func:`mlflow.data.from_polars()`), and more.
* :py:func:`DatasetSource <mlflow.data.dataset_source.DatasetSource>`: Represents the source of a
dataset. For example, this may be a directory of files stored in S3, a Delta Table, or a web URL.
Each :py:class:`Dataset <mlflow.data.dataset.Dataset>` references the source from which it was
derived. A :py:class:`Dataset <mlflow.data.dataset.Dataset>`'s features and targets may differ
from the source if transformations and filtering were applied. You can get the
:py:func:`DatasetSource <mlflow.data.dataset_source.DatasetSource>` of a dataset logged to a
run in MLflow Tracking using the :py:func:`mlflow.data.get_source()` API.
The following example demonstrates how to use ``mlflow.data`` to log a training dataset to a run,
retrieve information about the dataset from the run, and load the dataset's source.
.. code-block:: python
import mlflow.data
import pandas as pd
from mlflow.data.pandas_dataset import PandasDataset
# Construct a Pandas DataFrame using iris flower data from a web URL
dataset_source_url = "http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv"
df = pd.read_csv(dataset_source_url)
# Construct an MLflow PandasDataset from the Pandas DataFrame, and specify the web URL
# as the source
dataset: PandasDataset = mlflow.data.from_pandas(df, source=dataset_source_url)
with mlflow.start_run():
# Log the dataset to the MLflow Run. Specify the "training" context to indicate that the
# dataset is used for model training
mlflow.log_input(dataset, context="training")
# Retrieve the run, including dataset information
run = mlflow.get_run(mlflow.last_active_run().info.run_id)
dataset_info = run.inputs.dataset_inputs[0].dataset
print(f"Dataset name: {dataset_info.name}")
print(f"Dataset digest: {dataset_info.digest}")
print(f"Dataset profile: {dataset_info.profile}")
print(f"Dataset schema: {dataset_info.schema}")
# Load the dataset's source, which downloads the content from the source URL to the local
# filesystem
dataset_source = mlflow.data.get_source(dataset_info)
dataset_source.load()
.. autoclass:: mlflow.data.dataset.Dataset
:members:
:undoc-members:
:show-inheritance:
.. autoclass:: mlflow.data.dataset_source.DatasetSource
:members:
:undoc-members:
:show-inheritance:
:exclude-members: from_json
.. method:: from_json(cls, source_json: str) -> DatasetSource
.. autofunction:: mlflow.data.get_source
pandas
~~~~~~
.. autofunction:: mlflow.data.from_pandas
.. autoclass:: mlflow.data.pandas_dataset.PandasDataset()
:members:
:undoc-members:
:exclude-members: to_pyfunc, to_evaluation_dataset
NumPy
~~~~~
.. autofunction:: mlflow.data.from_numpy
.. autoclass:: mlflow.data.numpy_dataset.NumpyDataset()
:members:
:undoc-members:
:exclude-members: to_pyfunc, to_evaluation_dataset
Spark
~~~~~
.. autofunction:: mlflow.data.load_delta
.. autofunction:: mlflow.data.from_spark
.. autoclass:: mlflow.data.spark_dataset.SparkDataset()
:members:
:undoc-members:
:exclude-members: to_pyfunc, to_evaluation_dataset
Hugging Face
~~~~~~~~~~~~
.. autofunction:: mlflow.data.huggingface_dataset.from_huggingface
.. autoclass:: mlflow.data.huggingface_dataset.HuggingFaceDataset()
:members:
:undoc-members:
:exclude-members: to_pyfunc
TensorFlow
~~~~~~~~~~~~
.. autofunction:: mlflow.data.tensorflow_dataset.from_tensorflow
.. autoclass:: mlflow.data.tensorflow_dataset.TensorFlowDataset()
:members:
:undoc-members:
:exclude-members: to_pyfunc,
.. autoclass:: mlflow.data.evaluation_dataset.EvaluationDataset()
:members:
:undoc-members:
polars
~~~~~~
.. autofunction:: mlflow.data.from_polars
.. autoclass:: mlflow.data.polars_dataset.PolarsDataset()
:members:
:undoc-members:
:exclude-members: to_pyfunc, to_evaluation_dataset
Dataset Sources
~~~~~~~~~~~~~~~~
.. autoclass:: mlflow.data.filesystem_dataset_source.FileSystemDatasetSource()
:members:
:undoc-members:
.. autoclass:: mlflow.data.http_dataset_source.HTTPDatasetSource()
:members:
:undoc-members:
.. autoclass:: mlflow.data.huggingface_dataset_source.HuggingFaceDatasetSource()
:members:
:undoc-members:
:exclude-members:
.. autoclass:: mlflow.data.delta_dataset_source.DeltaDatasetSource()
:members:
:undoc-members:
.. autoclass:: mlflow.data.spark_dataset_source.SparkDatasetSource()
:members:
:undoc-members:
@@ -0,0 +1,12 @@
mlflow.deployments
==================
.. automodule:: mlflow.deployments
:members:
:undoc-members:
:exclude-members: PredictionsResponse
.. autoclass:: mlflow.deployments.PredictionsResponse
:members:
:undoc-members:
:exclude-members: from_json
@@ -0,0 +1,7 @@
mlflow.dspy
==================
.. automodule:: mlflow.dspy
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,15 @@
mlflow.entities
===============
.. automodule:: mlflow.entities
:members:
:undoc-members:
.. automodule:: mlflow.entities.model_registry
:members:
:undoc-members:
:exclude-members: Prompt
.. automodule:: mlflow.store.entities
:members:
:undoc-members:
@@ -0,0 +1,6 @@
mlflow.environment_variables
============================
.. automodule:: mlflow.environment_variables
:members:
:undoc-members:
@@ -0,0 +1,14 @@
mlflow.gateway
==============
.. automodule:: mlflow.gateway
:members:
:undoc-members:
.. automodule:: mlflow.gateway.base_models
:members: ConfigModel
.. automodule:: mlflow.gateway.config
:members:
:undoc-members:
:exclude-members: model_computed_fields
@@ -0,0 +1,7 @@
mlflow.gemini
==============
.. automodule:: mlflow.gemini
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,73 @@
mlflow.genai
============
.. automodule:: mlflow.genai
:members:
:undoc-members:
:show-inheritance:
.. automodule:: mlflow.genai.scorers
:members:
:undoc-members:
:show-inheritance:
:exclude-members: Scorer
.. automodule:: mlflow.genai.scorers.deepeval
:members:
:undoc-members:
:show-inheritance:
:exclude-members: DeepEvalScorer
.. automodule:: mlflow.genai.scorers.ragas
:members:
:undoc-members:
:show-inheritance:
:exclude-members: RagasScorer
.. automodule:: mlflow.genai.scorers.phoenix
:members:
:undoc-members:
:show-inheritance:
:exclude-members: PhoenixScorer
.. automodule:: mlflow.genai.scorers.trulens
:members:
:undoc-members:
:show-inheritance:
:exclude-members: TruLensScorer, TruLensAgentScorer
.. automodule:: mlflow.genai.scorers.guardrails
:members:
:undoc-members:
:show-inheritance:
:exclude-members: GuardrailsScorer
.. automodule:: mlflow.genai.datasets
:members:
:undoc-members:
:show-inheritance:
.. automodule:: mlflow.genai.label_schemas
:members:
:undoc-members:
:show-inheritance:
.. automodule:: mlflow.genai.review_queues
:members:
:undoc-members:
:show-inheritance:
.. automodule:: mlflow.genai.optimize
:members:
:undoc-members:
:show-inheritance:
.. automodule:: mlflow.genai.judges
:members:
:undoc-members:
:show-inheritance:
.. automodule:: mlflow.genai.agent_server
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.groq
================
.. automodule:: mlflow.groq
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.h2o
==========
.. automodule:: mlflow.h2o
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.haystack
==================
.. automodule:: mlflow.haystack
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.johnsnowlabs
===================
.. automodule:: mlflow.johnsnowlabs
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,22 @@
mlflow.keras
==================
.. automodule:: mlflow.keras.autolog
:members:
:undoc-members:
:show-inheritance:
.. automodule:: mlflow.keras.callback
:members:
:undoc-members:
:show-inheritance:
.. automodule:: mlflow.keras.load
:members:
:undoc-members:
:show-inheritance:
.. automodule:: mlflow.keras.save
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,13 @@
mlflow.langchain
==================
.. automodule:: mlflow.langchain
:members:
:undoc-members:
:show-inheritance:
.. autoclass:: mlflow.langchain.chat_agent_langgraph.ChatAgentState
.. autoclass:: mlflow.langchain.chat_agent_langgraph.ChatAgentToolNode
.. autoclass:: mlflow.langchain.output_parsers.ChatAgentOutputParser
@@ -0,0 +1,7 @@
mlflow.lightgbm
===============
.. automodule:: mlflow.lightgbm
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.litellm
==============
.. automodule:: mlflow.litellm
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.llama_index
==================
.. automodule:: mlflow.llama_index
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,224 @@
mlflow.metrics
==============
The ``mlflow.metrics`` module helps you quantitatively and qualitatively measure your models.
.. autoclass:: mlflow.metrics.EvaluationMetric
These :py:class:`EvaluationMetric <mlflow.metrics.EvaluationMetric>` are used by the :py:func:`mlflow.evaluate()` API, either computed automatically depending on the ``model_type`` or specified via the ``extra_metrics`` parameter.
The following code demonstrates how to use :py:func:`mlflow.evaluate()` with an :py:class:`EvaluationMetric <mlflow.metrics.EvaluationMetric>`.
.. code-block:: python
import mlflow
from mlflow.metrics.genai import EvaluationExample, answer_similarity
eval_df = pd.DataFrame(
{
"inputs": [
"What is MLflow?",
],
"ground_truth": [
"MLflow is the largest open source AI engineering platform for agents, LLM applications, and ML models. It was developed by Databricks, a company that specializes in data and AI solutions. MLflow is designed to address the challenges that data scientists and AI engineers face when developing, evaluating, and deploying AI applications.",
],
}
)
example = EvaluationExample(
input="What is MLflow?",
output="MLflow is the largest open source AI engineering platform "
"for agents, LLM applications, and ML models, including tracing, "
"evaluation, prompt management, experiment tracking, and deployment.",
score=4,
justification="The definition effectively explains what MLflow is "
"its purpose, and its developer. It could be more concise for a 5-score.",
grading_context={
"ground_truth": "MLflow is the largest open source AI engineering "
"platform for agents, LLM applications, and ML models. It was "
"developed by Databricks, a company that specializes in data and "
"AI solutions. MLflow is designed to address the challenges that "
"data scientists and AI engineers face when developing, evaluating, "
"and deploying AI applications."
},
)
answer_similarity_metric = answer_similarity(examples=[example])
results = mlflow.evaluate(
logged_model.model_uri,
eval_df,
targets="ground_truth",
model_type="question-answering",
extra_metrics=[answer_similarity_metric],
)
Information about how an :py:class:`EvaluationMetric <mlflow.metrics.EvaluationMetric>` is calculated, such as the grading prompt used is available via the ``metric_details`` property.
.. code-block:: python
import mlflow
from mlflow.metrics.genai import relevance
my_relevance_metric = relevance()
print(my_relevance_metric.metric_details)
Evaluation results are stored as :py:class:`MetricValue <mlflow.metrics.MetricValue>`. Aggregate results are logged to the MLflow run as metrics, while per-example results are logged to the MLflow run as artifacts in the form of an evaluation table.
.. autoclass:: mlflow.metrics.MetricValue
We provide the following builtin factory functions to create :py:class:`EvaluationMetric <mlflow.metrics.EvaluationMetric>` for evaluating models. These metrics are computed automatically depending on the ``model_type``. For more information on the ``model_type`` parameter, see :py:func:`mlflow.evaluate()` API.
Regressor Metrics
-----------------
.. autofunction:: mlflow.metrics.mae
.. autofunction:: mlflow.metrics.mape
.. autofunction:: mlflow.metrics.max_error
.. autofunction:: mlflow.metrics.mse
.. autofunction:: mlflow.metrics.rmse
.. autofunction:: mlflow.metrics.r2_score
Classifier Metrics
------------------
.. autofunction:: mlflow.metrics.precision_score
.. autofunction:: mlflow.metrics.recall_score
.. autofunction:: mlflow.metrics.f1_score
Text Metrics
------------
.. autofunction:: mlflow.metrics.ari_grade_level
.. autofunction:: mlflow.metrics.flesch_kincaid_grade_level
Question Answering Metrics
---------------------------
Includes all of the above **Text Metrics** as well as the following:
.. autofunction:: mlflow.metrics.exact_match
.. autofunction:: mlflow.metrics.rouge1
.. autofunction:: mlflow.metrics.rouge2
.. autofunction:: mlflow.metrics.rougeL
.. autofunction:: mlflow.metrics.rougeLsum
.. autofunction:: mlflow.metrics.toxicity
.. autofunction:: mlflow.metrics.token_count
.. autofunction:: mlflow.metrics.latency
.. autofunction:: mlflow.metrics.bleu
Retriever Metrics
-----------------
The following metrics are built-in metrics for the ``'retriever'`` model type, meaning they will be
automatically calculated with a default ``retriever_k`` value of 3.
To evaluate document retrieval models, it is recommended to use a dataset with the following
columns:
- Input queries
- Retrieved relevant doc IDs
- Ground-truth doc IDs
Alternatively, you can also provide a function through the ``model`` parameter to represent
your retrieval model. The function should take a Pandas DataFrame containing input queries and
ground-truth relevant doc IDs, and return a DataFrame with a column of retrieved relevant doc IDs.
A "doc ID" is a string or integer that uniquely identifies a document. Each row of the retrieved and
ground-truth doc ID columns should consist of a list or numpy array of doc IDs.
Parameters:
- ``targets``: A string specifying the column name of the ground-truth relevant doc IDs
- ``predictions``: A string specifying the column name of the retrieved relevant doc IDs in either
the static dataset or the Dataframe returned by the ``model`` function
- ``retriever_k``: A positive integer specifying the number of retrieved docs IDs to consider for
each input query. ``retriever_k`` defaults to 3. You can change ``retriever_k`` by using the
:py:func:`mlflow.evaluate` API:
1. .. code-block:: python
# with a model and using `evaluator_config`
mlflow.evaluate(
model=retriever_function,
data=data,
targets="ground_truth",
model_type="retriever",
evaluators="default",
evaluator_config={"retriever_k": 5}
)
2. .. code-block:: python
# with a static dataset and using `extra_metrics`
mlflow.evaluate(
data=data,
predictions="predictions_param",
targets="targets_param",
model_type="retriever",
extra_metrics = [
mlflow.metrics.precision_at_k(5),
mlflow.metrics.precision_at_k(6),
mlflow.metrics.recall_at_k(5),
mlflow.metrics.ndcg_at_k(5)
]
)
NOTE: In the 2nd method, it is recommended to omit the ``model_type`` as well, or else
``precision@3`` and ``recall@3`` will be calculated in addition to ``precision@5``,
``precision@6``, ``recall@5``, and ``ndcg_at_k@5``.
.. autofunction:: mlflow.metrics.precision_at_k
.. autofunction:: mlflow.metrics.recall_at_k
.. autofunction:: mlflow.metrics.ndcg_at_k
Users create their own :py:class:`EvaluationMetric <mlflow.metrics.EvaluationMetric>` using the :py:func:`make_metric <mlflow.metrics.make_metric>` factory function
.. autofunction:: mlflow.metrics.make_metric
.. automodule:: mlflow.metrics
:members:
:undoc-members:
:show-inheritance:
:exclude-members: MetricValue, EvaluationMetric, make_metric, EvaluationExample, ari_grade_level, flesch_kincaid_grade_level, exact_match, rouge1, rouge2, rougeL, rougeLsum, toxicity, answer_similarity, answer_correctness, faithfulness, answer_relevance, mae, mape, max_error, mse, rmse, r2_score, precision_score, recall_score, f1_score, token_count, latency, precision_at_k, recall_at_k, ndcg_at_k, bleu
Generative AI Metrics
---------------------
We also provide generative AI ("genai") :py:class:`EvaluationMetric <mlflow.metrics.EvaluationMetric>`\s for evaluating text models. These metrics use an LLM to evaluate the quality of a model's output text. Note that your use of a third party LLM service (e.g., OpenAI) for evaluation may be subject to and governed by the LLM service's terms of use. The following factory functions help you customize the intelligent metric to your use case.
.. automodule:: mlflow.metrics.genai
:members:
:undoc-members:
:show-inheritance:
:exclude-members: EvaluationExample, make_genai_metric
You can also create your own generative AI :py:class:`EvaluationMetric <mlflow.metrics.EvaluationMetric>`\s using the :py:func:`make_genai_metric <mlflow.metrics.genai.make_genai_metric>` factory function.
.. autofunction:: mlflow.metrics.genai.make_genai_metric
When using generative AI :py:class:`EvaluationMetric <mlflow.metrics.EvaluationMetric>`\s, it is important to pass in an :py:class:`EvaluationExample <mlflow.metrics.genai.EvaluationExample>`
.. autoclass:: mlflow.metrics.genai.EvaluationExample
Users must set the appropriate environment variables for the LLM service they are using for
evaluation. For example, if you are using OpenAI's API, you must set the ``OPENAI_API_KEY``
environment variable. If using Azure OpenAI, you must also set the ``OPENAI_API_TYPE``,
``OPENAI_API_VERSION``, ``OPENAI_API_BASE``, and ``OPENAI_DEPLOYMENT_NAME`` environment variables.
See `Azure OpenAI documentation <https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/switching-endpoints>`_
Users do not need to set these environment variables if they are using a gateway route.
@@ -0,0 +1,7 @@
mlflow.mistral
==============
.. automodule:: mlflow.mistral
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,11 @@
mlflow.models
==============
.. automodule:: mlflow.models
:members:
:undoc-members:
:show-inheritance:
:exclude-members: EvaluationMetric
.. autoclass:: mlflow.models.model.ModelInfo
:members:
@@ -0,0 +1,7 @@
mlflow.onnx
==================
.. automodule:: mlflow.onnx
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.openai
=============
.. automodule:: mlflow.openai
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.paddle
==================
.. automodule:: mlflow.paddle
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.pmdarima
===============
.. automodule:: mlflow.pmdarima
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.projects
===============
.. automodule:: mlflow.projects
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.prophet
==================
.. automodule:: mlflow.prophet
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.pydantic_ai
==================
.. automodule:: mlflow.pydantic_ai
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,43 @@
mlflow.pyfunc
=============
.. automodule:: mlflow.pyfunc
:members:
:undoc-members:
:show-inheritance:
.. Include ``get_default_pip_requirements`` and ``get_default_conda_env``,
which are imported from `mlflow.pyfunc.model`, in the `mlflow.pyfunc` namespace
.. autofunction:: mlflow.pyfunc.get_default_pip_requirements
.. autofunction:: mlflow.pyfunc.get_default_conda_env
.. Include ``PythonModelContext`` as a renamed class to avoid documenting constructor parameters.
This class is meant to be constructed implicitly, and users should only be aware of its
documented member properties.
.. autoclass:: mlflow.pyfunc.PythonModelContext()
:members:
:undoc-members:
.. Include ``PythonModel``, which is imported from `mlflow.pyfunc.model`, in the
`mlflow.pyfunc` namespace
.. autoclass:: mlflow.pyfunc.PythonModel
:members:
:undoc-members:
.. Include ``ChatModel``, which is imported from `mlflow.pyfunc.model`, in the
`mlflow.pyfunc` namespace
.. autoclass:: mlflow.pyfunc.ChatModel
:members:
:undoc-members:
.. Include ``ChatAgent``, which is imported from `mlflow.pyfunc.model`, in the
`mlflow.pyfunc` namespace
.. autoclass:: mlflow.pyfunc.ChatAgent
:members:
:undoc-members:
.. Include ``ResponsesAgent``, which is imported from `mlflow.pyfunc.model`, in the
`mlflow.pyfunc` namespace
.. autoclass:: mlflow.pyfunc.ResponsesAgent
:members:
:undoc-members:
@@ -0,0 +1,7 @@
mlflow.pyspark.ml
=================
.. automodule:: mlflow.pyspark.ml
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.pytorch
==================
.. automodule:: mlflow.pytorch
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,83 @@
mlflow
======
.. automodule:: mlflow
:members:
:undoc-members:
:exclude-members:
MlflowClient,
add_trace,
trace,
start_span,
start_span_no_context,
get_trace,
search_traces,
log_assessment,
log_expectation,
log_feedback,
update_assessment,
delete_assessment,
get_current_active_span,
get_last_active_trace_id,
create_external_model,
delete_logged_model_tag,
finalize_logged_model,
get_logged_model,
initialize_logged_model,
last_logged_model,
search_logged_models,
set_active_model,
set_logged_model_tags,
log_model_params,
clear_active_model,
load_prompt,
register_prompt,
search_prompts,
set_prompt_alias,
delete_prompt_alias,
.. _mlflow-tracing-fluent-python-apis:
MLflow Tracing APIs
===================
The ``mlflow`` module provides a set of high-level APIs for `MLflow Tracing <../llms/tracing/index.html>`_. For the detailed
guidance on how to use these tracing APIs, please refer to the `Tracing Fluent APIs Guide <../llms/tracing/index.html#tracing-fluent-apis>`_.
.. autofunction:: mlflow.trace
.. autofunction:: mlflow.start_span
.. autofunction:: mlflow.start_span_no_context
.. autofunction:: mlflow.get_trace
.. autofunction:: mlflow.search_traces
.. autofunction:: mlflow.get_current_active_span
.. autofunction:: mlflow.get_last_active_trace_id
.. autofunction:: mlflow.add_trace
.. autofunction:: mlflow.log_assessment
.. autofunction:: mlflow.log_expectation
.. autofunction:: mlflow.log_feedback
.. autofunction:: mlflow.update_assessment
.. autofunction:: mlflow.delete_assessment
.. automodule:: mlflow.tracing
:members:
:undoc-members:
:noindex:
.. _mlflow-logged-model-fluent-python-apis:
MLflow Logged Model APIs
========================
The ``mlflow`` module provides a set of high-level APIs to interact with ``MLflow Logged Models``.
.. autofunction:: mlflow.clear_active_model
.. autofunction:: mlflow.create_external_model
.. autofunction:: mlflow.delete_logged_model_tag
.. autofunction:: mlflow.finalize_logged_model
.. autofunction:: mlflow.get_logged_model
.. autofunction:: mlflow.initialize_logged_model
.. autofunction:: mlflow.last_logged_model
.. autofunction:: mlflow.search_logged_models
.. autofunction:: mlflow.set_active_model
.. autofunction:: mlflow.set_logged_model_tags
.. autofunction:: mlflow.log_model_params
@@ -0,0 +1,7 @@
mlflow.sagemaker
================
.. automodule:: mlflow.sagemaker
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.sentence_transformers
============================
.. automodule:: mlflow.sentence_transformers
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.server
=============
.. automodule:: mlflow.server
:members: get_app_client
:undoc-members:
:show-inheritance:
@@ -0,0 +1,8 @@
mlflow.shap
===========
.. automodule:: mlflow.shap
:members:
:undoc-members:
:show-inheritance:
:exclude-members: save_model
@@ -0,0 +1,7 @@
mlflow.sklearn
==============
.. automodule:: mlflow.sklearn
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.smolagents
==================
.. automodule:: mlflow.smolagents
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.spacy
============
.. automodule:: mlflow.spacy
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.spark
===============
.. automodule:: mlflow.spark
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.statsmodels
==================
.. automodule:: mlflow.statsmodels
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.strands
==================
.. automodule:: mlflow.strands
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.system_metrics
======================
.. automodule:: mlflow.system_metrics
:members:
:undoc-members:
@@ -0,0 +1,11 @@
mlflow.tensorflow
==================
.. automodule:: mlflow.tensorflow
:members:
:undoc-members:
:show-inheritance:
.. autoclass:: mlflow.tensorflow.MlflowCallback
:members:
:undoc-members:
@@ -0,0 +1,21 @@
mlflow.tracing
==============
.. attention::
The ``mlflow.tracing`` namespace only contains a few utility functions fo managing traces. The main entry point for MLflow
Tracing is :ref:`Tracing Fluent APIs <mlflow-tracing-fluent-python-apis>` defined directly under the
:py:mod:`mlflow` namespace, or the low-level `Tracing Client APIs <../llms/tracing/index.html#tracing-client-apis>`_
.. automodule:: mlflow.tracing
:members:
:undoc-members:
:show-inheritance:
mlflow.tracing.attachments
--------------------------
.. automodule:: mlflow.tracing.attachments
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.transformers
===================
.. automodule:: mlflow.transformers
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,28 @@
mlflow.types
==============
.. automodule:: mlflow.types
:members:
:show-inheritance:
.. automodule:: mlflow.types.responses
:members:
.. automodule:: mlflow.types.responses_helpers
:members:
.. automodule:: mlflow.types.agent
:members:
.. automodule:: mlflow.types.llm
:members:
.. automodule:: mlflow.types.chat
:members:
.. automodule:: mlflow.types.schema
:members: Array, Map, Object, Property, AnyType
:undoc-members:
.. automodule:: mlflow.types.llm._BaseDataclass
:undoc-members:
@@ -0,0 +1,10 @@
mlflow.utils
==================
.. automodule:: mlflow.utils.async_logging
:members:
:undoc-members:
.. automodule:: mlflow.utils.async_logging.run_operations
:members:
:undoc-members:
@@ -0,0 +1,7 @@
mlflow.webhooks
===============
.. automodule:: mlflow.webhooks
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,7 @@
mlflow.xgboost
==============
.. automodule:: mlflow.xgboost
:members:
:undoc-members:
:show-inheritance:
@@ -0,0 +1,256 @@
:orphan:
.. _mlflow.openai.messages:
Supported ``messages`` formats for OpenAI chat completion task
==============================================================
This document covers the following:
- Supported ``messages`` formats for OpenAI chat completion task in the ``openai`` flavor.
- Logged model signature for each format.
- Payload sent to OpenAI chat completion API for each format.
- Expected prediction input types for each format.
``messages`` with variables
---------------------------
The ``messages`` argument accepts a list of dictionaries with ``role`` and ``content`` keys. The
``content`` field in each message can contain variables (= named format fields). When the logged
model is loaded and makes a prediction, the variables are replaced with the values from the
prediction input.
Single variable
~~~~~~~~~~~~~~~
.. code-block:: python
import mlflow
import openai
with mlflow.start_run():
model_info = mlflow.openai.log_model(
name="model",
model="gpt-4o-mini",
task=openai.chat.completions,
messages=[
{
"role": "user",
"content": "Tell me a {adjective} joke",
# ^^^^^^^^^^
# variable
},
# Can contain more messages
],
)
model = mlflow.pyfunc.load_model(model_info.model_uri)
print(model.predict([{"adjective": "funny"}]))
Logged model signature:
.. code-block:: python
{
"inputs": [{"type": "string"}],
"outputs": [{"type": "string"}],
}
Expected prediction input types:
.. code-block:: python
# A list of dictionaries with 'adjective' key
[{"adjective": "funny"}, ...]
# A list of strings
["funny", ...]
Payload sent to OpenAI chat completion API:
.. code-block:: python
{
"model": "gpt-4o-mini",
"messages": [
{
"role": "user",
"content": "Tell me a funny joke",
}
],
}
Multiple variables
~~~~~~~~~~~~~~~~~~
.. code-block:: python
import mlflow
import openai
with mlflow.start_run():
model_info = mlflow.openai.log_model(
name="model",
model="gpt-4o-mini",
task=openai.chat.completions,
messages=[
{
"role": "user",
"content": "Tell me a {adjective} joke about {thing}.",
# ^^^^^^^^^^ ^^^^^^^
# variable another variable
},
# Can contain more messages
],
)
model = mlflow.pyfunc.load_model(model_info.model_uri)
print(model.predict([{"adjective": "funny", "thing": "vim"}]))
Logged model signature:
.. code-block:: python
{
"inputs": [
{"name": "adjective", "type": "string"},
{"name": "thing", "type": "string"},
],
"outputs": [{"type": "string"}],
}
Expected prediction input types:
.. code-block:: python
# A list of dictionaries with 'adjective' and 'thing' keys
[{"adjective": "funny", "thing": "vim"}, ...]
Payload sent to OpenAI chat completion API:
.. code-block:: python
{
"model": "gpt-4o-mini",
"messages": [
{
"role": "user",
"content": "Tell me a funny joke about vim",
}
],
}
``messages`` without variables
------------------------------
If no variables are provided, the prediction input will be _appended_ to the logged ``messages``
with ``role = user``.
.. code-block:: python
with mlflow.start_run():
model_info = mlflow.openai.log_model(
name="model",
model="gpt-4o-mini",
task=openai.chat.completions,
messages=[
{
"role": "system",
"content": "You're a frontend engineer.",
}
],
)
model = mlflow.pyfunc.load_model(model_info.model_uri)
print(model.predict(["Tell me a funny joke."]))
Logged model signature:
.. code-block:: python
{
"inputs": [{"type": "string"}],
"outputs": [{"type": "string"}],
}
Expected prediction input type:
- A list of dictionaries with a single key
- A list of strings
Payload sent to OpenAI chat completion API:
.. code-block:: python
{
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "You're a frontend engineer.",
},
{
"role": "user",
"content": "Tell me a funny joke.",
},
],
}
No ``messages``
---------------
The ``messages`` argument is optional and can be omitted. If omitted, the prediction input will be
sent to the OpenAI chat completion API as-is with ``role = user``.
.. code-block:: python
import mlflow
import openai
with mlflow.start_run():
model_info = mlflow.openai.log_model(
name="model",
model="gpt-4o-mini",
task=openai.chat.completions,
)
model = mlflow.pyfunc.load_model(model_info.model_uri)
print(model.predict(["Tell me a funny joke."]))
Logged model signature:
.. code-block:: python
{
"inputs": [{"type": "string"}],
"outputs": [{"type": "string"}],
}
Expected prediction input types:
.. code-block:: python
# A list of dictionaries with a single key
[{"<any key>": "Tell me a funny joke."}, ...]
# A list of strings
["Tell me a funny joke.", ...]
Payload sent to OpenAI chat completion API:
.. code-block:: python
{
"model": "gpt-4o-mini",
"messages": [
{
"role": "user",
"content": "Tell me a funny joke.",
}
],
}
+10079
View File
File diff suppressed because it is too large Load Diff
+211
View File
@@ -0,0 +1,211 @@
"""
Standalone script to extract code blocks marked with :test: from Python docstrings.
Uses AST to parse Python files and extract docstrings with test code blocks.
"""
import ast
import re
import subprocess
import textwrap
from pathlib import Path
_CODE_BLOCK_HEADER_REGEX = re.compile(r"^\.\.\s+code-block::\s*py(thon)?")
_CODE_BLOCK_OPTION_REGEX = re.compile(r"^:\w+:")
def _get_indent(s: str) -> int:
return len(s) - len(s.lstrip())
def _get_header_indent(s: str) -> int | None:
if _CODE_BLOCK_HEADER_REGEX.match(s.lstrip()):
return _get_indent(s)
return None
def extract_code_blocks_from_docstring(docstring: str | None) -> list[tuple[int, str]]:
"""
Extract all code blocks marked with :test: from a docstring.
Uses the same approach as clint for parsing code blocks.
Returns a list of tuples: (line_number, code_content)
"""
if not docstring:
return []
blocks = []
header_indent: int | None = None
code_lines: list[str] = []
has_test_option = False
code_block_lineno = 0
line_iter = enumerate(docstring.splitlines())
while t := next(line_iter, None):
idx, line = t
if code_lines:
# We're inside a code block
indent = _get_indent(line)
# If we encounter a non-blank line with an indent less than or equal to the header
# we are done parsing the code block
if line.strip() and (header_indent is not None) and indent <= header_indent:
if has_test_option:
code = textwrap.dedent("\n".join(code_lines))
blocks.append((code_block_lineno, code))
# Reset state
code_lines.clear()
has_test_option = False
# It's possible that another code block follows the current one
header_indent = _get_header_indent(line)
continue
code_lines.append(line)
elif header_indent is not None:
# We found a code-block header, now advance to the code body
# Skip options like :test:, :caption:, etc.
while True:
stripped = line.lstrip()
if stripped.startswith(":test:") or stripped == ":test:":
has_test_option = True
# Check if this is still an option line or blank
if stripped and not _CODE_BLOCK_OPTION_REGEX.match(stripped):
# We are at the first line of the code block
code_lines.append(line)
code_block_lineno = idx + 1 # Line number in docstring (1-indexed)
break
if next_line := next(line_iter, None):
idx, line = next_line
else:
break
else:
# Look for code-block headers
header_indent = _get_header_indent(line)
# The docstring ends with a code block
if code_lines and has_test_option:
code = textwrap.dedent("\n".join(code_lines))
blocks.append((code_block_lineno, code))
return blocks
def extract_code_blocks_from_file(filepath: Path, repo_root: Path) -> list[tuple[str, int, str]]:
"""
Extract all code blocks marked with :test: from a Python file.
Args:
filepath: Path to the Python file
repo_root: Root of the repository
Returns:
List of tuples: (location_string, line_number, code_content)
"""
source = filepath.read_text()
tree = ast.parse(source)
results = []
rel_path = filepath.relative_to(repo_root)
for node in ast.walk(tree):
# Check functions and classes for docstrings
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
docstring = ast.get_docstring(node)
if not docstring:
continue
blocks = extract_code_blocks_from_docstring(docstring)
for lineno_in_docstring, code in blocks:
# Calculate the actual line number in the file
# The docstring starts at node.lineno, and lineno_in_docstring is relative to that
actual_line = node.lineno + lineno_in_docstring
location = f"{rel_path}:{actual_line}"
results.append((location, lineno_in_docstring, code))
return results
def find_python_files(directory: Path, repo_root: Path) -> list[Path]:
"""Find all Python files tracked by git in a directory."""
# Get relative path from repo root
rel_dir = directory.relative_to(repo_root)
# Run git ls-files from repo root with the directory as a pattern
output = subprocess.check_output(
["git", "ls-files", f"{rel_dir}/*.py"],
cwd=repo_root,
text=True,
)
files = [repo_root / line for line in output.strip().split("\n") if line]
return sorted(files)
def generate_test_file(location: str, line_num: int, code: str, output_dir: Path) -> Path:
"""Generate a pytest test file for a code block."""
# Create a unique filename based on location
safe_name = re.sub(r"[/\\:.]", "_", location)
filename = f"test_{safe_name}_{line_num}.py"
content = textwrap.indent(code, " " * 4)
test_code = "\n".join([
f"# Location: {location}",
"import pytest",
"",
"",
# Show the code block location in the test report.
f"@pytest.mark.parametrize('_', [' {location} '])",
"def test(_):",
content,
"",
"",
'if __name__ == "__main__":',
" test()",
"",
])
output_path = output_dir / filename
output_path.write_text(test_code)
return output_path
def extract_examples(mlflow_dir: Path, output_dir: Path, repo_root: Path) -> None:
"""
Extract test examples from Python files and generate test files.
Args:
mlflow_dir: Directory containing Python files to scan
output_dir: Directory to write test files to
repo_root: Root of the repository
"""
output_dir.mkdir(exist_ok=True)
# Clean up old test files
for old_file in output_dir.glob("test_*.py"):
old_file.unlink()
print(f"Scanning Python files in: {mlflow_dir}")
python_files = find_python_files(mlflow_dir, repo_root)
print(f"Found {len(python_files)} Python files")
for filepath in python_files:
results = extract_code_blocks_from_file(filepath, repo_root)
for location, line_num, code in results:
output_path = generate_test_file(location, line_num, code, output_dir)
print(f" Generated: {output_path.name}")
def main() -> None:
output = subprocess.check_output(["git", "rev-parse", "--show-toplevel"], text=True)
repo_root = Path(output.strip())
scan_dir = repo_root / "mlflow"
output_dir = Path(".examples")
extract_examples(scan_dir, output_dir, repo_root)
if __name__ == "__main__":
main()
@@ -0,0 +1,6 @@
.. _typescript_api:
TypeScript API
==============
This file is a placeholder. TypeScript documentation is filled in by the build-tsdoc.sh script, executed during "make html".
@@ -0,0 +1,17 @@
"""Sphinx ReadTheDocs theme.
From https://github.com/ryan-roemer/sphinx-bootstrap-theme.
"""
import os
VERSION = (0, 1, 9)
__version__ = ".".join(str(v) for v in VERSION)
__version_full__ = __version__
def get_html_theme_path():
"""Return list of HTML theme paths."""
return os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
@@ -0,0 +1,36 @@
{% if not embedded %}
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'{{ url_root }}',
VERSION:'{{ release|e }}',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'{{ '' if no_search_suffix else file_suffix }}',
HAS_SOURCE: {{ has_source|lower }}
};
</script>
{%- for scriptfile in script_files %}
<script type="text/javascript" src="/{{ pathto(scriptfile, 1) }}"></script>
{%- endfor %}
{% endif %}
<script type="text/javascript" src="{{ pathto('_static/js/clipboard.min.js', 1) }}"></script>
<script type="text/javascript" src="{{ pathto('_static/js/jquery.waypoints.min.js', 1) }}"></script>
{# RTD hosts this file, so just load on non RTD builds #}
{% if not READTHEDOCS %}
{# I'm sorry, I don't know how to use sphinx to inject this into the static JS. #}
<script type="text/javascript">var CLIPPY_SVG_PATH = "{{ pathto('_static/clippy.svg', 1) }}";</script>
<script type="text/javascript" src="{{ pathto('_static/js/custom.js', 1) }}"></script>
{% endif %}
{# STICKY NAVIGATION #}
{% if theme_sticky_navigation %}
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
{% endif %}
@@ -0,0 +1,31 @@
{# Support for Sphinx 1.3+ page_source_suffix, but don't break old builds. #}
{% if page_source_suffix %}
{% set suffix = page_source_suffix %}
{% else %}
{% set suffix = source_suffix %}
{% endif %}
{% set github_user = 'mlflow' %}
{% set github_repo = 'mlflow' %}
{% set github_version = 'master' %}
{% set conf_py_path = 'docs/source' %}
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="{{ pathto(master_doc) }}">Documentation</a> <span class="db-icon db-icon-chevron-right"></span></li>
{% for doc in parents %}
<li><a href="{{ doc.link|e }}">{{ doc.title }}</a> <span class="db-icon db-icon-chevron-right"></span></li>
{% endfor %}
{% if title %}
<li>{{ title }}</li>
{% elif pagename == "search" %}
<li>Search</li>
{% endif %}
{% if not pagename == "search" %}
<!-- <li class="wy-breadcrumbs-aside">
<a href="https://{{ github_host|default("github.com") }}/{{ github_user }}/{{ github_repo }}/blob/{{ github_version }}/{{ conf_py_path }}/{{ pagename }}{{ suffix }}" class="fa fa-github"> Edit on GitHub</a>
</li> -->
{% endif %}
</ul>
</div>

Some files were not shown because too many files have changed in this diff Show More