@Test public void illegalOutput() { flowEvaluatorManifest.setOutputs(Collections.singletonList(new Field("unknown", DataType.DOUBLE))); Assertions.assertThrows(EvaluatorException.class, () -> flowEvaluatorManifest.create("") ); }
public static FlowEvaluator create(FlowEvaluatorManifest flowEvaluatorManifest, String path) throws EvaluatorException, IOException { List<EvaluatorManifest> evaluatorManifests = flowEvaluatorManifest.getEvaluatorManifests(); List<Evaluator<? extends Field>> evaluators = new ArrayList<>(evaluatorManifests.size()); Set<Field> pureInputSet = new HashSet<>(); Set<Field> outputSet = new HashSet<>(); int batchSize = 1; for (EvaluatorManifest evaluatorManifest : evaluatorManifests) { Evaluator<?> evaluator = evaluatorManifest.create(path); Validator.validate(evaluator); evaluators.add(evaluator); outputSet.addAll(evaluator.getOutputs()); List<String> inputsNames = evaluator.getInputs().stream().map(Field::getName).collect(Collectors.toList()); List<String> outputNames = outputSet.stream().map(Field::getName).collect(Collectors.toList()); Set<String> diff = SetUtils.difference(new HashSet<>(inputsNames), new HashSet<>(outputNames)); pureInputSet.addAll( evaluator.getInputs().stream().filter(x -> diff.contains(x.getName())).collect(Collectors.toList()) ); batchSize += evaluator.getRollingWindowSize() - 1; } List<? extends Field> actualOutputs; if (!flowEvaluatorManifest.getOutputs().isEmpty()) { actualOutputs = flowEvaluatorManifest.getOutputs(); SetUtils.SetView<Field> difference = SetUtils.difference(new HashSet<>(actualOutputs), outputSet); if (!difference.isEmpty()) { throw new EvaluatorException( String.format( "Desired outputs %s are not actual outputs of the described FlowEvaluator", difference.stream().map(Field::getName).collect(Collectors.joining(",")) ) ); } } else { if (evaluators.isEmpty()) { actualOutputs = new LinkedList<>(); } else { actualOutputs = evaluators.get(evaluators.size() - 1).getOutputs(); } } return new FlowEvaluator(evaluators, new LinkedList<>(pureInputSet), actualOutputs, batchSize); }
FlowEvaluator implements Evaluator { public static FlowEvaluator create(FlowEvaluatorManifest flowEvaluatorManifest, String path) throws EvaluatorException, IOException { List<EvaluatorManifest> evaluatorManifests = flowEvaluatorManifest.getEvaluatorManifests(); List<Evaluator<? extends Field>> evaluators = new ArrayList<>(evaluatorManifests.size()); Set<Field> pureInputSet = new HashSet<>(); Set<Field> outputSet = new HashSet<>(); int batchSize = 1; for (EvaluatorManifest evaluatorManifest : evaluatorManifests) { Evaluator<?> evaluator = evaluatorManifest.create(path); Validator.validate(evaluator); evaluators.add(evaluator); outputSet.addAll(evaluator.getOutputs()); List<String> inputsNames = evaluator.getInputs().stream().map(Field::getName).collect(Collectors.toList()); List<String> outputNames = outputSet.stream().map(Field::getName).collect(Collectors.toList()); Set<String> diff = SetUtils.difference(new HashSet<>(inputsNames), new HashSet<>(outputNames)); pureInputSet.addAll( evaluator.getInputs().stream().filter(x -> diff.contains(x.getName())).collect(Collectors.toList()) ); batchSize += evaluator.getRollingWindowSize() - 1; } List<? extends Field> actualOutputs; if (!flowEvaluatorManifest.getOutputs().isEmpty()) { actualOutputs = flowEvaluatorManifest.getOutputs(); SetUtils.SetView<Field> difference = SetUtils.difference(new HashSet<>(actualOutputs), outputSet); if (!difference.isEmpty()) { throw new EvaluatorException( String.format( "Desired outputs %s are not actual outputs of the described FlowEvaluator", difference.stream().map(Field::getName).collect(Collectors.joining(",")) ) ); } } else { if (evaluators.isEmpty()) { actualOutputs = new LinkedList<>(); } else { actualOutputs = evaluators.get(evaluators.size() - 1).getOutputs(); } } return new FlowEvaluator(evaluators, new LinkedList<>(pureInputSet), actualOutputs, batchSize); } }
FlowEvaluator implements Evaluator { public static FlowEvaluator create(FlowEvaluatorManifest flowEvaluatorManifest, String path) throws EvaluatorException, IOException { List<EvaluatorManifest> evaluatorManifests = flowEvaluatorManifest.getEvaluatorManifests(); List<Evaluator<? extends Field>> evaluators = new ArrayList<>(evaluatorManifests.size()); Set<Field> pureInputSet = new HashSet<>(); Set<Field> outputSet = new HashSet<>(); int batchSize = 1; for (EvaluatorManifest evaluatorManifest : evaluatorManifests) { Evaluator<?> evaluator = evaluatorManifest.create(path); Validator.validate(evaluator); evaluators.add(evaluator); outputSet.addAll(evaluator.getOutputs()); List<String> inputsNames = evaluator.getInputs().stream().map(Field::getName).collect(Collectors.toList()); List<String> outputNames = outputSet.stream().map(Field::getName).collect(Collectors.toList()); Set<String> diff = SetUtils.difference(new HashSet<>(inputsNames), new HashSet<>(outputNames)); pureInputSet.addAll( evaluator.getInputs().stream().filter(x -> diff.contains(x.getName())).collect(Collectors.toList()) ); batchSize += evaluator.getRollingWindowSize() - 1; } List<? extends Field> actualOutputs; if (!flowEvaluatorManifest.getOutputs().isEmpty()) { actualOutputs = flowEvaluatorManifest.getOutputs(); SetUtils.SetView<Field> difference = SetUtils.difference(new HashSet<>(actualOutputs), outputSet); if (!difference.isEmpty()) { throw new EvaluatorException( String.format( "Desired outputs %s are not actual outputs of the described FlowEvaluator", difference.stream().map(Field::getName).collect(Collectors.joining(",")) ) ); } } else { if (evaluators.isEmpty()) { actualOutputs = new LinkedList<>(); } else { actualOutputs = evaluators.get(evaluators.size() - 1).getOutputs(); } } return new FlowEvaluator(evaluators, new LinkedList<>(pureInputSet), actualOutputs, batchSize); } private  FlowEvaluator(
        List<Evaluator<?>> evaluators,
        List<? extends Field> inputs,
        List<? extends Field> outputs,
        int rollingWindowsSize
    ); }
FlowEvaluator implements Evaluator { public static FlowEvaluator create(FlowEvaluatorManifest flowEvaluatorManifest, String path) throws EvaluatorException, IOException { List<EvaluatorManifest> evaluatorManifests = flowEvaluatorManifest.getEvaluatorManifests(); List<Evaluator<? extends Field>> evaluators = new ArrayList<>(evaluatorManifests.size()); Set<Field> pureInputSet = new HashSet<>(); Set<Field> outputSet = new HashSet<>(); int batchSize = 1; for (EvaluatorManifest evaluatorManifest : evaluatorManifests) { Evaluator<?> evaluator = evaluatorManifest.create(path); Validator.validate(evaluator); evaluators.add(evaluator); outputSet.addAll(evaluator.getOutputs()); List<String> inputsNames = evaluator.getInputs().stream().map(Field::getName).collect(Collectors.toList()); List<String> outputNames = outputSet.stream().map(Field::getName).collect(Collectors.toList()); Set<String> diff = SetUtils.difference(new HashSet<>(inputsNames), new HashSet<>(outputNames)); pureInputSet.addAll( evaluator.getInputs().stream().filter(x -> diff.contains(x.getName())).collect(Collectors.toList()) ); batchSize += evaluator.getRollingWindowSize() - 1; } List<? extends Field> actualOutputs; if (!flowEvaluatorManifest.getOutputs().isEmpty()) { actualOutputs = flowEvaluatorManifest.getOutputs(); SetUtils.SetView<Field> difference = SetUtils.difference(new HashSet<>(actualOutputs), outputSet); if (!difference.isEmpty()) { throw new EvaluatorException( String.format( "Desired outputs %s are not actual outputs of the described FlowEvaluator", difference.stream().map(Field::getName).collect(Collectors.joining(",")) ) ); } } else { if (evaluators.isEmpty()) { actualOutputs = new LinkedList<>(); } else { actualOutputs = evaluators.get(evaluators.size() - 1).getOutputs(); } } return new FlowEvaluator(evaluators, new LinkedList<>(pureInputSet), actualOutputs, batchSize); } private  FlowEvaluator(
        List<Evaluator<?>> evaluators,
        List<? extends Field> inputs,
        List<? extends Field> outputs,
        int rollingWindowsSize
    ); static FlowEvaluator create(FlowEvaluatorManifest flowEvaluatorManifest, String path); @Override TensorIO evaluate(TensorIO io, EvaluationContext evaluationContext); @Override List<? extends Field> getInputs(); @Override List<? extends Field> getOutputs(); @Override int getRollingWindowSize(); }
