catboost 1.25.1 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/DEPLOYMENT.md +22 -15
  2. package/README.md +37 -27
  3. package/binding.gyp +5 -7
  4. package/build_scripts/bootstrap.js +2 -1
  5. package/build_scripts/out/build.js +46 -68
  6. package/build_scripts/out/build_model.js +1 -1
  7. package/build_scripts/out/{build_ya.js → build_native.js} +1 -1
  8. package/build_scripts/out/ci.js +5 -5
  9. package/build_scripts/out/config.js +32 -18
  10. package/build_scripts/out/install.js +5 -3
  11. package/build_scripts/out/package_prepublish.js +1 -1
  12. package/build_scripts/out/packaging.js +1 -19
  13. package/build_scripts/out/run_tests.js +1 -1
  14. package/build_scripts/out/test.js +8 -3
  15. package/config.json +18 -11
  16. package/inc/catboost/libs/model_interface/c_api.h +349 -3
  17. package/lib/catboost.d.ts +65 -21
  18. package/package.json +4 -4
  19. package/src/api_helpers.cpp +100 -24
  20. package/src/api_helpers.h +8 -7
  21. package/src/api_module.cpp +1 -2
  22. package/src/model.cpp +483 -83
  23. package/src/model.h +24 -9
  24. package/inc/contrib/libs/cxxsupp/system_stl/include/stlfwd +0 -14
  25. package/inc/util/charset/recode_result.h +0 -9
  26. package/inc/util/charset/unicode_table.h +0 -123
  27. package/inc/util/charset/unidata.h +0 -421
  28. package/inc/util/charset/utf8.h +0 -384
  29. package/inc/util/charset/wide.h +0 -843
  30. package/inc/util/charset/wide_specific.h +0 -22
  31. package/inc/util/datetime/base.h +0 -669
  32. package/inc/util/datetime/constants.h +0 -7
  33. package/inc/util/datetime/cputimer.h +0 -124
  34. package/inc/util/datetime/parser.h +0 -292
  35. package/inc/util/datetime/systime.h +0 -47
  36. package/inc/util/datetime/uptime.h +0 -8
  37. package/inc/util/digest/city.h +0 -88
  38. package/inc/util/digest/fnv.h +0 -73
  39. package/inc/util/digest/multi.h +0 -14
  40. package/inc/util/digest/murmur.h +0 -57
  41. package/inc/util/digest/numeric.h +0 -86
  42. package/inc/util/digest/sequence.h +0 -48
  43. package/inc/util/draft/date.h +0 -129
  44. package/inc/util/draft/datetime.h +0 -184
  45. package/inc/util/draft/enum.h +0 -136
  46. package/inc/util/draft/holder_vector.h +0 -102
  47. package/inc/util/draft/ip.h +0 -131
  48. package/inc/util/draft/matrix.h +0 -108
  49. package/inc/util/draft/memory.h +0 -40
  50. package/inc/util/folder/dirent_win.h +0 -46
  51. package/inc/util/folder/dirut.h +0 -121
  52. package/inc/util/folder/filelist.h +0 -81
  53. package/inc/util/folder/fts.h +0 -108
  54. package/inc/util/folder/iterator.h +0 -109
  55. package/inc/util/folder/lstat_win.h +0 -20
  56. package/inc/util/folder/path.h +0 -225
  57. package/inc/util/folder/pathsplit.h +0 -113
  58. package/inc/util/folder/tempdir.h +0 -42
  59. package/inc/util/generic/adaptor.h +0 -134
  60. package/inc/util/generic/algorithm.h +0 -765
  61. package/inc/util/generic/array_ref.h +0 -282
  62. package/inc/util/generic/array_size.h +0 -24
  63. package/inc/util/generic/benchmark/vector_count_ctor/f.h +0 -9
  64. package/inc/util/generic/bitmap.h +0 -1115
  65. package/inc/util/generic/bitops.h +0 -459
  66. package/inc/util/generic/bt_exception.h +0 -24
  67. package/inc/util/generic/buffer.h +0 -232
  68. package/inc/util/generic/cast.h +0 -176
  69. package/inc/util/generic/deque.h +0 -24
  70. package/inc/util/generic/explicit_type.h +0 -42
  71. package/inc/util/generic/fastqueue.h +0 -55
  72. package/inc/util/generic/flags.h +0 -244
  73. package/inc/util/generic/function.h +0 -103
  74. package/inc/util/generic/fwd.h +0 -171
  75. package/inc/util/generic/guid.h +0 -61
  76. package/inc/util/generic/hash.h +0 -2032
  77. package/inc/util/generic/hash_primes.h +0 -140
  78. package/inc/util/generic/hash_set.h +0 -490
  79. package/inc/util/generic/hide_ptr.h +0 -3
  80. package/inc/util/generic/intrlist.h +0 -876
  81. package/inc/util/generic/is_in.h +0 -53
  82. package/inc/util/generic/iterator.h +0 -137
  83. package/inc/util/generic/iterator_range.h +0 -105
  84. package/inc/util/generic/lazy_value.h +0 -66
  85. package/inc/util/generic/list.h +0 -22
  86. package/inc/util/generic/map.h +0 -44
  87. package/inc/util/generic/mapfindptr.h +0 -60
  88. package/inc/util/generic/maybe.h +0 -713
  89. package/inc/util/generic/maybe_traits.h +0 -164
  90. package/inc/util/generic/mem_copy.h +0 -55
  91. package/inc/util/generic/noncopyable.h +0 -38
  92. package/inc/util/generic/object_counter.h +0 -53
  93. package/inc/util/generic/ptr.h +0 -1113
  94. package/inc/util/generic/queue.h +0 -57
  95. package/inc/util/generic/refcount.h +0 -162
  96. package/inc/util/generic/reserve.h +0 -11
  97. package/inc/util/generic/scope.h +0 -65
  98. package/inc/util/generic/serialized_enum.h +0 -406
  99. package/inc/util/generic/set.h +0 -42
  100. package/inc/util/generic/singleton.h +0 -136
  101. package/inc/util/generic/size_literals.h +0 -65
  102. package/inc/util/generic/stack.h +0 -18
  103. package/inc/util/generic/store_policy.h +0 -120
  104. package/inc/util/generic/strbase.h +0 -612
  105. package/inc/util/generic/strbuf.h +0 -552
  106. package/inc/util/generic/strfcpy.h +0 -17
  107. package/inc/util/generic/string.h +0 -1572
  108. package/inc/util/generic/string_hash.h +0 -21
  109. package/inc/util/generic/string_ut.h +0 -1175
  110. package/inc/util/generic/type_name.h +0 -34
  111. package/inc/util/generic/typelist.h +0 -114
  112. package/inc/util/generic/typetraits.h +0 -325
  113. package/inc/util/generic/utility.h +0 -132
  114. package/inc/util/generic/va_args.h +0 -400
  115. package/inc/util/generic/variant.h +0 -631
  116. package/inc/util/generic/variant_traits.h +0 -171
  117. package/inc/util/generic/vector.h +0 -119
  118. package/inc/util/generic/xrange.h +0 -258
  119. package/inc/util/generic/yexception.h +0 -212
  120. package/inc/util/generic/yexception_ut.h +0 -14
  121. package/inc/util/generic/ylimits.h +0 -92
  122. package/inc/util/generic/ymath.h +0 -206
  123. package/inc/util/memory/addstorage.h +0 -93
  124. package/inc/util/memory/alloc.h +0 -27
  125. package/inc/util/memory/blob.h +0 -296
  126. package/inc/util/memory/mmapalloc.h +0 -8
  127. package/inc/util/memory/pool.h +0 -432
  128. package/inc/util/memory/segmented_string_pool.h +0 -194
  129. package/inc/util/memory/segpool_alloc.h +0 -118
  130. package/inc/util/memory/smallobj.h +0 -141
  131. package/inc/util/memory/tempbuf.h +0 -111
  132. package/inc/util/network/address.h +0 -136
  133. package/inc/util/network/endpoint.h +0 -61
  134. package/inc/util/network/hostip.h +0 -16
  135. package/inc/util/network/init.h +0 -60
  136. package/inc/util/network/interface.h +0 -17
  137. package/inc/util/network/iovec.h +0 -65
  138. package/inc/util/network/ip.h +0 -116
  139. package/inc/util/network/nonblock.h +0 -8
  140. package/inc/util/network/pair.h +0 -9
  141. package/inc/util/network/poller.h +0 -58
  142. package/inc/util/network/pollerimpl.h +0 -707
  143. package/inc/util/network/sock.h +0 -608
  144. package/inc/util/network/socket.h +0 -421
  145. package/inc/util/random/common_ops.h +0 -130
  146. package/inc/util/random/easy.h +0 -47
  147. package/inc/util/random/entropy.h +0 -21
  148. package/inc/util/random/fast.h +0 -101
  149. package/inc/util/random/init_atfork.h +0 -3
  150. package/inc/util/random/lcg_engine.h +0 -66
  151. package/inc/util/random/mersenne.h +0 -46
  152. package/inc/util/random/mersenne32.h +0 -50
  153. package/inc/util/random/mersenne64.h +0 -50
  154. package/inc/util/random/normal.h +0 -38
  155. package/inc/util/random/random.h +0 -30
  156. package/inc/util/random/shuffle.h +0 -39
  157. package/inc/util/str_stl.h +0 -266
  158. package/inc/util/stream/aligned.h +0 -99
  159. package/inc/util/stream/buffer.h +0 -119
  160. package/inc/util/stream/buffered.h +0 -225
  161. package/inc/util/stream/debug.h +0 -53
  162. package/inc/util/stream/direct_io.h +0 -43
  163. package/inc/util/stream/file.h +0 -108
  164. package/inc/util/stream/format.h +0 -444
  165. package/inc/util/stream/fwd.h +0 -100
  166. package/inc/util/stream/hex.h +0 -8
  167. package/inc/util/stream/holder.h +0 -44
  168. package/inc/util/stream/input.h +0 -273
  169. package/inc/util/stream/labeled.h +0 -19
  170. package/inc/util/stream/length.h +0 -100
  171. package/inc/util/stream/mem.h +0 -255
  172. package/inc/util/stream/multi.h +0 -32
  173. package/inc/util/stream/null.h +0 -61
  174. package/inc/util/stream/output.h +0 -304
  175. package/inc/util/stream/pipe.h +0 -112
  176. package/inc/util/stream/printf.h +0 -25
  177. package/inc/util/stream/str.h +0 -207
  178. package/inc/util/stream/tee.h +0 -28
  179. package/inc/util/stream/tempbuf.h +0 -21
  180. package/inc/util/stream/tokenizer.h +0 -214
  181. package/inc/util/stream/trace.h +0 -60
  182. package/inc/util/stream/walk.h +0 -35
  183. package/inc/util/stream/zerocopy.h +0 -91
  184. package/inc/util/stream/zerocopy_output.h +0 -57
  185. package/inc/util/stream/zlib.h +0 -173
  186. package/inc/util/string/ascii.h +0 -236
  187. package/inc/util/string/builder.h +0 -39
  188. package/inc/util/string/cast.h +0 -347
  189. package/inc/util/string/cstriter.h +0 -14
  190. package/inc/util/string/escape.h +0 -70
  191. package/inc/util/string/hex.h +0 -59
  192. package/inc/util/string/join.h +0 -194
  193. package/inc/util/string/printf.h +0 -13
  194. package/inc/util/string/reverse.h +0 -16
  195. package/inc/util/string/split.h +0 -1080
  196. package/inc/util/string/strip.h +0 -257
  197. package/inc/util/string/strspn.h +0 -65
  198. package/inc/util/string/subst.h +0 -56
  199. package/inc/util/string/type.h +0 -50
  200. package/inc/util/string/util.h +0 -195
  201. package/inc/util/string/vector.h +0 -132
  202. package/inc/util/system/align.h +0 -50
  203. package/inc/util/system/atexit.h +0 -22
  204. package/inc/util/system/atomic.h +0 -51
  205. package/inc/util/system/atomic_gcc.h +0 -90
  206. package/inc/util/system/atomic_ops.h +0 -189
  207. package/inc/util/system/atomic_win.h +0 -114
  208. package/inc/util/system/backtrace.h +0 -39
  209. package/inc/util/system/byteorder.h +0 -186
  210. package/inc/util/system/compat.h +0 -84
  211. package/inc/util/system/compiler.h +0 -620
  212. package/inc/util/system/condvar.h +0 -71
  213. package/inc/util/system/context.h +0 -181
  214. package/inc/util/system/context_aarch64.h +0 -8
  215. package/inc/util/system/context_i686.h +0 -9
  216. package/inc/util/system/context_x86.h +0 -12
  217. package/inc/util/system/context_x86_64.h +0 -7
  218. package/inc/util/system/cpu_id.h +0 -159
  219. package/inc/util/system/daemon.h +0 -28
  220. package/inc/util/system/datetime.h +0 -98
  221. package/inc/util/system/defaults.h +0 -149
  222. package/inc/util/system/demangle.h +0 -5
  223. package/inc/util/system/demangle_impl.h +0 -23
  224. package/inc/util/system/direct_io.h +0 -71
  225. package/inc/util/system/dynlib.h +0 -119
  226. package/inc/util/system/env.h +0 -32
  227. package/inc/util/system/error.h +0 -95
  228. package/inc/util/system/event.h +0 -122
  229. package/inc/util/system/execpath.h +0 -17
  230. package/inc/util/system/fasttime.h +0 -6
  231. package/inc/util/system/fhandle.h +0 -27
  232. package/inc/util/system/file.h +0 -210
  233. package/inc/util/system/file_lock.h +0 -34
  234. package/inc/util/system/filemap.h +0 -383
  235. package/inc/util/system/flock.h +0 -35
  236. package/inc/util/system/fs.h +0 -156
  237. package/inc/util/system/fs_win.h +0 -29
  238. package/inc/util/system/fstat.h +0 -46
  239. package/inc/util/system/getpid.h +0 -12
  240. package/inc/util/system/guard.h +0 -179
  241. package/inc/util/system/hi_lo.h +0 -139
  242. package/inc/util/system/hostname.h +0 -10
  243. package/inc/util/system/hp_timer.h +0 -36
  244. package/inc/util/system/info.h +0 -12
  245. package/inc/util/system/interrupt_signals.h +0 -22
  246. package/inc/util/system/madvise.h +0 -30
  247. package/inc/util/system/maxlen.h +0 -32
  248. package/inc/util/system/mem_info.h +0 -18
  249. package/inc/util/system/mincore.h +0 -38
  250. package/inc/util/system/mktemp.h +0 -11
  251. package/inc/util/system/mlock.h +0 -43
  252. package/inc/util/system/mutex.h +0 -67
  253. package/inc/util/system/nice.h +0 -3
  254. package/inc/util/system/pipe.h +0 -90
  255. package/inc/util/system/platform.h +0 -246
  256. package/inc/util/system/progname.h +0 -13
  257. package/inc/util/system/protect.h +0 -25
  258. package/inc/util/system/rusage.h +0 -26
  259. package/inc/util/system/rwlock.h +0 -78
  260. package/inc/util/system/sanitizers.h +0 -122
  261. package/inc/util/system/sem.h +0 -41
  262. package/inc/util/system/shellcommand.h +0 -472
  263. package/inc/util/system/shmat.h +0 -32
  264. package/inc/util/system/sigset.h +0 -78
  265. package/inc/util/system/spin_wait.h +0 -10
  266. package/inc/util/system/spinlock.h +0 -121
  267. package/inc/util/system/src_location.h +0 -25
  268. package/inc/util/system/src_root.h +0 -68
  269. package/inc/util/system/sys_alloc.h +0 -43
  270. package/inc/util/system/sysstat.h +0 -52
  271. package/inc/util/system/tempfile.h +0 -34
  272. package/inc/util/system/thread.h +0 -167
  273. package/inc/util/system/tls.h +0 -307
  274. package/inc/util/system/types.h +0 -119
  275. package/inc/util/system/unaligned_mem.h +0 -67
  276. package/inc/util/system/user.h +0 -5
  277. package/inc/util/system/utime.h +0 -6
  278. package/inc/util/system/valgrind.h +0 -48
  279. package/inc/util/system/winint.h +0 -43
  280. package/inc/util/system/yassert.h +0 -121
  281. package/inc/util/system/yield.h +0 -4
  282. package/inc/util/thread/factory.h +0 -65
  283. package/inc/util/thread/fwd.h +0 -30
  284. package/inc/util/thread/lfqueue.h +0 -406
  285. package/inc/util/thread/lfstack.h +0 -188
  286. package/inc/util/thread/pool.h +0 -388
  287. package/inc/util/thread/singleton.h +0 -42
  288. package/inc/util/ysafeptr.h +0 -427
  289. package/inc/util/ysaveload.h +0 -700
