-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(models): update mlflow-related mappers (#12263)
Co-authored-by: Shirshanka Das <[email protected]> Co-authored-by: RyanHolstien <[email protected]>
- Loading branch information
1 parent
e34b2e4
commit ddd0d21
Showing
35 changed files
with
2,046 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...n/java/com/linkedin/datahub/graphql/types/common/mappers/TimeStampToAuditStampMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.linkedin.datahub.graphql.types.common.mappers; | ||
|
||
import com.linkedin.common.TimeStamp; | ||
import com.linkedin.datahub.graphql.QueryContext; | ||
import com.linkedin.datahub.graphql.generated.AuditStamp; | ||
import javax.annotation.Nullable; | ||
|
||
public class TimeStampToAuditStampMapper { | ||
|
||
public static final TimeStampToAuditStampMapper INSTANCE = new TimeStampToAuditStampMapper(); | ||
|
||
public static AuditStamp map( | ||
@Nullable final QueryContext context, @Nullable final TimeStamp input) { | ||
if (input == null) { | ||
return null; | ||
} | ||
final AuditStamp result = new AuditStamp(); | ||
result.setTime(input.getTime()); | ||
if (input.hasActor()) { | ||
result.setActor(input.getActor().toString()); | ||
} | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
...main/java/com/linkedin/datahub/graphql/types/dataprocessinst/DataProcessInstanceType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package com.linkedin.datahub.graphql.types.dataprocessinst; | ||
|
||
import static com.linkedin.metadata.Constants.*; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import com.linkedin.common.urn.Urn; | ||
import com.linkedin.common.urn.UrnUtils; | ||
import com.linkedin.datahub.graphql.QueryContext; | ||
import com.linkedin.datahub.graphql.featureflags.FeatureFlags; | ||
import com.linkedin.datahub.graphql.generated.DataProcessInstance; | ||
import com.linkedin.datahub.graphql.generated.Entity; | ||
import com.linkedin.datahub.graphql.generated.EntityType; | ||
import com.linkedin.datahub.graphql.types.dataprocessinst.mappers.DataProcessInstanceMapper; | ||
import com.linkedin.entity.EntityResponse; | ||
import com.linkedin.entity.client.EntityClient; | ||
import graphql.execution.DataFetcherResult; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
import javax.annotation.Nonnull; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public class DataProcessInstanceType | ||
implements com.linkedin.datahub.graphql.types.EntityType<DataProcessInstance, String> { | ||
|
||
public static final Set<String> ASPECTS_TO_FETCH = | ||
ImmutableSet.of( | ||
DATA_PROCESS_INSTANCE_KEY_ASPECT_NAME, | ||
DATA_PLATFORM_INSTANCE_ASPECT_NAME, | ||
DATA_PROCESS_INSTANCE_PROPERTIES_ASPECT_NAME, | ||
DATA_PROCESS_INSTANCE_INPUT_ASPECT_NAME, | ||
DATA_PROCESS_INSTANCE_OUTPUT_ASPECT_NAME, | ||
DATA_PROCESS_INSTANCE_RUN_EVENT_ASPECT_NAME, | ||
TEST_RESULTS_ASPECT_NAME, | ||
DATA_PROCESS_INSTANCE_RELATIONSHIPS_ASPECT_NAME, | ||
ML_TRAINING_RUN_PROPERTIES_ASPECT_NAME, | ||
SUB_TYPES_ASPECT_NAME, | ||
CONTAINER_ASPECT_NAME); | ||
|
||
private final EntityClient _entityClient; | ||
private final FeatureFlags _featureFlags; | ||
|
||
@Override | ||
public EntityType type() { | ||
return EntityType.DATA_PROCESS_INSTANCE; | ||
} | ||
|
||
@Override | ||
public Function<Entity, String> getKeyProvider() { | ||
return Entity::getUrn; | ||
} | ||
|
||
@Override | ||
public Class<DataProcessInstance> objectClass() { | ||
return DataProcessInstance.class; | ||
} | ||
|
||
@Override | ||
public List<DataFetcherResult<DataProcessInstance>> batchLoad( | ||
@Nonnull List<String> urns, @Nonnull QueryContext context) throws Exception { | ||
final List<Urn> dataProcessInstanceUrns = | ||
urns.stream().map(UrnUtils::getUrn).collect(Collectors.toList()); | ||
|
||
try { | ||
Map<Urn, EntityResponse> entities = new HashMap<>(); | ||
if (_featureFlags.isDataProcessInstanceEntityEnabled()) { | ||
entities = | ||
_entityClient.batchGetV2( | ||
context.getOperationContext(), | ||
DATA_PROCESS_INSTANCE_ENTITY_NAME, | ||
new HashSet<>(dataProcessInstanceUrns), | ||
ASPECTS_TO_FETCH); | ||
} | ||
|
||
final List<EntityResponse> gmsResults = new ArrayList<>(); | ||
for (Urn urn : dataProcessInstanceUrns) { | ||
if (_featureFlags.isDataProcessInstanceEntityEnabled()) { | ||
gmsResults.add(entities.getOrDefault(urn, null)); | ||
} | ||
} | ||
|
||
return gmsResults.stream() | ||
.map( | ||
gmsResult -> | ||
gmsResult == null | ||
? null | ||
: DataFetcherResult.<DataProcessInstance>newResult() | ||
.data(DataProcessInstanceMapper.map(context, gmsResult)) | ||
.build()) | ||
.collect(Collectors.toList()); | ||
|
||
} catch (Exception e) { | ||
throw new RuntimeException("Failed to load Data Process Instance entity", e); | ||
} | ||
} | ||
} |
Oops, something went wrong.