From ced6d45e015a92ff736b98336ae266c8c42badb9 Mon Sep 17 00:00:00 2001 From: tqchen Date: Tue, 1 Mar 2016 21:02:35 -0800 Subject: [PATCH] Update rabit --- .gitignore | 5 +++-- Makefile | 7 ++++++- python-package/xgboost/rabit.py | 11 +++++++++-- rabit | 2 +- tests/distributed/test_basic.py | 3 +++ 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 4e8c0610b..ae196175c 100644 --- a/.gitignore +++ b/.gitignore @@ -20,8 +20,9 @@ *buffer *model *pyc -*train -*test +*.train +*.test +*.tar *group *rar *vali diff --git a/Makefile b/Makefile index e8bc5f9b8..f85d44443 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ endif # specify tensor path -.PHONY: clean all lint clean_all doxygen rcpplint Rpack Rbuild Rcheck java +.PHONY: clean all lint clean_all doxygen rcpplint pypack Rpack Rbuild Rcheck java all: lib/libxgboost.a $(XGBOOST_DYLIB) xgboost @@ -143,6 +143,11 @@ clean_all: clean doxygen: doxygen doc/Doxyfile +# create standalone python tar file. +pypack: ${XGBOOST_DYLIB} + cp ${XGBOOST_DYLIB} python-package/xgboost + cd python-package; tar cf xgboost.tar xgboost; cd .. + # Script to make a clean installable R package. Rpack: make clean_all diff --git a/python-package/xgboost/rabit.py b/python-package/xgboost/rabit.py index da4cfa675..0ea7736e5 100644 --- a/python-package/xgboost/rabit.py +++ b/python-package/xgboost/rabit.py @@ -8,11 +8,18 @@ import numpy as np from .core import _LIB, c_str, STRING_TYPES def _init_rabit(): - """Initialize the rabit library.""" + """internal libary initializer.""" _LIB.RabitGetRank.restype = ctypes.c_int _LIB.RabitGetWorldSize.restype = ctypes.c_int _LIB.RabitVersionNumber.restype = ctypes.c_int - _LIB.RabitInit(0, None) + +def init(args=None): + """Initialize the rabit libary with arguments""" + if args is None: + args = [] + arr = (ctypes.c_char_p * len(args))() + arr[:] = args + _LIB.RabitInit(len(arr), arr) def finalize(): diff --git a/rabit b/rabit index 1392e9f3d..be50e7b63 160000 --- a/rabit +++ b/rabit @@ -1 +1 @@ -Subproject commit 1392e9f3da59bd5602ddebee944dd8fb5c6507b0 +Subproject commit be50e7b63224b9fb7ff94ce34df9f8752ef83043 diff --git a/tests/distributed/test_basic.py b/tests/distributed/test_basic.py index 20504fd13..aacad0d8e 100644 --- a/tests/distributed/test_basic.py +++ b/tests/distributed/test_basic.py @@ -4,6 +4,9 @@ import scipy.sparse import pickle import xgboost as xgb +# always call this before using distributed module +xgb.rabit.init() + # Load file, file will be automatically sharded in distributed mode. dtrain = xgb.DMatrix('../../demo/data/agaricus.txt.train') dtest = xgb.DMatrix('../../demo/data/agaricus.txt.test')