package/DEPLOYMENT.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Building scripts
4
4
 
5
- Scripts responsible for building and preparing the package for publishing are located in `/build_scripts` directory.
5
+ Scripts responsible for building and preparing the package for publishing are located in `/build_scripts` directory.
6
6
 
7
7
  These scripts are built once on the first execution of any script. To compile build scripts explicitly, run
8
8
  ```
@@ -11,44 +11,46 @@ npm run compile_build_scripts
11
11
 
12
12
  ## Scripts
13
13
 
14
- - `npm run install` - main script for installing the package. Behaves differently if called from catboost directory or from the standalone package distribution:
14
+ - `npm run install` - main script for installing the package. Behaves differently if called from catboost directory or from the standalone package distribution:
15
15
  - If called from `catboost` repository, then builds the local version of `catboostmodel` library from source, compiles and links package against it. After that the package can be added locally via
16
16
  ```
17
17
  npm install $PATH_TO_CATBOOST_REPO/catboost/node-package
18
18
  ```
19
19
  - If called outside of the repository, then the package is considered to be installed from npm and it will be built and linked against the binaries specified in `config.json` file. This file is created during package preparation for publishing, see below.
20
20
  - `npm run build` - build package locally in the `catboost` repository, link against library built from source.
21
- - `npm run ci` - a single scrpt for CI which runs the procedure described in "Release procedure" section.
21
+ - `npm run ci` - \[requires Linux with docker installed\] a single script for CI which runs the procedure described in "Release procedure" section.
22
+ Add `--have-cuda` flag to enable tests with CUDA evaluation.
22
23
  - `npm run compile` - compile Typescript source files only.
23
24
  - `npm run test` - run local unit tests.
25
+ Add `--have-cuda` flag to enable tests with CUDA evaluation.
24
26
  - `npm run compile_build_scripts` - compile build scripts from Typescript sources.
25
27
  - `npm run clean` - delete local artifacts.
26
- - `npm run package_prepublish <version>` - prepare the package for publishing, does the following:
28
+ - `npm run package_prepublish <version>` - prepare the package for publishing, does the following:
27
29
  1. Copies C headers required for building package on the client's side from repository to a `./inc` directory.
28
30
  2. Compiles Typescript source files.
29
- 3. Fetches the binaries from the `github.com` releases for a given version (for ex. `v0.25.1`), prepopulates `config.json` file. This config file includes link to the binaries and sha256 checksums that will be verified on the client side. The binaries have to be downloaded during the package installation as they are too big to be part of the distributed package.
31
+ 3. Fetches the binaries from the `github.com` releases for a given version (for ex. `v0.25.1`), prepopulates `config.json` file. This config file includes link to the binaries and sha256 checksums that will be verified on the client side. The binaries have to be downloaded during the package installation as they are too big to be part of the distributed package.
30
32
 
31
33
  ## Release procedure
32
34
 
33
35
  0. Verify package locally (optional)
34
36
  1. Checkout the released branch.
35
- 2. Run
37
+ 2. Run
38
+ ```
39
+ npm run build -- --have-cuda
36
40
  ```
37
- npm run build
38
- ```
39
41
  to build package from source.
40
- 3. Run
42
+ 3. Run
43
+ ```
44
+ npm run test --have-cuda
41
45
  ```
42
- npm run test
43
- ```
44
46
  to verify that the tests are passing.
45
- 1. Run
47
+ 1. Run
46
48
  ```
47
49
  npm run package_prepublish <version>
48
50
  ```
49
51
  2. Check generated `config.json` file, verify that the links and file checksums are correct.
50
52
  3. Update package version in `package.json`.
51
- 4. Run integration deployment test (local docker required):
53
+ 4. Run integration deployment test \[requires Linux with docker installed\]:
52
54
  ```
53
55
  npm run e2e
54
56
  ```
@@ -59,13 +61,18 @@ npm run compile_build_scripts
59
61
 
60
62
  ## CI
61
63
 
64
+ Requires Linux with Internet access and docker (with permissions to tag images and run containers) installed.
65
+
62
66
  For setting up continuous integration the following had to be done:
63
67
 
64
- 1. Checkout the source code (at the release tag commit) on the host with Internet access and docker daemon running (with permissions to tag images and run containers).
68
+ 1. Checkout the source code (at the release tag commit).
69
+
65
70
  2. From `catboost/catboost/node-package` subdirectory, execute ci script and check that it is executed correctly:
66
71
  ```
