numenta / htm.java

Hierarchical Temporal Memory implementation in Java - an official Community-Driven Java port of the Numenta Platform for Intelligent Computing (NuPIC).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JavaFX dependency complicates deployment

skidder opened this issue · comments

The JavaFX javafx.util.Pair is used by 3 classes in the production htm.java codebase (src/main/java). JavaFX isn't a problem on bare-metal hardware or virtual machines, but Docker deployments are more challenging. JavaFX requires a window manager that isn't available on container architectures. Most Docker base images with the JDK or JRE do not provide JavaFX at runtime, resulting in an exception like the following:

java.lang.NoClassDefFoundError: javafx/util/Pair
    at org.numenta.nupic.algorithms.TemporalMemory.compute(TemporalMemory.java:145)
    at org.numenta.nupic.network.Layer.temporalInput(Layer.java:1942)
    at org.numenta.nupic.network.Layer$FunctionFactory$2.call(Layer.java:2285)
    at org.numenta.nupic.network.Layer$FunctionFactory$2.call(Layer.java:2274)
    at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
    at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
    at rx.internal.operators.OperatorFilter$1.onNext(OperatorFilter.java:54)
    at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
    at rx.internal.operators.OperatorCast$1.onNext(OperatorCast.java:50)
    at rx.internal.operators.OperatorFilter$1.onNext(OperatorFilter.java:54)
    at rx.subjects.SubjectSubscriptionManager$SubjectObserver.onNext(SubjectSubscriptionManager.java:224)
    at rx.subjects.PublishSubject.onNext(PublishSubject.java:114)
    at org.numenta.nupic.network.Layer.compute(Layer.java:937)
    at org.numenta.nupic.network.Region.compute(Region.java:250)
    at org.numenta.nupic.network.Network.computeImmediate(Network.java:630)
    at org.numenta.nupic.flink.streaming.api.operator.AbstractHTMInferenceOperator.processInput(AbstractHTMInferenceOperator.java:122)
    at org.numenta.nupic.flink.streaming.api.operator.AbstractHTMInferenceOperator.processElement(AbstractHTMInferenceOperator.java:102)
    at org.numenta.nupic.flink.streaming.api.operator.KeyedHTMInferenceOperator.processElement(KeyedHTMInferenceOperator.java:95)
    at org.apache.flink.streaming.runtime.io.StreamInputProcessor.processInput(StreamInputProcessor.java:176)
    at org.apache.flink.streaming.runtime.tasks.OneInputStreamTask.run(OneInputStreamTask.java:66)
    at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:266)

This seems overkill just to support a Pair class that could be provided numerous other ways. Can you provide a custom Pair implementation, or use a Pair implementation from an existing library dependency (e.g. chaschev.lang.Pair)?

@skidder Yes, I am intending to change this (right now in my current PR actually) because I suspected weird handling of the bundled JavaFX (later on).

Feel free to add a Pair class to org.numenta.nupic.utils with a getFirst() / getLast() method or equivalent names of your choosing? ...and submit a PR and I will just use yours?