Problem
You try to import PMML
files using PyPMML. The following code shows an example command.
%python
from pypmml import Model
modelb = Model.fromFile('/dbfs/username/DecisionTreeIris.pmml')
You then receive the following error.
ValueError: invalid literal for int() with base 10: b'[Global flags]\n'.
Cause
PyPMML is designed to retrieve and return the port number on which the Py4J gateway is running when it initiates the gateway.
However, included in the Java options there is a -XX:+PrintFlagsFinal
flag which modifies the gateway's output. This flag produces a list of all global Java flags instead of just the port number. This extended output is incorrectly passed to the int()
function, which expects a numerical value. As a result the int()
function returns a parsing error.
Solution
Remove the flag from the Java options before calling the PyPMML method to remove the excess global list from the output. Execute the following code in a notebook.
tmpval= os.environ.get("JAVA_OPTS")
tmpval=privtmpval.replace('-XX:+PrintFlagsFinal', '')
os.environ["JAVA_OPTS"] = tmpval