Skip to content

MolSSI/mmic_cmd

mmic_cmd

GitHub Actions Build Status codecov Language grade: Python docs

Package that provides command-line execution using qcengine. A more thorough description to be followed in the near future ...

CmdComponent

General execution

from mmic_cmd.components import CmdComponent

inp = {
    "command": [executable, "--arg", arg, "--out", ofile_name],
    "outfiles": [ofile_name],
}
outp = CmdComponent.compute(inp)

stdout, stderr = outp.stdout, outp.stderr
ofile_content = outp.outfiles[ofile_name]

Specifying scratch dir & input files

inp = {
    "command": [executable, "--in", ifile_name, "--out", ofile_name],
    "infiles": [ifile_path], # copy file to scratch tmp dir
    "outfiles": [ofile_name],
    "scratch_directory": path_to_scratch_dir,
}

outp = CmdComponent.compute(inp)

stdout, stderr = outp.stdout, outp.stderr
scratch_dir = outp.scratch_directory

Tracking outfiles (no loading in memory)

By default, all files specified in outfiles are loaded in memory. To prevent that, we pass outfiles_track, a list of output file names to track (and not load), to compute. The file path, rather than its contents, are returned in outfiles for file names specified in outfiles_track. To ensure these files persist (and do not get deleted) after execution, we must set scratch_mess=True as well.

inp = {
    "command": [executable, "--in", ifile_name, "--out", ofile_name],
    "infiles": [ifile_path], # copy file to scratch tmp dir
    "outfiles": [big_ofile_name, small_ofil_name],
    "outfiles_track": [big_ofile_name],
    "scratch_directory": path_to_scratch_dir,
    "scratch_messy": True, # do not remove scratch dir
}

outp = CmdComponent.compute(inp)

stdout, stderr = outp.stdout, outp.stderr
big_ofile_path = outp.outfiles[big_ofile_name] -> Path
small_ofile_cont = outp.outfiles[small_ofile_name] -> str

Copyright

Copyright (c) 2021, MolSSI

Acknowledgements

Project based on the Computational Molecular Science Python Cookiecutter version 1.5.

Releases

No releases published

Packages

No packages published