def test_keyword_args_passing(adapter_client_fixture, cores_per_task, memory_per_task, scratch_dir): if scratch_dir == "tmpdir": temp_directory = tempfile.TemporaryDirectory() scratch_dir = temp_directory.name psi4_mem_buffer = 0.95 # Memory consumption buffer on psi4 adapter_client = adapter_client_fixture task_id = "uuid-{}-{}".format(cores_per_task, memory_per_task) tasks = [ # Emulate the QueueManager test function { "id": task_id, "spec": { "function": "qcengine.compute", "args": [{ "molecule": ptl.data.get_molecule("hooh.json"), "driver": "energy", "model": { "method": "HF", "basis": "sto-3g" }, "keywords": {}, }, "psi4"], "kwargs": {} }, "parser": "single", "tag": "other" } ] # Spin up a test queue manager manager = QueueManager(None, adapter_client, cores_per_task=cores_per_task, memory_per_task=memory_per_task, scratch_directory=scratch_dir) # Operate on the adapter since there is no backend QCF Client manager.queue_adapter.submit_tasks(tasks) manager.queue_adapter.await_results() ret = manager.queue_adapter.acquire_complete() assert len(ret) == 1 # Not all return objects, TOFIX if hasattr(ret[task_id], "dict"): ret = ret[task_id].dict() else: ret = ret[task_id] assert ret["success"], ret["error"]["error_message"] provenance = ret["provenance"] if cores_per_task is not None: assert provenance["nthreads"] == cores_per_task if memory_per_task is not None: assert provenance["memory"] == pytest.approx(memory_per_task * psi4_mem_buffer) if scratch_dir is not None: assert manager.queue_adapter.qcengine_local_options[ "scratch_directory"] == scratch_dir
def test_cores_per_rank(adapter_client_fixture, caplog): manager = QueueManager(None, adapter_client_fixture, nodes_per_task=2, cores_per_rank=2) # Check that ``cores_per_rank`` is set in local properties assert manager.queue_adapter.qcengine_local_options.get( "cores_per_rank") == 2
def test_node_parallel(adapter_client_fixture, caplog): # Make sure to grab the warnings caplog.set_level(logging.WARNING) # Set up the queue manager manager = QueueManager(None, adapter_client_fixture, nodes_per_task=2) # Initializer should warn users about non-node-parallel codes assert "Program rdkit is not node parallel" in caplog.text # Check that ``nnodes`` is set in local properties assert manager.queue_adapter.qcengine_local_options.get("nnodes") == 2