Skip to content

Commit c8c17f9

Browse files
Removed lxml
1 parent 5160671 commit c8c17f9

File tree

3 files changed

+3
-18
lines changed

3 files changed

+3
-18
lines changed

src/sasctl/utils/pyml2ds/connectors/ensembles/pmml.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
try:
2-
from lxml import objectify
3-
except ImportError:
4-
objectify = None
5-
6-
from sasctl.utils.pyml2ds.basic.tree import TreeParser
1+
from pyml2ds.basic.tree import TreeParser
72
from .core import EnsembleParser
83

94

@@ -69,9 +64,6 @@ def __init__(self, tree_root):
6964
i = elem.tag.find('}')
7065
if i >= 0:
7166
elem.tag = elem.tag[i+1:]
72-
if objectify is None:
73-
raise RuntimeError("Lxml is not installed. Lxml is needed to parse xml files.")
74-
objectify.deannotate(tree_root, cleanup_namespaces=True)
7567

7668
self._forest = tree_root.find('MiningModel/Segmentation')[0].find('MiningModel')
7769

src/sasctl/utils/pyml2ds/pyml2ds.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import sys
2-
3-
try:
4-
from lxml import etree
5-
except ImportError:
6-
etree = None
2+
import xml.etree.ElementTree as etree
73

84
try:
95
import pickle
@@ -36,7 +32,7 @@ def _check_type(model):
3632
parser = LightgbmParser(model.booster_)
3733
elif lightgbm and isinstance(model, lightgbm.basic.Booster):
3834
parser = LightgbmParser(model)
39-
elif etree and isinstance(model, etree._ElementTree):
35+
elif etree and isinstance(model, etree.ElementTree):
4036
parser = PmmlParser(model.getroot())
4137
else:
4238
raise RuntimeError("Unknown booster type: %s. Compatible types are: %s. Check if corresponding library is installed." % type(model).__name__)
@@ -60,8 +56,6 @@ def pyml2ds(inFile, outFile, outVarName="P_TARGET", test=False):
6056
# Load model file
6157
ext = ".pmml"
6258
if inFile[-len(ext):] == ext:
63-
if etree is None:
64-
raise RuntimeError("Found pmml file but lxml is not installed. Lxml is needed to parse xml files.")
6559
model = etree.parse(inFile)
6660
else:
6761
with open(inFile, 'rb') as mf:

tox.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ deps =
5656
tests: kerberos ; platform_system != "Windows"
5757
tests: xgboost
5858
tests: lightgbm
59-
tests: lxml
6059
codecov: codecov >= 1.4.0
6160
doc: sphinx == 1.8
6261

0 commit comments

Comments
 (0)