Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: MLmodel Graphql Query #2166

Merged
merged 11 commits into from
Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
282 changes: 282 additions & 0 deletions datahub-gms-graphql-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,285 @@ Sample Response:
}
```

### Query MLModel

Sample Request:

```
{
mlModel(urn: "urn:li:mlModel:(urn:li:dataPlatform:science,scienceModel,PROD)") {
urn
type
name
origin
description
tags
ownership {
owners {
owner {
urn
username
editableInfo {
pictureLink
}
info {
firstName
}
}
type
source {
type
url
}
}
}
properties {
description
date
version
type
hyperParameters {
key
value {
...on StringBox {
stringValue
}
... on IntBox {
intValue
}
... on FloatBox {
floatValue
}
... on BooleanBox {
booleanValue
}
}
}
mlFeatures
tags
}
status {
removed
}
institutionalMemory {
elements {
url
description
created {
actor
}
}
}
intendedUse {
primaryUses
primaryUsers
outOfScopeUses
}
factorPrompts {
relevantFactors {
groups
instrumentation
environment
}
evaluationFactors {
groups
instrumentation
environment
}
}
metrics {
decisionThreshold
performanceMeasures
}
trainingData {
dataset
motivation
preProcessing
}
evaluationData {
dataset
motivation
preProcessing
}
quantitativeAnalyses {
unitaryResults {
...on StringBox {
stringValue
}
}
intersectionalResults {
...on StringBox {
stringValue
}
}
}
ethicalConsiderations {
useCases
humanLife
mitigations
risksAndHarms
useCases
data
}
caveatsAndRecommendations {
caveats {
caveatDescription
needsFurtherTesting
groupsNotRepresented
}
recommendations
idealDatasetCharacteristics
}
cost {
costType
costValue {
costId
costCode
}
}
}
}
```

Sample Response:

```
{
"data": {
"mlModel": {
"urn": "urn:li:mlModel:(urn:li:dataPlatform:science,scienceModel,PROD)",
"type": "MLMODEL",
"name": "scienceModel",
"origin": "PROD",
"description": "A sample model for predicting some outcome.",
"tags": [
"Sample"
],
"ownership": {
"owners": [
{
"owner": {
"urn": "urn:li:corpuser:jdoe",
"username": "jdoe",
"editableInfo": null,
"info": {
"firstName": null
}
},
"type": "DATAOWNER",
"source": null
},
{
"owner": {
"urn": "urn:li:corpuser:datahub",
"username": "datahub",
"editableInfo": {
"pictureLink": "https://raw.githubusercontent.com/linkedin/datahub/master/datahub-web/packages/data-portal/public/assets/images/default_avatar.png"
},
"info": {
"firstName": null
}
},
"type": "DATAOWNER",
"source": null
}
]
},
"properties": {
"description": "A sample model for predicting some outcome.",
"date": null,
"version": null,
"type": "Naive Bayes classifier",
"hyperParameters": null,
"mlFeatures": null,
"tags": [
"Sample"
]
},
"status": {
"removed": false
},
"institutionalMemory": {
"elements": [
{
"url": "https://www.linkedin.com",
"description": "Sample doc",
"created": {
"actor": "urn:li:corpuser:jdoe"
}
}
]
},
"intendedUse": {
"primaryUses": [
"Sample Model",
"Primary Use"
],
"primaryUsers": [
"ENTERPRISE"
],
"outOfScopeUses": [
"Production Deployment"
]
},
"factorPrompts": null,
"metrics": {
"decisionThreshold": [
"decisionThreshold"
],
"performanceMeasures": [
"performanceMeasures"
]
},
"trainingData": [
{
"dataset": "urn:li:dataset:(urn:li:dataPlatform:hive,pageViewsHive,PROD)",
"motivation": "For science!",
"preProcessing": [
"Aggregation"
]
}
],
"evaluationData": [
{
"dataset": "urn:li:dataset:(urn:li:dataPlatform:hive,pageViewsHive,PROD)",
"motivation": null,
"preProcessing": null
}
],
"quantitativeAnalyses": null,
"ethicalConsiderations": {
"useCases": [
"useCases"
],
"humanLife": [
"humanLife"
],
"mitigations": [
"mitigations"
],
"risksAndHarms": [
"risksAndHarms"
],
"data": [
"data"
]
},
"caveatsAndRecommendations": {
"caveats": null,
"recommendations": "recommendations",
"idealDatasetCharacteristics": [
"idealDatasetCharacteristics"
]
},
"cost": {
"costType": "ORG_COST_TYPE",
"costValue": {
"costId": null,
"costCode": "costCode"
}
}
}
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.linkedin.dataset.client.Lineages;
import com.linkedin.identity.client.CorpUsers;
import com.linkedin.metadata.restli.DefaultRestliClientFactory;
import com.linkedin.ml.client.MLModels;
import com.linkedin.restli.client.Client;
import com.linkedin.tag.client.Tags;
import com.linkedin.util.Configuration;
Expand All @@ -33,6 +34,7 @@ public class GmsClientFactory {
private static Dashboards _dashboards;
private static Charts _charts;
private static DataPlatforms _dataPlatforms;
private static MLModels _mlModels;
private static Lineages _lineages;
private static Tags _tags;

Expand Down Expand Up @@ -94,6 +96,17 @@ public static DataPlatforms getDataPlatformsClient() {
return _dataPlatforms;
}

public static MLModels getMLModelsClient() {
if (_mlModels == null) {
synchronized (GmsClientFactory.class) {
if (_mlModels == null) {
_mlModels = new MLModels(REST_CLIENT);
}
}
}
return _mlModels;
}

public static Lineages getLineagesClient() {
if (_lineages == null) {
synchronized (GmsClientFactory.class) {
Expand Down
Loading