Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def is_program_new_enough(program, version_feature_introduced):
"""Returns True if `program` registered in QCEngine, locatable in
environment, has parseable version, and that version in normalized
form is equal to or later than `version_feature_introduced`.
"""
if program not in qcng.list_available_programs():
return False
candidate_version = qcng.get_program(program).get_version()
return parse_version(candidate_version) >= parse_version(version_feature_introduced)
"fireworks": _plugin_import("fireworks"),
"rdkit": _plugin_import("rdkit"),
"psi4": _plugin_import("psi4"),
"parsl": _plugin_import("parsl"),
"dask": _plugin_import("dask"),
"dask_jobqueue": _plugin_import("dask_jobqueue"),
"geometric": _plugin_import("geometric"),
"torsiondrive": _plugin_import("torsiondrive"),
"torchani": _plugin_import("torchani"),
}
if _programs["dask"]:
_programs["dask.distributed"] = _plugin_import("dask.distributed")
else:
_programs["dask.distributed"] = False
_programs["dftd3"] = "dftd3" in qcng.list_available_programs()
def has_module(name):
return _programs[name]
def check_has_module(program):
import_message = "Not detecting module {}. Install package if necessary to enable tests."
if has_module(program) is False:
pytest.skip(import_message.format(program))
def _build_pytest_skip(program):
import_message = "Not detecting module {}. Install package if necessary to enable tests."
return pytest.mark.skipif(has_module(program) is False, reason=import_message.format(program))
def info_programs(): # lgtm: [py/similar-function]
print(">>> Program information")
all_progs = list_all_programs()
avail_progs = list_available_programs()
print("Available programs:")
for prog_name in sorted(avail_progs):
version = get_program(prog_name).get_version()
if version is None:
version = "???"
print(f"{prog_name + ':':12} v{version}")
print()
print("Other supported programs:")
print(" ".join(sorted(all_progs - avail_progs)))
print()
print(
"""If you think available programs are missing, query for details: `python -c "import qcengine as qcng; qcng.get_program('')"`"""
)
print()
self.scheduler = None
self.update_frequency = update_frequency
self.periodic = {}
self.active = 0
self.exit_callbacks = []
# Server response/stale job handling
self.server_error_retries = server_error_retries
self.stale_update_limit = stale_update_limit
self._stale_updates_tracked = 0
self._stale_payload_tracking = []
self.n_stale_jobs = 0
# QCEngine data
self.available_programs = qcng.list_available_programs()
self.available_procedures = qcng.list_available_procedures()
self.logger.info("QueueManager:")
self.logger.info(" Version: {}\n".format(get_information("version")))
if self.verbose:
self.logger.info(" Name Information:")
self.logger.info(" Cluster: {}".format(self.name_data["cluster"]))
self.logger.info(" Hostname: {}".format(self.name_data["hostname"]))
self.logger.info(" UUID: {}\n".format(self.name_data["uuid"]))
self.logger.info(" Queue Adapter:")
self.logger.info(" {}\n".format(self.queue_adapter))
if self.verbose:
self.logger.info(" QCEngine:")
self.scheduler = None
self.update_frequency = update_frequency
self.periodic = {}
self.active = 0
self.exit_callbacks = []
# Server response/stale job handling
self.server_error_retries = server_error_retries
self.stale_update_limit = stale_update_limit
self._stale_updates_tracked = 0
self._stale_payload_tracking = []
self.n_stale_jobs = 0
# QCEngine data
self.available_programs = qcng.list_available_programs()
self.available_procedures = qcng.list_available_procedures()
# Display a warning if there are non-node-parallel programs and >1 node_per_task
if self.nodes_per_task > 1:
for name in self.available_programs:
program = qcng.get_program(name)
if not program.node_parallel:
self.logger.warning(
"Program {} is not node parallel," " but manager will use >1 node per task".format(name)
)
# Print out configuration
self.logger.info("QueueManager:")
self.logger.info(" Version: {}\n".format(get_information("version")))
if self.verbose: