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

change validation to handle no method check #60

Merged
merged 1 commit into from
Jan 23, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,21 @@ private void checkPredictiveUnitsMicroservices(PredictiveUnit pu,PredictorSpec p
checkPredictiveUnitsMicroservices(child,p);
}

private void checkTypeAndSubType(PredictiveUnit pu) throws SeldonDeploymentException
/*
* If implementation is specified, ignore the rest
* if not, implementation defaults to UNKNOWN_IMPLEMENTATION and
* if type is specified ignore the rest
* if not, type defaults to UNKNOWN_TYPE and
* if methods is not specified, raise an error (we are in the case when none of implementation, type, methods has been specified)
*/
private void checkTypeMethodAndImpl(PredictiveUnit pu) throws SeldonDeploymentException
{
if (!pu.hasType())
throw new SeldonDeploymentException(String.format("Predictive unit %s has no type",pu.getName()));
if ((!pu.hasImplementation() || pu.getImplementation().getNumber() == PredictiveUnitImplementation.UNKNOWN_IMPLEMENTATION_VALUE) &&
(!pu.hasType() || pu.getType().getNumber() == PredictiveUnitType.UNKNOWN_TYPE_VALUE) &&
pu.getMethodsCount() == 0)
throw new SeldonDeploymentException(String.format("Predictive unit %s has no methods specified",pu.getName()));
for(PredictiveUnit child : pu.getChildrenList())
checkTypeAndSubType(child);
checkTypeMethodAndImpl(child);
}

@Override
Expand All @@ -354,7 +363,7 @@ public void validate(SeldonDeployment mlDep) throws SeldonDeploymentException {
for(PredictorSpec p : mlDep.getSpec().getPredictorsList())
{
checkPredictiveUnitsMicroservices(p.getGraph(),p);
checkTypeAndSubType(p.getGraph());
checkTypeMethodAndImpl(p.getGraph());
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public void testBadGraph() throws IOException, SeldonDeploymentException
}

@Test(expected = SeldonDeploymentException.class)
public void testNoType() throws IOException, SeldonDeploymentException
public void testNoMethod() throws IOException, SeldonDeploymentException
{
SeldonDeploymentOperator op = new SeldonDeploymentOperatorImpl(getClusterManagerprops());
String jsonStr = readFile("src/test/resources/model_invalid_no_type.json",StandardCharsets.UTF_8);
String jsonStr = readFile("src/test/resources/model_invalid_no_method.json",StandardCharsets.UTF_8);
SeldonDeployment mlDep = SeldonDeploymentUtils.jsonToSeldonDeployment(jsonStr);
SeldonDeployment mlDep2 = op.defaulting(mlDep);
op.validate(mlDep2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"endpoint": {
"type" : "REST"
},
"subtype": "MICROSERVICE",
"type": "MODEL"
},
"name": "fx-market-predictor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
"name": "mean-classifier",
"endpoint": {
"type" : "REST"
},
"subtype": "MICROSERVICE"
}
},
"name": "fx-market-predictor",
"replicas": 1,
Expand Down