def test_node_environ(): scratch_name = "myscratch1234" with environ_context(env={"QCA_SCRATCH_DIR": scratch_name}): description = {"name": "something", "hostname_pattern": "*", "scratch_directory": "$QCA_SCRATCH_DIR"} node = qcng.config.NodeDescriptor(**description) assert node.scratch_directory == scratch_name
def opt_state_basic(): """ Capture the options state and temporarily override. """ # Snapshot env old_node = copy.deepcopy(qcng.config.NODE_DESCRIPTORS) scratch_name = "myscratch1234" with environ_context(env={"QCA_SCRATCH_DIR": scratch_name}): configs = [ { "name": "dragonstooth", "hostname_pattern": "dt*", "jobs_per_node": 2, "ncores": 12, "memory": 120, "scratch_directory": "$NOVAR_RANDOM_ABC123", }, { "name": "newriver", "hostname_pattern": "nr*", "jobs_per_node": 2, "ncores": 24, "memory": 240 }, { "name": "batchnode", "hostname_pattern": "bn*", "is_batch_node": True, "jobs_per_node": 1, "mpiexec_command": "mpirun -n {total_ranks} -N {ranks_per_node}", "ncores": 24, "memory": 240, }, { "name": "default", "hostname_pattern": "*", "jobs_per_node": 1, "memory": 4, "memory_safety_factor": 0, "ncores": 5, "scratch_directory": "$QCA_SCRATCH_DIR", }, ] for desc in configs: node = qcng.config.NodeDescriptor(**desc) qcng.config.NODE_DESCRIPTORS[desc["name"]] = node yield # Reset env qcng.config.NODE_DESCRIPTORS = old_node