FlowEvaluator implements Evaluator { public static FlowEvaluator create(FlowEvaluatorManifest flowEvaluatorManifest, String path) throws EvaluatorException, IOException { List<EvaluatorManifest> evaluatorManifests = flowEvaluatorManifest.getEvaluatorManifests(); List<Evaluator<? extends Field>> evaluators = new ArrayList<>(evaluatorManifests.size()); Set<Field> pureInputSet = new HashSet<>(); Set<Field> outputSet = new HashSet<>(); int batchSize = 1; for (EvaluatorManifest evaluatorManifest : evaluatorManifests) { Evaluator<?> evaluator = evaluatorManifest.create(path); Validator.validate(evaluator); evaluators.add(evaluator); outputSet.addAll(evaluator.getOutputs()); List<String> inputsNames = evaluator.getInputs().stream().map(Field::getName).collect(Collectors.toList()); List<String> outputNames = outputSet.stream().map(Field::getName).collect(Collectors.toList()); Set<String> diff = SetUtils.difference(new HashSet<>(inputsNames), new HashSet<>(outputNames)); pureInputSet.addAll( evaluator.getInputs().stream().filter(x -> diff.contains(x.getName())).collect(Collectors.toList()) ); batchSize += evaluator.getRollingWindowSize() - 1; } List<? extends Field> actualOutputs; if (!flowEvaluatorManifest.getOutputs().isEmpty()) { actualOutputs = flowEvaluatorManifest.getOutputs(); SetUtils.SetView<Field> difference = SetUtils.difference(new HashSet<>(actualOutputs), outputSet); if (!difference.isEmpty()) { throw new EvaluatorException( String.format( "Desired outputs %s are not actual outputs of the described FlowEvaluator", difference.stream().map(Field::getName).collect(Collectors.joining(",")) ) ); } } else { if (evaluators.isEmpty()) { actualOutputs = new LinkedList<>(); } else { actualOutputs = evaluators.get(evaluators.size() - 1).getOutputs(); } } return new FlowEvaluator(evaluators, new LinkedList<>(pureInputSet), actualOutputs, batchSize); } private  FlowEvaluator(
        List<Evaluator<?>> evaluators,
        List<? extends Field> inputs,
        List<? extends Field> outputs,
        int rollingWindowsSize
    ); static FlowEvaluator create(FlowEvaluatorManifest flowEvaluatorManifest, String path); @Override TensorIO evaluate(TensorIO io, EvaluationContext evaluationContext); @Override List<? extends Field> getInputs(); @Override List<? extends Field> getOutputs(); @Override int getRollingWindowSize();  }