Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upadd option to save generated code into file #110
Comments
|
Hey @StrikerRUS, thanks for reporting this. Can |
|
@izeigerman Why not?.. I just used it so for preparing #109. |
|
Yeah, I'm just trying to understand whether piping is sufficient after all or not. |
|
Just a comment; I started working on this today and the docs could be upgraded to clarify that CLI use can use piping to save to a file. I "might" try to tackle this as I would like to get my feet wet on contributing to OSS. |
|
@eafpres Do you mean docs of the CLI tool itself or the README? We do mention this in the latter: https://github.com/BayesWitnesses/m2cgen#cli . In any case please feel free to submit a PR. Contributions are welcome! |
|
@izeigerman Initially I was going to propose a change to the readme. Piping works fine on the CLI so I don't see an urgent need to explicitly add the functionality to that tool. Long-term maybe. |
|
Hey @wbadry! If you're using
Alternatively if you're using the Python API: import m2cgen as m2c
generated_code = m2c.export_to_c(...)
with open('<path_to_output_file', 'w') as fd:
fd.write(generated_code)Hope this helps! |



I'm sorry if I missed this functionality, but
CLIversion hasn't it for sure (I saw the related code only ingenerate_code_examples.py). I guess it will be very useful to eliminate copy-paste phase, especially for large models.Of course, piping is a solution, but not for development in Jupyter Notebook, for example.