Skip to content

Commit

Permalink
Fix: "Source Run" field in Model Version UI page points to wrong run …
Browse files Browse the repository at this point in the history
…model artifact in Run UI page (#8156)

* init

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

* format

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

* update

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

* update test

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

* update

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

* update

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

* update

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

* update

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

* update

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

---------

Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
  • Loading branch information
WeichenXu123 committed Apr 12, 2023
1 parent 928a6ae commit 4728afe
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 3 deletions.
8 changes: 6 additions & 2 deletions mlflow/server/js/src/experiment-tracking/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ class Routes {

static experimentPageSearchRoute = '/experiments/:experimentId/:searchString';

static getRunPageRoute(experimentId, runUuid) {
return `/experiments/${experimentId}/runs/${runUuid}`;
static getRunPageRoute(experimentId, runUuid, artifactPath = null) {
const path = `/experiments/${experimentId}/runs/${runUuid}`;
if (artifactPath) {
return `${path}/artifactPath/${artifactPath}`;
}
return path;
}

static runPageRoute = '/experiments/:experimentId/runs/:runUuid';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { setModelVersionTagApi, deleteModelVersionTagApi } from '../actions';
import { connect } from 'react-redux';
import { OverflowMenu, PageHeader } from '../../shared/building_blocks/PageHeader';
import { FormattedMessage, injectIntl } from 'react-intl';
import { extractArtifactPathFromModelSource } from '../utils/VersionUtils';

export class ModelVersionViewImpl extends React.Component {
static propTypes = {
Expand Down Expand Up @@ -316,8 +317,19 @@ export class ModelVersionViewImpl extends React.Component {
</a>
);
} else if (runInfo) {
let artifactPath = null;
const modelSource = this.props.modelVersion?.source;
if (modelSource) {
artifactPath = extractArtifactPathFromModelSource(modelSource, runInfo.getRunUuid());
}
return (
<Link to={Routers.getRunPageRoute(runInfo.getExperimentId(), runInfo.getRunUuid())}>
<Link
to={Routers.getRunPageRoute(
runInfo.getExperimentId(),
runInfo.getRunUuid(),
artifactPath,
)}
>
{this.resolveRunName()}
</Link>
);
Expand Down
36 changes: 36 additions & 0 deletions mlflow/server/js/src/model-registry/utils/VersionUtils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { extractArtifactPathFromModelSource } from './VersionUtils';

describe('extractArtifactPathFromModelSource', () => {
it('test extractArtifactPathFromModelSource', () => {
expect(
extractArtifactPathFromModelSource('mlflow-artifacts:/0/01bcd/artifacts/xx/yy', '01bcd'),
).toBe('xx/yy');
expect(
extractArtifactPathFromModelSource(
'mlflow-artifacts:/0/01bcd/artifacts/artifacts/xx/yy',
'01bcd',
),
).toBe('artifacts/xx/yy');
expect(
extractArtifactPathFromModelSource('mlflow-artifacts:/0/01bcd/artifacts/xx/yy', '01bce'),
).toBe(undefined);
expect(
extractArtifactPathFromModelSource('file///path/to/mlruns/0/01bcd/artifacts/xx/yy', '01bcd'),
).toBe('xx/yy');
expect(
extractArtifactPathFromModelSource(
'file///path/to/artifacts/mlruns/0/01bcd/artifacts/xx/yy',
'01bcd',
),
).toBe('xx/yy');
expect(
extractArtifactPathFromModelSource(
'file///path/to/mlruns/0/01bcd/artifacts/artifacts/xx/yy',
'01bcd',
),
).toBe('artifacts/xx/yy');
expect(
extractArtifactPathFromModelSource('file///path/to/mlruns/0/01bcd/artifacts/xx/yy', '01bce'),
).toBe(undefined);
});
});
6 changes: 6 additions & 0 deletions mlflow/server/js/src/model-registry/utils/VersionUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Extract artifact path from provided `modelSource` string
*/
export function extractArtifactPathFromModelSource(modelSource: string, runId: string) {
return modelSource.match(new RegExp(`/${runId}/artifacts/(.+)`))?.[1];
}

0 comments on commit 4728afe

Please sign in to comment.