67
- npm run ci
72
+ npm run ci -- <catboost-release version> <catboost-node-package version> --have-cuda [build_native arguments]
68
73
  ```
74
+ See [build_native documentation](https://catboost.ai/docs/en/installation/build-native-artifacts#build-build-native) about possible arguments. Don't specify already defined `--target` or `--build-root-dir` arguments.
75
+
69
76
  3. Assuming that npm registry credentials are set up on the host, publish the package via
70
77
  ```
71
78
  npm publish
package/README.md CHANGED
@@ -1,27 +1,47 @@
1
1
  # CatBoost Model Node package
2
2
 
3
- A Node.js package for applying pretrained CatBoost model.
3
+ A Node.js package for applying pretrained CatBoost models.
4
4
 
5
- ## Usage example
5
+ ## Installation
6
6
 
7
- 1. Install the package. You have two options:
7
+ Install the package. You have two options:
8
8
  - Install from npm registry:
9
- ```sh
10
- npm i catboost
11
- ```
12
- - Build package from source. Navigate to this directory inside the repo and run:
9
+ ```sh
10
+ npm i catboost
11
+ ```
12
+ - Build package from source.
13
13
 
14
- ```sh
15
- npm install
16
- ```
14
+ CatBoost source code is stored as a [Git](https://git-scm.com/) repository on GitHub at <https://github.com/catboost/catboost/>. You can obtain a local copy of this Git repository by running the following command from a command line interpreter (you need to have Git command line tools installed):
17
15
 
18
- Now you can link this package in your project via:
16
+ ```sh
17
+ git clone https://github.com/catboost/catboost.git
18
+ ```
19
19
 
20
- ```sh
21
- npm install $PATH_TO_CATBOOST_REPO/catboost/node-package
22
- ```
20
+ Navigate to `$PATH_TO_CATBOOST_REPO/catboost/node-package` directory inside the repo and run:
23
21
 
24
- 1. Apply the pretrained model:
22
+ ```sh
23
+ npm run install [-- <build_native arguments>]
24
+ ```
25
+ See [build_native documentation](https://catboost.ai/docs/en/installation/build-native-artifacts#build-build-native) about possible arguments. Don't specify already defined `--target` or `--build-root-dir` arguments.
26
+
27
+ For example, build with CUDA support:
28
+
29
+ ```sh
30
+ npm run install -- --have-cuda
31
+ ```
32
+
33
+ Now you can link this package in your project via:
34
+
35
+ ```sh
36
+ npm install $PATH_TO_CATBOOST_REPO/catboost/node-package
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ Apply the pretrained model.
42
+
43
+ Example with numerical and categorical features (they must be passed in separate arrays containing features of
44
+ each type for all samples):
25
45
 
26
46
  ```js
27
47
  catboost = require('catboost');
@@ -41,16 +61,6 @@ prediction = model.predict([
41
61
  console.log(prediction);
42
62
  ```
43
63
 
44
- ### Development roadmap
45
-
46
- - [x] Implement basic API calls.
47
- - [ ] Extend exposed API, improve test coverage.
48
- - [X] Migrate away from shell scripts.
49
- - [X] Support Windows and MacOS platforms.
50
- - [X] Switch to downloading and verifying the pre-built binary instead of building it from scratch.
51
- - [X] Publish the alpha version of the package.
52
- - [ ] Publish the generally available version of the package.
53
-
54
- ### Release procedure
64
+ ## Release procedure
55
65
 
56
- See [DEMPLOYMENT.md](./DEPLOYMENT.md).
66
+ See [DEPLOYMENT.md](./DEPLOYMENT.md).
package/binding.gyp CHANGED
@@ -2,28 +2,26 @@
2
2
  'targets': [
3
3
  {
4
4
  'target_name': 'catboost-node',
5
- 'sources': [
5
+ 'sources': [
6
6
  'src/api_helpers.cpp',
7
7
  'src/api_module.cpp',
8
8
  'src/model.cpp',
9
9
  ],
10
10
  'include_dirs': [
11
11
  "<!@(node -p \"require('node-addon-api').include\")",
12
- "<!@(node -p \"process.env['CATBOOST_SRC_PATH'] || '../..'\")",
13
- "<!@(node -p \"process.env['CATBOOST_SRC_PATH'] || '../..'\")/catboost/libs/model_interface",
14
- "<!@(node -p \"process.env['CATBOOST_SRC_PATH'] || '../..'\")/contrib/libs/cxxsupp/system_stl/include",
12
+ "<!@(node -p \"JSON.stringify(path.resolve(process.env['CATBOOST_SRC_PATH'] || path.join('..','..')))\")",
15
13
  ],
16
14
  'dependencies': [ "<!(node -p \"require('node-addon-api').gyp\")" ],
17
15
  'conditions': [
18
16
  ['OS=="linux"', {
19
- 'libraries': [
17
+ 'libraries': [
20
18
  "-L<(module_root_dir)/build/catboost/libs/model_interface/",
21
19
  "-lcatboostmodel",
22
20
  "-Wl,-rpath <(module_root_dir)/build/catboost/libs/model_interface"
23
21
  ],
24
22
  }],
25
23
  ['OS=="mac"', {
26
- 'libraries': [
24
+ 'libraries': [
27
25
  "-L<(module_root_dir)/build/catboost/libs/model_interface/",
28
26
  "-lcatboostmodel",
29
27
  "-Wl,-rpath,@loader_path/../catboost/libs/model_interface"
@@ -57,7 +55,7 @@
57
55
  'xcode_settings': {
58
56
  'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
59
57
  'CLANG_CXX_LIBRARY': 'libc++',
60
- 'MACOSX_DEPLOYMENT_TARGET': '10.7'
58
+ 'MACOSX_DEPLOYMENT_TARGET': '11.0'
61
59
  },
62
60
  'msvs_settings': {
63
61
  'VCCLCompilerTool': { 'ExceptionHandling': 1 },
@@ -1,10 +1,11 @@
1
1
  const childProcess = require('child_process');
2
2
  const fs = require('fs');
3
+ var path = require('path');
3
4
 
4
5
  process.chdir('./build_scripts');
5
6
 
6
7
  function compileBuildScripts() {
7
- const buildRun = childProcess.exec('../node_modules/.bin/tsc');
8
+ const buildRun = childProcess.exec(path.join('..','node_modules', '.bin', 'tsc'));
8
9
  buildRun.stdout.on('data', chunk => {
9
10
  console.log(chunk);
10
11
  });
@@ -36,11 +36,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.buildLocal = exports.buildYa = exports.buildModel = exports.compileBindings = exports.compileJs = void 0;
39
+ exports.buildLocal = exports.buildNative = exports.buildModel = exports.compileBindings = exports.compileJs = void 0;
40
40
  var common_1 = require("./common");
41
41
  var fs_1 = require("fs");
42
42
  var download_1 = require("./download");
43
43
  var config_1 = require("./config");
44
+ var path_1 = require("path");
44
45
  function compileTypeScript() {
45
46
  var _a;
46
47
  return __awaiter(this, void 0, void 0, function () {
@@ -51,7 +52,7 @@ function compileTypeScript() {
51
52
  case 1:
52
53
  result = _b.sent();
53
54
  if (result.code !== 0) {
54
- console.error("Building ts library failed: \n " + result.code + " " + result.signal + " " + ((_a = result.err) === null || _a === void 0 ? void 0 : _a.message));
55
+ console.error("Building ts library failed:\n " + result.code + " " + result.signal + " " + ((_a = result.err) === null || _a === void 0 ? void 0 : _a.message));
55
56
  process.exit(1);
56
57
  }
57
58
  return [2 /*return*/];
@@ -65,7 +66,7 @@ function copyBindings() {
65
66
  }
66
67
  function compileNativeAddon(srcPath) {
67
68
  var _a;
68
- if (srcPath === void 0) { srcPath = '../..'; }
69
+ if (srcPath === void 0) { srcPath = path_1.join('..', '..'); }
69
70
  return __awaiter(this, void 0, void 0, function () {
70
71
  var result;
71
72
  return __generator(this, function (_b) {
@@ -76,7 +77,7 @@ function compileNativeAddon(srcPath) {
76
77
  case 1:
77
78
  result = _b.sent();
78
79
  if (result.code !== 0) {
79
- console.error("Building native-addon library failed: \n " + result.code + " " + result.signal + " " + ((_a = result.err) === null || _a === void 0 ? void 0 : _a.message));
80
+ console.error("Building native-addon library failed:\n " + result.code + " " + result.signal + " " + ((_a = result.err) === null || _a === void 0 ? void 0 : _a.message));
80
81
  process.exit(1);
81
82
  }
82
83
  return [2 /*return*/];
@@ -114,19 +115,27 @@ function compileBindings() {
114
115
  });
115
116
  }
116
117
  exports.compileBindings = compileBindings;
117
- function buildModelInterfaceLibrary() {
118
+ function buildModelInterfaceLibrary(buildNativeExtraArgs) {
118
119
  var _a;
119
120
  return __awaiter(this, void 0, void 0, function () {
120
- var srcPath, result;
121
+ var _i, buildNativeExtraArgs_1, buildNativeArg, srcPath, result;
121
122
  return __generator(this, function (_b) {
122
123
  switch (_b.label) {
123
124
  case 0:
124
- srcPath = process.env['CATBOOST_SRC_PATH'] || '../..';
125
- return [4 /*yield*/, common_1.execProcess(srcPath + "/ya make -r " + srcPath + "/catboost/libs/model_interface -o ./build")];
125
+ for (_i = 0, buildNativeExtraArgs_1 = buildNativeExtraArgs; _i < buildNativeExtraArgs_1.length; _i++) {
126
+ buildNativeArg = buildNativeExtraArgs_1[_i];
127
+ if (buildNativeArg.match(/^\-\-(targets|build\-root\-dir)/)) {
128
+ console.error("build_native extra arguments cannot contain --targets or --build-root-dir, they are predefined");
129
+ process.exit(1);
130
+ }
131
+ }
132
+ srcPath = process.env['CATBOOST_SRC_PATH'] || path_1.join('..', '..');
133
+ return [4 /*yield*/, common_1.execProcess("python3 " + path_1.join(srcPath, 'build', 'build_native.py') + " --targets catboostmodel --build-root-dir ./build "
134
+ + buildNativeExtraArgs.map(function (arg) { return '"' + arg + '"'; }).join(' '))];
126
135
  case 1:
127
136
  result = _b.sent();
128
137
  if (result.code !== 0) {
129
- console.error("Building catboostmodel library failed: \n " + result.code + " " + result.signal + " " + ((_a = result.err) === null || _a === void 0 ? void 0 : _a.message));
138
+ console.error("Building catboostmodel library failed:\n " + result.code + " " + result.signal + " " + ((_a = result.err) === null || _a === void 0 ? void 0 : _a.message));
130
139
  process.exit(1);
131
140
  }
132
141
  return [2 /*return*/];
@@ -136,7 +145,7 @@ function buildModelInterfaceLibrary() {
136
145
  }
137
146
  function configureGyp(srcPath) {
138
147
  var _a;
139
- if (srcPath === void 0) { srcPath = '../..'; }
148
+ if (srcPath === void 0) { srcPath = path_1.join('..', '..'); }
140
149
  return __awaiter(this, void 0, void 0, function () {
141
150
  var result;
142
151
  return __generator(this, function (_b) {
@@ -147,7 +156,7 @@ function configureGyp(srcPath) {
147
156
  case 1:
148
157
  result = _b.sent();
149
158
  if (result.code !== 0) {
150
- console.error("Node-gyp configuration failed: \n " + result.code + " " + result.signal + " " + ((_a = result.err) === null || _a === void 0 ? void 0 : _a.message));
159
+ console.error("Node-gyp configuration failed:\n " + result.code + " " + result.signal + " " + ((_a = result.err) === null || _a === void 0 ? void 0 : _a.message));
151
160
  process.exit(1);
152
161
  }
153
162
  return [2 /*return*/];
@@ -155,14 +164,14 @@ function configureGyp(srcPath) {
155
164
  });
156
165
  });
157
166
  }
158
- function buildModel() {
167
+ function buildModel(buildNativeExtraArgs) {
159
168
  return __awaiter(this, void 0, void 0, function () {
160
169
  return __generator(this, function (_a) {
161
170
  switch (_a.label) {
162
171
  case 0: return [4 /*yield*/, configureGyp()];
163
172
  case 1:
164
173
  _a.sent();
165
- return [4 /*yield*/, buildModelInterfaceLibrary()];
174
+ return [4 /*yield*/, buildModelInterfaceLibrary(buildNativeExtraArgs)];
166
175
  case 2:
167
176
  _a.sent();
168
177
  return [2 /*return*/];
@@ -172,14 +181,14 @@ function buildModel() {
172
181
  }
173
182
  exports.buildModel = buildModel;
174
183
  /** Build binary from repository. */
175
- function buildYa() {
184
+ function buildNative(buildNativeExtraArgs) {
176
185
  return __awaiter(this, void 0, void 0, function () {
177
186
  return __generator(this, function (_a) {
178
187
  switch (_a.label) {
179
188
  case 0: return [4 /*yield*/, configureGyp()];
180
189
  case 1:
181
190
  _a.sent();
182
- return [4 /*yield*/, buildModelInterfaceLibrary()];
191
+ return [4 /*yield*/, buildModelInterfaceLibrary(buildNativeExtraArgs)];
183
192
  case 2:
184
193
  _a.sent();
185
194
  return [4 /*yield*/, compileBindings()];
@@ -190,75 +199,44 @@ function buildYa() {
190
199
  });
191
200
  });
192
201
  }
193
- exports.buildYa = buildYa;
194
- function preparePlatformBinary(platform) {
202
+ exports.buildNative = buildNative;
203
+ function preparePlatformBinary(platform, arch) {
195
204
  return __awaiter(this, void 0, void 0, function () {
196
- var config, _a, _i, _b, binary, _c, _d, binary, _e, _f, binary;
197
- return __generator(this, function (_g) {
198
- switch (_g.label) {
205
+ var config, platform_arch, _i, _a, binary;
206
+ return __generator(this, function (_b) {
207
+ switch (_b.label) {
199
208
  case 0:
200
209
  config = config_1.readConfig();
201
- _a = platform;
202
- switch (_a) {
203
- case 'linux': return [3 /*break*/, 1];
204
- case 'darwin': return [3 /*break*/, 6];
205
- case 'win32': return [3 /*break*/, 11];
210
+ if (platform == 'darwin') {
211
+ arch = 'universal2';
206
212
  }
207
- return [3 /*break*/, 16];
213
+ platform_arch = platform + '-' + arch;
214
+ _i = 0, _a = config.binaries[platform_arch];
215
+ _b.label = 1;
208
216
  case 1:
209
- _i = 0, _b = config.binaries['linux'];
210
- _g.label = 2;
211
- case 2:
212
- if (!(_i < _b.length)) return [3 /*break*/, 5];
213
- binary = _b[_i];
217
+ if (!(_i < _a.length)) return [3 /*break*/, 4];
218
+ binary = _a[_i];
214
219
  return [4 /*yield*/, download_1.downloadBinaryFile('./build/catboost/libs/model_interface', binary)];
220
+ case 2:
221
+ _b.sent();
222
+ _b.label = 3;
215
223
  case 3:
216
- _g.sent();
217
- _g.label = 4;
218
- case 4:
219
224
  _i++;
220
- return [3 /*break*/, 2];
221
- case 5:
222
- fs_1.linkSync('./build/catboost/libs/model_interface/libcatboostmodel.so', './build/catboost/libs/model_interface/libcatboostmodel.so.1');
225
+ return [3 /*break*/, 1];
226
+ case 4:
227
+ if (platform == 'linux') {
228
+ fs_1.linkSync('./build/catboost/libs/model_interface/libcatboostmodel.so', './build/catboost/libs/model_interface/libcatboostmodel.so.1');
229
+ }
223
230
  return [2 /*return*/];
224
- case 6:
225
- _c = 0, _d = config.binaries['mac'];
226
- _g.label = 7;
227
- case 7:
228
- if (!(_c < _d.length)) return [3 /*break*/, 10];
229
- binary = _d[_c];
230
- return [4 /*yield*/, download_1.downloadBinaryFile('./build/catboost/libs/model_interface', binary)];
231
- case 8:
232
- _g.sent();
233
- _g.label = 9;
234
- case 9:
235
- _c++;
236
- return [3 /*break*/, 7];
237
- case 10: return [2 /*return*/];
238
- case 11:
239
- _e = 0, _f = config.binaries['win'];
240
- _g.label = 12;
241
- case 12:
242
- if (!(_e < _f.length)) return [3 /*break*/, 15];
243
- binary = _f[_e];
244
- return [4 /*yield*/, download_1.downloadBinaryFile('./build/catboost/libs/model_interface', binary)];
245
- case 13:
246
- _g.sent();
247
- _g.label = 14;
248
- case 14:
249
- _e++;
250
- return [3 /*break*/, 12];
251
- case 15: return [2 /*return*/];
252
- case 16: throw new Error("Platform " + platform + " is not supported");
253
231
  }
254
232
  });
255
233
  });
256
234
  }
257
- function buildLocal(platform) {
235
+ function buildLocal(platform, arch) {
258
236
  return __awaiter(this, void 0, void 0, function () {
259
237
  return __generator(this, function (_a) {
260
238
  switch (_a.label) {
261
- case 0: return [4 /*yield*/, preparePlatformBinary(platform)];
239
+ case 0: return [4 /*yield*/, preparePlatformBinary(platform, arch)];
262
240
  case 1:
263
241
  _a.sent();
264
242
  return [4 /*yield*/, configureGyp('./inc')];
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var build_1 = require("./build");
4
- build_1.buildModel();
4
+ build_1.buildModel(process.argv.slice(5));
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var build_1 = require("./build");
4
- build_1.buildYa();
4
+ build_1.buildNative(process.argv.slice(5));
@@ -46,11 +46,11 @@ function ci() {
46
46
  return __generator(this, function (_a) {
47
47
  switch (_a.label) {
48
48
  case 0:
49
- if (process.argv.length !== 7) {
50
- throw new Error('ci script --- Usage: npm run ci <catboost-release version> <catboost-node-package version>');
49
+ if (process.argv.length < 7) {
50
+ throw new Error('ci script --- Usage: npm run ci -- <catboost-release version> <catboost-node-package version> [--have-cuda] [build_native arguments]');
51
51
  }
52
52
  catboostVersion = process.argv[5];
53
- if (!/v[0-9\.]*/.exec(catboostVersion)) {
53
+ if (!/[0-9\.]*/.exec(catboostVersion)) {
54
54
  throw new Error("Version '" + catboostVersion + "' is not a valid catboost version.");
55
55
  }
56
56
  packageVersion = process.argv[6];
@@ -60,11 +60,11 @@ function ci() {
60
60
  console.log("Patching \"package.json\" with version \"" + packageVersion + "\"...");
61
61
  packaging_1.patchPackageJSONWithVersion(packageVersion);
62
62
  console.log('Building catboost package against repository sources...');
63
- return [4 /*yield*/, build_1.buildYa()];
63
+ return [4 /*yield*/, build_1.buildNative(process.argv.slice(7))];
64
64
  case 1:
65
65
  _a.sent();
66
66
  console.log('Running local unit tests...');
67
- return [4 /*yield*/, test_1.test()];
67
+ return [4 /*yield*/, test_1.test(process.argv.indexOf('--have-cuda') > -1)];
68
68
  case 2:
69
69
  _a.sent();
70
70
  console.log('Preparing package...');
@@ -41,11 +41,23 @@ var fs_1 = require("fs");
41
41
  var path_1 = require("path");
42
42
  var download_1 = require("./download");
43
43
  var GITHUB_PATH = 'https://github.com/catboost/catboost/releases/download/';
44
- var PLATFORM_TO_BINARY = {
45
- 'linux': ['libcatboostmodel.so'],
46
- 'mac': ['libcatboostmodel.dylib'],
47
- 'win': ['catboostmodel.dll', 'catboostmodel.lib'],
48
- };
44
+ function getPlatformArchToBinary(version) {
45
+ return {
46
+ 'linux-x64': [
47
+ ["libcatboostmodel-linux-x86_64-" + version + ".so", 'libcatboostmodel.so']
48
+ ],
49
+ 'linux-arm64': [
50
+ ["libcatboostmodel-linux-aarch64-" + version + ".so", 'libcatboostmodel.so']
51
+ ],
52
+ 'darwin-universal2': [
53
+ ["libcatboostmodel-darwin-universal2-" + version + ".dylib", 'libcatboostmodel.dylib']
54
+ ],
55
+ 'win32-x64': [
56
+ ["catboostmodel-windows-x86_64-" + version + ".dll", 'catboostmodel.dll'],
57
+ ["catboostmodel-windows-x86_64-" + version + ".lib", 'catboostmodel.lib']
58
+ ],
59
+ };
60
+ }
49
61
  function parseBinaryFileData(mapEntry) {
50
62
  if (mapEntry['url'] === undefined || mapEntry['sha256'] === undefined || mapEntry['targetFile'] === undefined) {
51
63
  throw new Error("Not a correct binary file entry in the config: " + JSON.stringify(mapEntry));
@@ -77,7 +89,7 @@ function writeConfig(config) {
77
89
  exports.writeConfig = writeConfig;
78
90
  function createConfigForVersion(version) {
79
91
  return __awaiter(this, void 0, void 0, function () {
80
- var config, failedToDownload, _i, _a, platform, _b, _c, binary, targetFile, url, tmpPath, error_1, sha256, error;
92
+ var config, failedToDownload, platform_arch_to_binaries, _i, _a, platform_arch, _b, _c, src_and_target_file, srcFile, targetFile, url, tmpPath, error_1, sha256, error;
81
93
  return __generator(this, function (_d) {
82
94
  switch (_d.label) {
83
95
  case 0:
@@ -85,20 +97,22 @@ function createConfigForVersion(version) {
85
97
  binaries: {},
86
98
  };
87
99
  failedToDownload = [];
88
- _i = 0, _a = Object.keys(PLATFORM_TO_BINARY);
100
+ platform_arch_to_binaries = getPlatformArchToBinary(version);
101
+ _i = 0, _a = Object.keys(platform_arch_to_binaries);
89
102
  _d.label = 1;
90
103
  case 1:
91
104
  if (!(_i < _a.length)) return [3 /*break*/, 9];
92
- platform = _a[_i];
93
- config.binaries[platform] = [];
94
- _b = 0, _c = PLATFORM_TO_BINARY[platform];
105
+ platform_arch = _a[_i];
106
+ config.binaries[platform_arch] = [];
107
+ _b = 0, _c = platform_arch_to_binaries[platform_arch];
95
108
  _d.label = 2;
96
109
  case 2:
97
110
  if (!(_b < _c.length)) return [3 /*break*/, 8];
98
- binary = _c[_b];
99
- targetFile = binary;
100
- url = path_1.join(GITHUB_PATH, version, targetFile);
101
- tmpPath = path_1.join('./build/tmp/', targetFile);
111
+ src_and_target_file = _c[_b];
112
+ srcFile = src_and_target_file[0];
113
+ targetFile = src_and_target_file[1];
114
+ url = path_1.join(GITHUB_PATH, 'v' + version, srcFile);
115
+ tmpPath = path_1.join('./build/tmp/', srcFile);
102
116
  _d.label = 3;
103
117
  case 3:
104
118
  _d.trys.push([3, 5, , 6]);
@@ -108,16 +122,16 @@ function createConfigForVersion(version) {
108
122
  return [3 /*break*/, 6];
109
123
  case 5:
110
124
  error_1 = _d.sent();
111
- failedToDownload.push(targetFile);
112
- config.binaries[platform].push({
113
- url: "Not found: " + targetFile,
125
+ failedToDownload.push(srcFile);
126
+ config.binaries[platform_arch].push({
127
+ url: "Not found: " + srcFile,
114
128
  sha256: '',
115
129
  targetFile: targetFile,
116
130
  });
117
131
  return [3 /*break*/, 7];
118
132
  case 6:
119
133
  sha256 = download_1.calculateFileHash(tmpPath);
120
- config.binaries[platform].push({ url: url, sha256: sha256, targetFile: targetFile });
134
+ config.binaries[platform_arch].push({ url: url, sha256: sha256, targetFile: targetFile });
121
135
  _d.label = 7;
122
136
  case 7:
123
137
  _b++;
@@ -40,15 +40,17 @@ var build_1 = require("./build");
40
40
  var fs_1 = require("fs");
41
41
  function install() {
42
42
  return __awaiter(this, void 0, void 0, function () {
43
+ var buildNativeExtraArgs;
43
44
  return __generator(this, function (_a) {
44
45
  switch (_a.label) {
45
46
  case 0:
46
- if (!fs_1.existsSync('../../ya')) return [3 /*break*/, 2];
47
- return [4 /*yield*/, build_1.buildYa()];
47
+ if (!fs_1.existsSync('../../build/build_native.py')) return [3 /*break*/, 2];
48
+ buildNativeExtraArgs = process.argv.slice(5);
49
+ return [4 /*yield*/, build_1.buildNative(buildNativeExtraArgs)];
48
50
  case 1:
49
51
  _a.sent();
50
52
  return [2 /*return*/];
51
- case 2: return [4 /*yield*/, build_1.buildLocal(process.platform)];
53
+ case 2: return [4 /*yield*/, build_1.buildLocal(process.platform, process.arch)];
52
54
  case 3:
53
55
  _a.sent();
54
56
  return [2 /*return*/];
@@ -45,7 +45,7 @@ function prepareAndBuildPackage() {
45
45
  switch (_a.label) {
46
46
  case 0:
47
47
  version = process.argv[process.argv.length - 1];
48
- if (!/v[0-9\.]*/.exec(version)) {
48
+ if (!/[0-9\.]*/.exec(version)) {
49
49
  console.error("Version \"" + version + "\" is not valid. Please add version as the last argument");
50
50
  process.exit(1);
51
51
  }