@openmle/omle.js 0.1.0-rc4 → 0.1.0-rc5
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.
- package/README.md +6 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/proto.d.ts +11 -0
- package/dist/proto.d.ts.map +1 -0
- package/dist/proto.js +38 -0
- package/dist/proto.js.map +1 -0
- package/dist/proto_descriptor.d.ts +4 -0
- package/dist/proto_descriptor.d.ts.map +1 -0
- package/dist/proto_descriptor.js +2377 -0
- package/dist/proto_descriptor.js.map +1 -0
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# omle.js
|
|
2
2
|
|
|
3
|
-
TypeScript library for loading, parsing, validating, and executing [OMLE](https://github.com/openmle) models. Works in Node.js and the browser.
|
|
3
|
+
TypeScript library for loading, parsing, validating, and executing [OMLE](https://github.com/openmle) models. Works in Node.js and the browser. One runtime dependency (`protobufjs`, for binary `.omle` decoding).
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- **Full IR** — TypeScript types for every message in `omle.proto`, following the Python SDK's JSON conventions (enums as strings, flat typed-data arrays, base64 bytes).
|
|
8
|
-
- **I/O** — `fromJSON` / `toJSON`, Node.js `loadFile` / `saveFile`, browser `loadBlob`.
|
|
8
|
+
- **I/O** — `fromJSON` / `toJSON`, `fromProtoBinary` for binary `.omle` files, Node.js `loadFile` / `saveFile`, browser `loadBlob`.
|
|
9
9
|
- **Resolution** — builds a tensor-entry index, topologically sorts the DAG, and expands `NameRange` patterns.
|
|
10
10
|
- **Validation** — structural and semantic checks with per-path error and warning messages.
|
|
11
11
|
- **Reference engine** — executes models in topological order with full composite-node scoping. Supports all structured bodies: decision tree, tree ensemble, linear, neural network (dense layers), naïve Bayes (Gaussian / Multinomial / Bernoulli / Categorical), prototype clustering, GMM, and linear and kernel SVM.
|
|
@@ -48,6 +48,10 @@ console.log(outputs);
|
|
|
48
48
|
fromJSON(json: string | object): OMLEModel
|
|
49
49
|
toJSON(model: OMLEModel, pretty?: boolean): string
|
|
50
50
|
|
|
51
|
+
// Binary .omle files (protobuf wire format). The schema is embedded, so
|
|
52
|
+
// nothing is fetched or compiled at build time.
|
|
53
|
+
fromProtoBinary(data: ArrayBuffer | Uint8Array): OMLEModel
|
|
54
|
+
|
|
51
55
|
// Node.js only
|
|
52
56
|
loadFile(path: string): Promise<OMLEModel>
|
|
53
57
|
saveFile(model: OMLEModel, path: string, pretty?: boolean): Promise<void>
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,YAAY,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACrF,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/K,YAAY,EACV,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,YAAY,EAChE,aAAa,EAAE,kBAAkB,EACjC,iBAAiB,EAAE,wBAAwB,EAC3C,iBAAiB,EAAE,gBAAgB,GACpC,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,YAAY,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACrF,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/K,YAAY,EACV,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,YAAY,EAChE,aAAa,EAAE,kBAAkB,EACjC,iBAAiB,EAAE,wBAAwB,EAC3C,iBAAiB,EAAE,gBAAgB,GACpC,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// const outputs = engine.run({ X: { dtype: 'FLOAT64', shape: [1, 4], data: new Float64Array([...]) } });
|
|
9
9
|
export * from './ir.js';
|
|
10
10
|
export * from './io.js';
|
|
11
|
+
export { fromProtoBinary } from './proto.js';
|
|
11
12
|
export * from './resolve.js';
|
|
12
13
|
export * from './validate.js';
|
|
13
14
|
export { Engine } from './engine/executor.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,EAAE;AACF,SAAS;AACT,mEAAmE;AACnE,wCAAwC;AACxC,oCAAoC;AACpC,sCAAsC;AACtC,2GAA2G;AAE3G,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAU7D,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,EAAE;AACF,SAAS;AACT,mEAAmE;AACnE,wCAAwC;AACxC,oCAAoC;AACpC,sCAAsC;AACtC,2GAA2G;AAE3G,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAU7D,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/proto.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OMLEModel } from './ir.js';
|
|
2
|
+
/**
|
|
3
|
+
* Decode a binary `.omle` file into an OMLEModel.
|
|
4
|
+
*
|
|
5
|
+
* Returns a model identical to what `fromJSON` produces for the same model, so
|
|
6
|
+
* callers can treat the two encodings interchangeably. The proto encoding wraps
|
|
7
|
+
* repeated typed arrays in list messages (Float32List and friends); fromJSON
|
|
8
|
+
* already unwraps those, so decoding hands its output straight to it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function fromProtoBinary(data: ArrayBuffer | Uint8Array): OMLEModel;
|
|
11
|
+
//# sourceMappingURL=proto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proto.d.ts","sourceRoot":"","sources":["../src/proto.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAWzC;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,CAWzE"}
|
package/dist/proto.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Binary .omle loader — decodes the protobuf wire format.
|
|
2
|
+
//
|
|
3
|
+
// Wire format is not self-describing: the bytes carry field numbers, not names
|
|
4
|
+
// or types, so decoding needs the schema. It is embedded as a protobufjs JSON
|
|
5
|
+
// descriptor (src/proto_descriptor.ts, generated from omle.proto) rather than
|
|
6
|
+
// the .proto text, which is ~4x larger and would also drag in the .proto
|
|
7
|
+
// grammar parser. protobufjs/light provides reflection without that parser.
|
|
8
|
+
import protobufLight from 'protobufjs/light.js';
|
|
9
|
+
import { protoDescriptor } from './proto_descriptor.js';
|
|
10
|
+
import { fromJSON } from './io.js';
|
|
11
|
+
let _root = null;
|
|
12
|
+
function getRoot() {
|
|
13
|
+
if (!_root) {
|
|
14
|
+
_root = protobufLight.Root.fromJSON(protoDescriptor);
|
|
15
|
+
}
|
|
16
|
+
return _root;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Decode a binary `.omle` file into an OMLEModel.
|
|
20
|
+
*
|
|
21
|
+
* Returns a model identical to what `fromJSON` produces for the same model, so
|
|
22
|
+
* callers can treat the two encodings interchangeably. The proto encoding wraps
|
|
23
|
+
* repeated typed arrays in list messages (Float32List and friends); fromJSON
|
|
24
|
+
* already unwraps those, so decoding hands its output straight to it.
|
|
25
|
+
*/
|
|
26
|
+
export function fromProtoBinary(data) {
|
|
27
|
+
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
28
|
+
const ModelType = getRoot().lookupType('omle.OMLEModel');
|
|
29
|
+
const decoded = ModelType.decode(bytes);
|
|
30
|
+
const obj = ModelType.toObject(decoded, {
|
|
31
|
+
longs: Number,
|
|
32
|
+
enums: String,
|
|
33
|
+
bytes: String, // base64 — matches the JSON convention
|
|
34
|
+
defaults: false,
|
|
35
|
+
});
|
|
36
|
+
return fromJSON(obj);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=proto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proto.js","sourceRoot":"","sources":["../src/proto.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,8EAA8E;AAC9E,yEAAyE;AACzE,4EAA4E;AAE5E,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGnC,IAAI,KAAK,GAAgB,IAAI,CAAC;AAE9B,SAAS,OAAO;IACd,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,IAA8B;IAC5D,MAAM,KAAK,GAAG,IAAI,YAAY,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IACvE,MAAM,SAAS,GAAG,OAAO,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;IACzD,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE;QACtC,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM,EAAI,uCAAuC;QACxD,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proto_descriptor.d.ts","sourceRoot":"","sources":["../src/proto_descriptor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,eAAO,MAAM,eAAe,EAi0EZ,UAAU,CAAC;AAE3B,eAAe,eAAe,CAAC"}
|