Job backend: Update job backend to use static names rather than function full names#19430
Job backend: Update job backend to use static names rather than function full names#19430WeichenXu123 merged 15 commits intomlflow:masterfrom
Conversation
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
There was a problem hiding this comment.
Pull request overview
This PR transitions the job backend from using function fullnames (module.function_name) as unique identifiers to static job names defined in the @job decorator. This change enables MLflow to move or rename job functions across versions while maintaining backward compatibility by keeping the static job names unchanged.
Key Changes:
- Added a required
nameparameter to the@jobdecorator for specifying static job names - Updated REST API endpoints to use
job_nameinstead offunction_fullnamein payloads and responses - Implemented a mapping system (
_job_name_to_fn_fullname_map) to resolve static job names to actual function fullnames at runtime - Renamed the database column
function_fullnametojob_namewith a migration script
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| mlflow/server/jobs/init.py | Added name parameter to @job decorator and updated job submission to use static job names |
| mlflow/server/jobs/utils.py | Implemented job name to function fullname mapping logic with get_job_fn_fullname() and _build_job_name_to_fn_fullname_map() |
| mlflow/server/jobs/_job_runner.py | Updated job runner to iterate over job names instead of function fullnames |
| mlflow/server/job_api.py | Modified REST API endpoints to accept and return job_name instead of function_fullname |
| mlflow/entities/_job.py | Renamed function_fullname property to job_name in Job entity |
| mlflow/store/jobs/abstract_store.py | Updated abstract store interface to use job_name parameter |
| mlflow/store/jobs/sqlalchemy_store.py | Updated SQL store implementation to use job_name parameter |
| mlflow/store/tracking/dbmodels/models.py | Renamed database column from function_fullname to job_name |
| mlflow/store/db_migrations/versions/5d2d30f0abce_update_job_table.py | Added migration script to rename column and update index |
| tests/server/jobs/test_jobs.py | Updated all test job decorators to include static name parameter and assertions to check job_name |
| tests/server/jobs/test_endpoint.py | Modified endpoint tests to use job_name in API calls and simplified error case tests |
| tests/server/jobs/test_utils.py | Added tests for _load_function error handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Documentation preview for 11c562a is available at: More info
|
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
There was a problem hiding this comment.
Can we add a rule in the [tool.clint.forbidden-top-level-imports] section of pyproject.toml to prevent top-level import of the mlflow/server/jobs (except in files under mlflow/server/jobs itself)? Since _job_name_to_fn_fullname_map try to import all job functions once, which can be slow or raise a warning when optional dependency is not installed, we should make sure it does not trigger when user just import MLflow in client side.
There was a problem hiding this comment.
need to update linter's _check_forbidden_top_level_import to support the rule. Will do it in follow-up PR
Related Issues/PRs
#xxxWhat changes are proposed in this pull request?
Motivation: The job backend uses function full name module.func_name as a unique identifier for the job function. This blocks us from moving function module in the future, because it will cause inconsistency between client and server in different versions. Each job function should have its own unique name and MLflow should maintain the mapping
In this PR, I updated the
jobdecorator to add anameparam, like:then, the job function is associated with the decorated static name, in newer MLflow versions, the job function can be renamed or moved to other module, we only need to keep the job static name unchanged, then the job function can work across different Mlflow versions.
For REST API request, user should set the static job name in the payload, and in the REST response, the job static name is returned. The real job function name is no longer exposed to front-end.
For job backend SQL table storage, it only saves the job static name, instead of the full function name. So that the unfinished job resumption can work across different MLFlow versions, and it can guarantee to query out all history jobs (submitted via different MLFlow versions) via the static job name.
How is this PR tested?
Does this PR require documentation update?
Release Notes
Is this a user-facing change?
jobdecorator provides anameparam, for marking the static name of the job function.What component(s), interfaces, languages, and integrations does this PR affect?
Components
area/tracking: Tracking Service, tracking client APIs, autologgingarea/models: MLmodel format, model serialization/deserialization, flavorsarea/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registryarea/scoring: MLflow Model server, model deployment tools, Spark UDFsarea/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflowsarea/gateway: MLflow AI Gateway client APIs, server, and third-party integrationsarea/prompts: MLflow prompt engineering features, prompt templates, and prompt managementarea/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionalityarea/projects: MLproject format, project running backendsarea/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev serverarea/build: Build and test infrastructure for MLflowarea/docs: MLflow documentation pagesHow should the PR be classified in the release notes? Choose one:
rn/none- No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" sectionrn/breaking-change- The PR will be mentioned in the "Breaking Changes" sectionrn/feature- A new user-facing feature worth mentioning in the release notesrn/bug-fix- A user-facing bug fix worth mentioning in the release notesrn/documentation- A user-facing documentation change worth mentioning in the release notesShould this PR be included in the next patch release?
Yesshould be selected for bug fixes, documentation updates, and other small changes.Noshould be selected for new features and larger changes. If you're unsure about the release classification of this PR, leave this unchecked to let the maintainers decide.What is a minor/patch release?
Bug fixes, doc updates and new features usually go into minor releases.
Bug fixes and doc updates usually go into patch releases.