Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import sys
from setuptools import setup, find_packages
if sys.version_info < (2, 7):
print("Python versions prior to 2.7 are not supported for pip installed MLeap.",
file=sys.stderr)
exit(-1)
try:
exec(open('mleap/version.py').read())
except IOError:
print("Failed to load MLeap version file for packaging. You must be in MLeap's python directory.",
file=sys.stderr)
sys.exit(-1)
VERSION = __version__
numpy_version = "1.8.2"
REQUIRED_PACKAGES = [
'numpy >= %s' % numpy_version,
'six >= 1.10.0',
'scipy>=0.13.0b1',
'pandas>=0.18.1',
'scikit-learn>=0.18.dev0',
'nose-exclude>=0.5.0'
]
setup(name='mleap',
version=VERSION,
description='MLeap Python API',
author='MLeap Developers',
def get_bundle(transformer):
js = {
"name": transformer.name,
"format": "json",
"version": __version__,
"timestamp": datetime.datetime.now().isoformat(),
"uid": "{}".format(uuid.uuid4())
}
return js
path=mleap_path_full))
os.makedirs(mleap_path_full)
dataset = spark_model.transform(sample_input)
model_path = "file:{mp}".format(mp=mleap_datapath_full)
try:
spark_model.serializeToBundle(path=model_path,
dataset=dataset)
except Py4JError:
_handle_py4j_error(
MLeapSerializationException,
"MLeap encountered an error while serializing the model. Ensure that the model is"
" compatible with MLeap (i.e does not contain any custom transformers).")
mlflow_model.add_flavor(FLAVOR_NAME,
mleap_version=mleap.version.__version__,
model_data=mleap_datapath_sub)