Repository navigation
air: add a hidden air deploy command that registers and serves a model - #7642
Draft
erarpitagarwal wants to merge 4 commits into
Draft
erarpitagarwal wants to merge 4 commits into
erarpitagarwal wants to merge 4 commits into
Conversation
`databricks air deploy -f deploy.yaml` registers a Unity Catalog model version through the registerModelPackage API (a checkpoint in a volume, a model from code, a model directory saved by MLflow) and serves it on a Model Serving endpoint, or serves an existing version. Registration is idempotent per key; the CLI repeats the same request until the version is ready, and prints the command that continues after Ctrl-C or --timeout. The command is hidden until the API is on everywhere. The run YAML loader, --override, -h config.<field>, code_source file selection and root path resolution are shared with `air run`. Co-authored-by: Isaac <no-reply@databricks.com>
Contributor
|
Thanks for the contribution! This pull request was opened from a fork. If you're a member of the Databricks organization, please request access to the If you're an external contributor, no action is needed; a maintainer will review your pull request. |
…errors - Register once, poll the read-only staging status API while a checkpoint's weights copy, then register again to finalize. - Retry transient failures of the polled requests via libs/retry. - Check the endpoint before registering: replace only a single version of the same model, and wait out another update first. - Require code_source.include_paths, refuse pathspec magic and files git tracks although .gitignore matches them, and list the files on --dry-run. Fix the shared non-git listing, which was relative to the working directory instead of root_path. - Print the idempotency key before the first request in every mode; reject an empty --idempotency-key; give JSON errors typed codes. - Validate endpoint names, workload types and sizes, checkpoint tasks, and count length limits as the server does. Co-authored-by: Isaac <no-reply@databricks.com>
- Poll the endpoint per GET with libs/retry, so transient failures spread over a long start don't end the wait. - Don't resend a model from code that isn't ready after registering. - Keep git's stderr in check-ignore failures; reject include_paths patterns and padding; don't mark a local client error retryable. Co-authored-by: Isaac <no-reply@databricks.com>
The server now leaves a registered version pending: air deploy registers it once, polls the read-only staging status until the weights are copied or fail, then calls finalizeModelPackage. A status without a state is waited out, a finalize failure prints the command that continues, and the finalize response must name the same version. Co-authored-by: Isaac <no-reply@databricks.com>
Contributor
|
An authorized user can trigger integration tests manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Add a hidden
databricks air deploycommand. It registers a model in Unity Catalog and serves it on a Model Serving endpoint, from one YAML file.model.typepicks the source:checkpoint: weights in a volume, plus the command that serves them.code: a Python file, with the files it imports fromcode_source, sent with the request.saved_model_dir: a model directory saved by MLflow, in a volume.registered: an existing model version.To register, it makes three calls:
POST /api/2.0/serving-endpoints:registerModelPackagewith an idempotency key, once. It logs the model, creates a pending version and starts copying a checkpoint's weights into it.serving-endpoints:checkModelDeploymentStagingStatus, polled while the weights copy.serving-endpoints:finalizeModelPackage, which finalizes the version once the server sees the weights copied.A version an earlier run finalized comes back ready from the registration, and isn't finalized again. Transient server errors are retried per request with
libs/retry, including each poll of the endpoint, so failures spread over a long wait don't end it. On Ctrl-C or--timeout, it prints the command that continues.--retry-failed-stagingcopies the weights again after a failure.It then creates the endpoint, or updates it to serve the new version, and waits until it is ready. It only replaces a single version of the same model, and it checks this before registering, so a wrong endpoint name fails before any weights are copied. An endpoint that already serves the version is left alone. An update that an interrupted run started is waited for, not repeated, and so is anyone else's update.
It reuses the
air runYAML loader (--override,-h config.<field>, rejecting unknown fields), thecode_sourcefile selection and root path resolution, and the idempotency token helper. The shared helpers now take the schema, or the token, as a parameter.air runbehaves as before, except that one error now reads "config must be a YAML mapping" instead of "run config must be a YAML mapping".Why
Serving a checkpoint or an agent today means calling
mlflow.<flavor>.log_modelfrom Python: pickling a model, copying weights into it, and packing an environment. Withair deploy, the user hands over text (YAML and.pyfiles) and the files a training job already wrote to a volume. The server writes the MLmodel and builds the environment from the declared runtime and dependencies. The YAML keeps theair runnames for the fields the two share:environment,code_source,env_variables,secretsandidempotency_token.The command is hidden, with no changelog entry, until the registration API is on in every workspace. The API is off by default while it rolls out. Some decisions:
git ls-filesorder, so a later run sends the same bytes.code_source.include_pathsis required and must name files and directories literally (no patterns), and within it files git ignores, hidden files and directories, and__pycache__aren't sent; the server can't place names that start with.anyway. A file git tracks although.gitignorematches it is refused.--dry-runlists every file it would send. This also fixes the sharedcode_sourcelisting outside git, which listed paths relative to the working directory instead ofroot_path(it affectedair runtoo).air deployto work.INVALID_ARGS,INTERRUPTED,TIMEOUT,STAGING_FAILEDorINTERNAL_ERROR.codeandsaved_model_dirnow, but the server registers only checkpoints until its follow-up lands, and until then answers the other two with "isn't supported yet". The CLI's checks follow the API's documented limits: checkpoint tasks, workload types (from the SDK), and the path, command, file and size caps.Tests
go test ./cmd/air/passes, and so does-raceon the new tests.golangci-lintreports 0 issues oncmd/air../task checkspasses, andGOOS=windows go build ./cmd/air/builds. New unit tests cover:GPU_MEDIUM:--dry-runvalidated the config without credentials.--timeout 45sstopped while the weights were copying and printed the resume command. Running it registered the version.model.type: registeredwith that version, changed nothing and took 1 s. A changed env var updated the endpoint to config version 2, which became READY.model.type: codesent its files, and the server answered "isn't supported yet", as expected until its follow-up.airhas none yet, the command is hidden, and the test server doesn't model these APIs.This pull request and its description were written by Isaac.