Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many CLS no longer read from STDIN #21

Open
swheele2 opened this issue Sep 7, 2024 · 3 comments
Open

Many CLS no longer read from STDIN #21

swheele2 opened this issue Sep 7, 2024 · 3 comments
Assignees

Comments

@swheele2
Copy link
Member

swheele2 commented Sep 7, 2024

The recent fix to glob_files made it so none of the CLS could read from STDIN. I made a small change to glob_files that fixes many cases.

However, many CLS still can't read from STDIN. The problem is that get_outfile() and get_filename() get called on infiles even if the data is coming from STDIN.

It's very useful to be able to do things like
fetchMolecule.py -i benzene | makeInput.py -m b3lyp -b 6-31G -opt -freq -o benzene.com

I've fixed makeInput.py and angle.py and will try to fix the others over the next few days. Some Tony should probably check these fixes though to make sure...

@swheele2 swheele2 self-assigned this Sep 7, 2024
@ajs99778
Copy link
Contributor

A subtle difference, but they can read from STDIN. They just won't print the results.

For the fixes, I think we still want to allow outputting to a file. The current implementation implementation for makeInput.py would basically ignore the -o flag if the input is STDIN since it requires both a -o option and the input to be a filename.

A way to fix this would be something like

    if args.outfile:
        outfile = args.outfile
        if isinstance(f, str): # apply substitutions if a file path was given as input
            outfile = get_outfile(
                outfile,
                INFILE=get_filename(f, include_parent_dir="$INDIR" not in args.outfile),
                INDIR=dirname(f),
            )
        warnings = geom.write(
            append=True,
            outfile=outfile,
            style=style,
            theory=theory,
            return_warnings=True,
            **other_kwargs
        )

If you have a certain Tony in mind, be sure to mention their user name preceded by an @ so that they get notified. The odds of a random person with a specific name checking these issues is astronomically low.

@swheele2
Copy link
Member Author

Thanks Tony.

In terms of the current versions (the ones on PyPi for example), you mean they take STDIN but won't print the results to a file.

The reference to "A certain Tony" was a subtle reference to the UT-Mainz ACES II manual from 20 years ago (ACES II later became CFOUR), which still had a note in it for "a certain Daniel" to fix/implement something a decade after Crawford stopped being a postdoc. I figured you'd see it even without @ajs99778 .

@swheele2
Copy link
Member Author

I fixed a few more CLS. I think I've caught most of the ones for which it makes sense to allow for STDIN and an outfile.

I've also tried to make the CLS more consistent in terms of appending or not appending results to outfile. angle, bond, and dihedral all behave differently. Also, several of these didn't include line returns when writing to a file--only when printint to STDOUT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants