Page MenuHomePhabricator

XGboost fails to load JSON model on macOS when using Docker image built on Linux host
Closed, DeclinedPublic

Description

I'm pretty sure this is the inverse of the issue noted in https://github.com/dmlc/xgboost/issues/5826, where XGBoost behaves differently on macOS when loading a JSON model.

Traceback (most recent call last):
  File "/opt/lib/python/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/opt/lib/python/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/opt/lib/python/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/opt/lib/python/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/opt/lib/python/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/opt/lib/python/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/opt/lib/python/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/opt/lib/python/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/opt/lib/python/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/lib/python/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/srv/app/api.py", line 51, in query
    max_recommendations=data.get("max_recommendations", 20),
  File "/srv/app/src/query.py", line 30, in run
    self.model.load_model(self.datasetloader.get_model_path())
  File "/opt/lib/python/site-packages/xgboost/sklearn.py", line 414, in load_model
    self._Booster.load_model(fname)
  File "/opt/lib/python/site-packages/xgboost/core.py", line 1604, in load_model
    self.handle, c_str(os_fspath(fname))))
  File "/opt/lib/python/site-packages/xgboost/core.py", line 188, in _check_call
    raise XGBoostError(py_str(_LIB.XGBGetLastError()))
xgboost.core.XGBoostError: [09:00:14] ../src/common/json.cc:449: Unknown construct, around character position: 71
    learn": '{"n_est

The issue may have to do with the fact that running the Linux-host built image results in some inconsistencies when that image is then run on a macOS host, but I'm not entirely sure.

As an aside, the JSON produced by xgboost.save_model() doesn't seem to be valid (note the use of single quotes in the stack trace) but it does seem to work with xgboost.load_model() 🤷

Details

Related Changes in Gerrit:

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 665994 had a related patch set uploaded (by Kosta Harlan; owner: Kosta Harlan):
[research/mwaddlink@main] README: Add docker-compose notes

https://gerrit.wikimedia.org/r/665994

Change 665994 merged by jenkins-bot:
[research/mwaddlink@main] README: Add docker-compose notes

https://gerrit.wikimedia.org/r/665994

I'm going to decline this. If someone wants to dig into this more, the best path would be to file a task in the upstream repository (https://github.com/dmlc/xgboost).