Python's h2o.download_pojo with get_jar=True and path leading to nonexistent, creatable location fails

Description

The following code raises error (iris: https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data; ... to shorten file paths):

>>> import h2o
>>> from h2o.estimators import H2OAutoEncoderEstimator as H2OAutoEncoder

>>> h2o.init()
>>> f = h2o.load_dataset('iris.data')
>>> m = H2OAutoEncoder(seed=42, reproducible=True)
>>> m.train(training_frame=f)
>>> name = h2o.download_pojo(model=m, path='test_ae_pojo', get_jar=True)
Traceback (most recent call last):
File ".../h2o/backend/connection.py", line 716, in _process_response
with open(fullname, "wb") as f:
NotADirectoryError: [Errno 20] Not a directory: 'test_ae_pojo/h2o-genmodel.jar'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "../h2o.py", line 1010, in download_pojo
api("GET /3/h2o-genmodel.jar", save_to=os.path.join(path, "h2o-genmodel.jar"))
File ".../h2o.py", line 104, in api
return h2oconn.request(endpoint, data=data, json=json, filename=filename, save_to=save_to)
File ".../backend/connection.py", line 407, in request
return self._process_response(resp, save_to)
File ".../backend/connection.py", line 721, in _process_response
raise H2OValueError("Cannot write to file %s: %s" % (fullname, e))
h2o.exceptions.H2OValueError: Cannot write to file test_ae_pojo/h2o-genmodel.jar: [Errno 20] Not a directory: 'test_ae_pojo/h2o-genmodel.jar'

Contrary to download_mojo that in case of obtaining jar correctly handles API request, here from what I can see download_pojo firstly downloads POJO, thus making the path a POJO file and the following jar downloading thus fails, because it expects the path to be a folder.

Assignee

Pavel Pscheidl

Fix versions

Reporter

Tom Kremel

Support ticket URL

None

Labels

Affected Spark version

None

Customer Request Type

None

Task progress

None

CustomerVisible

No

Components

Affects versions

Priority

Minor
Configure