Skip to content

Add selected dataset ID to URL for sharing#19142

Merged
dbczumar merged 7 commits intomlflow:masterfrom
dbczumar:dataset_url
Dec 4, 2025
Merged

Add selected dataset ID to URL for sharing#19142
dbczumar merged 7 commits intomlflow:masterfrom
dbczumar:dataset_url

Conversation

@dbczumar
Copy link
Collaborator

@dbczumar dbczumar commented Dec 1, 2025

🛠 DevTools 🛠

Open in GitHub Codespaces

Install mlflow from this PR

# mlflow
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/19142/merge
# mlflow-skinny
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/19142/merge#subdirectory=libs/skinny

For Databricks, use the following command:

%sh curl -LsSf https://raw.githubusercontent.com/mlflow/mlflow/HEAD/dev/install-skinny.sh | sh -s pull/19142/merge

Related Issues/PRs

#xxx

What changes are proposed in this pull request?

Add selected dataset ID to URL for sharing

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.

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: dbczumar <corey.zumar@databricks.com>
Signed-off-by: dbczumar <corey.zumar@databricks.com>
@github-actions github-actions bot added the v3.7.0 label Dec 1, 2025
@github-actions github-actions bot added area/evaluation MLflow Evaluation rn/none List under Small Changes in Changelogs. labels Dec 1, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

Documentation preview for fd94a22 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.

import type { EvaluationDataset } from './types';
import { ExperimentEvaluationDatasetsPageWrapper } from './ExperimentEvaluationDatasetsPageWrapper';
import { ExperimentEvaluationDatasetsEmptyState } from './components/ExperimentEvaluationDatasetsEmptyState';
import { useSelectedDatasetBySearchParam } from './hooks/useSelectedDatasetBySearchParam';
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this defined somewhere?

Copy link
Collaborator Author

@dbczumar dbczumar Dec 1, 2025

Choose a reason for hiding this comment

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

Sorry, forgot to commit it - pushed!

// Set the selected dataset if we don't already have one,
// or if the selected dataset went out of scope (e.g. was deleted / not in search)
if (!selectedDataset || !datasets.some((d) => d.dataset_id === selectedDataset.dataset_id)) {
if (datasets?.length && (!selectedDatasetId || !datasetIds.includes(selectedDatasetId))) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

not technically a problem with this PR, but can we put this whole state-setting block in an useeffect? otherwise this has risk of very easily causing infinite render loops

  useEffect(() => {
    // No datasets -> clear selection
    if (!datasets?.length) {
      setSelectedDataset(undefined);
      setSelectedDatasetId(undefined);
      return;
    }

    // Valid selectedDatasetId from URL -> use it
    if (selectedDatasetId) {
      const matchingDataset = datasets.find((d) => d.dataset_id === selectedDatasetId);
      if (matchingDataset) {
        setSelectedDataset(matchingDataset);
        return;
      }
    }

    // No valid selection -> auto-select first
    const sortedRows = table.getRowModel().rows;
    if (sortedRows.length > 0) {
      const firstDataset = sortedRows[0].original;
      setSelectedDataset(firstDataset);
      setSelectedDatasetId(firstDataset.dataset_id);
    }
  }, [datasets, selectedDatasetId, setSelectedDataset, setSelectedDatasetId, table]);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Totally - done.

otherwise this has risk of very easily causing infinite render loops

I actually observed this while iterating on the PR - glad there's a better way :)

Signed-off-by: dbczumar <corey.zumar@databricks.com>
Signed-off-by: dbczumar <corey.zumar@databricks.com>
import { useCallback } from 'react';
import { useSearchParams } from '@mlflow/mlflow/src/common/utils/RoutingUtils';

const QUERY_PARAM_KEY = 'selectedDataset';
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: add Id to make it clear + align with the name in code?

Suggested change
const QUERY_PARAM_KEY = 'selectedDataset';
const QUERY_PARAM_KEY = 'selectedDatasetId';

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done :)

const [datasetListHidden, setDatasetListHidden] = useState(false);
const [selectedDataset, setSelectedDataset] = useState<EvaluationDataset | undefined>(undefined);
const [isDatasetsLoading, setIsDatasetsLoading] = useState(false);
const [selectedDatasetId, setSelectedDatasetId] = useSelectedDatasetBySearchParam();
Copy link
Collaborator

Choose a reason for hiding this comment

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

rather than using the hook here and passing it down to ExperimentEvaluationDatasetsListTable, can we just use it in ExperimentEvaluationDatasetsListTable directly?

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh i think i see what the intention was. can we define a callback that combines setSelectedDataset and setSelectedDatasetId and pass that in instead (similar to what we did in https://github.com/mlflow/mlflow/pull/19142/files#diff-e2232542c52cc97ec1dd208f20ebfc9ded43289282fa3c8f378b8aa1a318445bR109:

Suggested change
const [selectedDatasetId, setSelectedDatasetId] = useSelectedDatasetBySearchParam();
const [selectedDatasetId, setSelectedDatasetId] = useSelectedDatasetBySearchParam();
const onSelectDataset = useCallback((dataset) => {
setSelectedDataset(dataset);
setSelectedDatasetId(dataset.dataset_id);
});

Copy link
Collaborator

Choose a reason for hiding this comment

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

ignore the above comments! once we address https://github.com/mlflow/mlflow/pull/19142/files#r2579393406 it should be taken care of.

Comment on lines +216 to +217
// Sync dataset selection state with URL and available datasets
useEffect(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: not sure if this needs to be an effect: https://react.dev/learn/you-might-not-need-an-effect

the original was not written with an effect

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, this was guidance from @danielseong1 - I reverted to not use an effect

Comment on lines +238 to +244
// Sync selectedDataset object when selectedDatasetId changes (e.g., from URL)
if (selectedDataset?.dataset_id !== selectedDatasetId) {
const datasetFromId = datasets?.find((d) => d.dataset_id === selectedDatasetId);
if (datasetFromId) {
setSelectedDataset(datasetFromId);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

actually thinking about it further, i think we should just remove selectedDataset as a state field entirely. it should just purely be derived from datasets + selectedDatasetId. it's weird to have two sources of truth here and have to keep them in sync.

can we lift the useSearchEvaluationDatasets call (lines 177 - 185 above) to the parent component, and pass datasets in here? then we can do something like const selectedDataset = datasets.find(dataset => dataset.dataset_id === selectedDatasetId) rather than having it be in state

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Awesome! Done :)

- Rename query param key to 'selectedDatasetId' for clarity
- Lift useSearchEvaluationDatasets to parent component
- Derive selectedDataset from datasets + selectedDatasetId
- Remove duplicate state, simplify auto-selection logic

Signed-off-by: dbczumar <corey.zumar@databricks.com>
Address review comment to make child component purely presentational
by moving the auto-selection useEffect to the parent component.

Signed-off-by: dbczumar <corey.zumar@databricks.com>
Signed-off-by: dbczumar <corey.zumar@databricks.com>
@BenWilson2 BenWilson2 added v3.7.1 and removed v3.7.0 labels Dec 4, 2025
Copy link
Collaborator

@daniellok-db daniellok-db left a comment

Choose a reason for hiding this comment

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

Lg!

@dbczumar dbczumar added this pull request to the merge queue Dec 4, 2025
Merged via the queue into mlflow:master with commit 24c1353 Dec 4, 2025
56 of 59 checks passed
@dbczumar dbczumar deleted the dataset_url branch December 4, 2025 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/evaluation MLflow Evaluation rn/none List under Small Changes in Changelogs. v3.7.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants