Skip to content

Commit

Permalink
fix properties.name mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
yoonhyejin committed Jan 28, 2025
1 parent a1c0125 commit dfd66bf
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ private void mapDataProcessProperties(
dataProcessInstanceProperties.getCustomProperties(), entityUrn));
}
if (dataProcessInstanceProperties.hasCreated()) {
com.linkedin.datahub.graphql.generated.AuditStamp created =
AuditStampMapper.map(context, dataProcessInstanceProperties.getCreated());
properties.setCreated(created);
dpi.setCreated(AuditStampMapper.map(context, dataProcessInstanceProperties.getCreated()));
}
dpi.setProperties(properties);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public MLModelGroupProperties apply(
result.setCreated(
TimeStampToAuditStampMapper.map(context, mlModelGroupProperties.getCreated()));
}
if (mlModelGroupProperties.getName() != null) {
result.setName(mlModelGroupProperties.getName());
} else {
// backfill name from URN for backwards compatibility
result.setName(entityUrn.getEntityKey().get(1)); // indexed access is safe here
}

if (mlModelGroupProperties.hasLastModified()) {
result.setLastModified(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public void testMapMLModelGroupProperties() throws URISyntaxException {
// Set description
input.setDescription("a ml trust model group");

// Set Name
input.setName("ML trust model group");

// Create URN
Urn groupUrn =
Urn.createFromString(
Expand All @@ -31,6 +34,7 @@ public void testMapMLModelGroupProperties() throws URISyntaxException {
// Verify mapped properties
assertNotNull(result);
assertEquals(result.getDescription(), "a ml trust model group");
assertEquals(result.getName(), "ML trust model group");

// Verify lineage info is null as in the mock data
assertNotNull(result.getMlModelLineageInfo());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Preview = ({
return (
<DefaultPreviewCard
url={entityRegistry.getEntityUrl(EntityType.Mlmodel, model.urn)}
name={model.name || ''}
name={model.properties?.['propertiesName'] || model.name || ''}
urn={model.urn}
description={model.description || ''}
platformInstanceId={model.dataPlatformInstance?.instanceId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class MLModelGroupEntity implements Entity<MlModelGroup> {
};

displayName = (data: MlModelGroup) => {
return data.name || data.urn;
return data.properties?.name || data.name || data.urn;
};

getGenericEntityProperties = (mlModelGroup: MlModelGroup) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const Preview = ({
return (
<DefaultPreviewCard
url={entityRegistry.getEntityUrl(EntityType.MlmodelGroup, group.urn)}
name={group?.name || ''}
name={group?.properties?.['propertiesName'] || group?.name || ''}
urn={group.urn}
platformInstanceId={group.dataPlatformInstance?.instanceId}
description={group?.description || ''}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ export default function MLGroupModels() {
dataIndex: 'name',
key: 'name',
width: 300,

Check warning on line 82 in datahub-web-react/src/app/entity/mlModelGroup/profile/ModelGroupModels.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/entity/mlModelGroup/profile/ModelGroupModels.tsx#L70-L82

Added lines #L70 - L82 were not covered by tests
render: (name, record) => (
render: (_: any, record) => (
<NameContainer>

Check warning on line 84 in datahub-web-react/src/app/entity/mlModelGroup/profile/ModelGroupModels.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/entity/mlModelGroup/profile/ModelGroupModels.tsx#L84

Added line #L84 was not covered by tests
<NameLink href={entityRegistry.getEntityUrl(EntityType.Mlmodel, record.urn)}>{name}</NameLink>
<NameLink href={entityRegistry.getEntityUrl(EntityType.Mlmodel, record.urn)}>{record?.properties?.propertiesName || record?.name }</NameLink>
</NameContainer>
),
},
Expand Down
2 changes: 1 addition & 1 deletion datahub-web-react/src/app/shared/time/timeUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export function formatDuration(durationMs: number): string {
const seconds = duration.seconds();

if (hours === 0 && minutes === 0) {

Check warning on line 216 in datahub-web-react/src/app/shared/time/timeUtils.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/shared/time/timeUtils.tsx#L211-L216

Added lines #L211 - L216 were not covered by tests
return `${seconds}secs`;
return `${seconds} secs`;
}

if (hours === 0) {
Expand Down
2 changes: 2 additions & 0 deletions datahub-web-react/src/graphql/lineage.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ fragment lineageNodeProperties on EntityWithRelationships {
removed
}
properties {
propertiesName: name
createdTS: created {
time
actor
Expand Down Expand Up @@ -322,6 +323,7 @@ fragment lineageNodeProperties on EntityWithRelationships {
comment
}
properties {
propertiesName: name
createdTS: created {
time
actor
Expand Down
6 changes: 6 additions & 0 deletions datahub-web-react/src/graphql/search.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,9 @@ fragment searchResultsWithoutSchemaField on Entity {
...structuredPropertiesFields
}
}
properties {
propertiesName: name
}
}
... on MLModelGroup {
name
Expand All @@ -908,6 +911,9 @@ fragment searchResultsWithoutSchemaField on Entity {
...structuredPropertiesFields
}
}
properties {
propertiesName: name
}
}
... on Tag {
name
Expand Down

0 comments on commit dfd66bf

Please sign in to comment.