Skip to content

Add ClpIrStreamWriter for writing IR streams. #75

Open
@junhaoliao

Description

@junhaoliao

Request

We currently have a ClpIrStreamReader class, which allows reading of CLP IR streams. However, it is difficult to write meaningful tests for this reader within the project itself because there is no built-in mechanism to generate valid IR streams directly in JavaScript/TypeScript.

Currently, we rely on external libraries in another language like clp-ffi-py or clp-loglib-py to create IR files, and use a temporary script to exercise the ClpIrStreamReader functionality. Since these IR test files are not checked into Git, we are unable to check in this script or any related unit tests. This severely limits our ability to verify and maintain the reader's behaviour in a sustainable and automated way.

Possible implementation

Introducing a ClpIrStreamWriter class to the clp-ffi-js project would solve this problem. It would allow us to generate valid IR streams directly within the project, making it possible to write self-contained unit tests for ClpIrStreamReader.

Additionally, having a writer would open up the possibility of implementing a CLP IR logger in JavaScript that logs directly in the CLP IR format. This would expand the usability of clp-ffi-js and bring it more in line with the capabilities provided in the Python bindings.

The writer should support output to a WritableStream, allowing it to integrate seamlessly with browser and Node.js Web Stream APIs. Supporting WritableStream will likely require implementing a custom sink interface that handles write(), close(), and abort() methods as per the WritableStream spec.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions