pierrehirel / atomsk

Atomsk: A Tool For Manipulating And Converting Atomic Data Files -
https://atomsk.univ-lille.fr
GNU General Public License v3.0
203 stars 75 forks source link

Feature request: Add option to redirect output to stdout rather than writing to disk #30

Closed mjclarke94 closed 3 years ago

mjclarke94 commented 3 years ago

Hi,

I'm currently using python as a wrapper (using subprocess) around atomsk for generating polycrystals. I need specific stoichiometry for charge balancing so I am just run it repeatedly until I happen to hit one which works. The issue is that this means there is a ton of fileIO each iteration (load in the primitive cell, write the polycrystal to disk, then load it back in to python to check the stoichiometry.

Having the output go to stdout rather than to disk would massively increase the speed of this operation.

pierrehirel commented 3 years ago

Dear Sir,

Since version 0.11 it is possible to specify "NULL" as an output file, which will produce no output at all. I do not know if that is useful to you, as you probably need the number of atoms in your workflow.

I will think of a way to write the output to stdout, but I think it will require to modify all output modules so it may take some time. I will come back to you when I get something working.

Best regards

pierrehirel commented 3 years ago

Hi,

I just committed a new version that allows output to stdout. As I suspected it required modifying all output modules.

To trigger it, specify "-" instead of an output file, and then one or several output formats. Examples:

atomsk input.cfg - vesta atomsk --polycrystal seed.cfg poly.txt - cfg

In addition, when output is stdout then the verbosity is set to zero, so that no other message is displayed on screen.

I must admit that I did not test this new implementation thoroughly, I tested the mode "--polycrystal" but not much more than that so process with caution.

Please let me know if you find bugs or if it corresponds to your expectations.

Best regards

mjclarke94 commented 3 years ago

Hi Pierre,

I've tried out the new mode (thanks for the quick implementation!). The redirection to stdout seems to work well, but the supplemental files (grain locations etc) still are written to disk in addition to being ported to stdout. Whilst this reduces the need to read files back in, there is still the IO cost of writing the files out!

Not sure whether preventing this would require a major upheaval?

Best, Matt

pierrehirel commented 3 years ago

Hi,

I just pushed an update that disables the writing of all additional files when the output is stdout. Let me know if it works and suits your needs.

Best Pierre

pierrehirel commented 3 years ago

In the absence of reply or comments for more than 1 month I close this thread.

pmrv commented 3 years ago

I just wanted to say, I'm working on integrating atomsk into pyiron and found this feature very helpful, thanks!