Skip to content

Job backend: Update job backend to use static names rather than function full names#19430

Merged
WeichenXu123 merged 15 commits intomlflow:masterfrom
WeichenXu123:ML-60464-3
Dec 18, 2025
Merged

Job backend: Update job backend to use static names rather than function full names#19430
WeichenXu123 merged 15 commits intomlflow:masterfrom
WeichenXu123:ML-60464-3

Conversation

@WeichenXu123
Copy link
Collaborator

@WeichenXu123 WeichenXu123 commented Dec 16, 2025

Related Issues/PRs

#xxx

What 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 job decorator to add a name param, like:

@job(name="the_static_name")
def my_job_function():
    ...

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?

  • Existing unit/integration tests
  • New unit/integration tests
  • Manual tests

Does this PR require documentation update?

  • No. You can skip the rest of this section.
  • Yes. I've updated:
    • Examples
    • API references
    • Instructions

Release Notes

Is this a user-facing change?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release notes for MLflow users.

job decorator provides a name param, 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, autologging
  • area/models: MLmodel format, model serialization/deserialization, flavors
  • area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • area/scoring: MLflow Model server, model deployment tools, Spark UDFs
  • area/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflows
  • area/gateway: MLflow AI Gateway client APIs, server, and third-party integrations
  • area/prompts: MLflow prompt engineering features, prompt templates, and prompt management
  • area/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionality
  • area/projects: MLproject format, project running backends
  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/build: Build and test infrastructure for MLflow
  • area/docs: MLflow documentation pages

How 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" section
  • rn/breaking-change - The PR will be mentioned in the "Breaking Changes" section
  • rn/feature - A new user-facing feature worth mentioning in the release notes
  • rn/bug-fix - A user-facing bug fix worth mentioning in the release notes
  • rn/documentation - A user-facing documentation change worth mentioning in the release notes

Should this PR be included in the next patch release?

Yes should be selected for bug fixes, documentation updates, and other small changes. No should 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?
  • Minor release: a release that increments the second part of the version number (e.g., 1.2.0 -> 1.3.0).
    Bug fixes, doc updates and new features usually go into minor releases.
  • Patch release: a release that increments the third part of the version number (e.g., 1.2.0 -> 1.2.1).
    Bug fixes and doc updates usually go into patch releases.
  • Yes (this PR will be cherry-picked and included in the next patch release)
  • No (this PR will be included in the next minor release)

Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Copilot AI review requested due to automatic review settings December 16, 2025 13:10
@github-actions github-actions bot added area/evaluation MLflow Evaluation area/prompts MLflow Prompt Registry and Optimization area/scoring MLflow Model server, model deployment tools, Spark UDFs rn/feature Mention under Features in Changelogs. labels Dec 16, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 name parameter to the @job decorator for specifying static job names
  • Updated REST API endpoints to use job_name instead of function_fullname in 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_fullname to job_name with 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.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2025

Documentation preview for 11c562a is available at:

More info
  • Ignore this comment if this PR does not change the documentation.
  • The preview is updated when a new commit is pushed to this PR.
  • This comment was created by this workflow run.
  • The documentation was built by this workflow run.

Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Copy link
Collaborator

@B-Step62 B-Step62 Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator Author

@WeichenXu123 WeichenXu123 Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to update linter's _check_forbidden_top_level_import to support the rule. Will do it in follow-up PR

Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
@WeichenXu123 WeichenXu123 added this pull request to the merge queue Dec 18, 2025
Merged via the queue into mlflow:master with commit 2acc4a9 Dec 18, 2025
48 of 50 checks passed
@WeichenXu123 WeichenXu123 deleted the ML-60464-3 branch December 18, 2025 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/evaluation MLflow Evaluation area/prompts MLflow Prompt Registry and Optimization area/scoring MLflow Model server, model deployment tools, Spark UDFs rn/feature Mention under Features in Changelogs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants