question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add option to save generated code into file

See original GitHub issue

I’m sorry if I missed this functionality, but CLI version hasn’t it for sure (I saw the related code only in generate_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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
izeigermancommented, Jul 20, 2020

Hey @wbadry!

If you’re using m2cgen in CLI you can just redirect its stdout into the file. Eg:

$ m2cgen <path_to_model> --language c > <path_to_output_file>

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!

0reactions
StrikerRUScommented, Apr 11, 2021

Closing due to the lack of interest.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Question] Can I save the text of codegen to a file? #16493
So, I'm thinking if it's possible to save the generated code to a file. In that case, I could upload the file and...
Read more >
Using HTML5/JavaScript to generate and save a file
Another option to save client-side generated files, is to put their contents in a Blob (or File) object and create a download link...
Read more >
How To Create and Save Your First HTML File By Hand
If you're on a Windows PC, be sure to click the dropdown box below the file name input, labeled “Save as type:” and...
Read more >
Scripting with Python - Generate Data and Save it to a file
In this Video, "Scripting with Python - Generate Data and Save it to a file ", I create a python piece of code...
Read more >
Creating SAVE Files of Program Files - L3HarrisGeospatial.com
The SAVE file need only include your own code, creating a smaller file that is easier to distribute. To create SAVE files to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found