Exemplo n.º 1
0
 def test_recursive_get_result(self):
     # Basic functionality with dictionary key
     result_dict = {"output":[{}, {"data":[0, 1, 2, 3]}]}
     out = recursive_get_result({"my_data":">>output.-1.data.2"}, result_dict)
     self.assertEqual(out["my_data"], 2)
     # Basic functionality with attribute
     task1 = Task1()
     out_attr = recursive_get_result({"fw_name":"a>>_fw_name"}, task1)
     self.assertEqual(out_attr["fw_name"],"{{atomate.utils.tests.test_utils.Task1}}")
     # Testing as_dict functionality
     out_as_dict = recursive_get_result({"fw_name":">>_fw_name"}, task1)
     self.assertEqual(out_as_dict["fw_name"],"{{atomate.utils.tests.test_utils.Task1}}")
Exemplo n.º 2
0
 def test_recursive_get_result(self):
     # Basic functionality with dictionary key
     result_dict = {"output": [{}, {"data": [0, 1, 2, 3]}]}
     out = recursive_get_result({"my_data": ">>output.-1.data.2"}, result_dict)
     self.assertEqual(out["my_data"], 2)
     # Basic functionality with attribute
     task1 = Task1()
     out_attr = recursive_get_result({"fw_name": "a>>_fw_name"}, task1)
     self.assertEqual(out_attr["fw_name"], "{{atomate.utils.tests.test_utils.Task1}}")
     # Basic functionality with callable attribute
     out_attr2 = recursive_get_result({"keys": "a>>keys"}, task1)
     self.assertEqual(list(out_attr2["keys"]), [])
     # Testing as_dict functionality
     out_as_dict = recursive_get_result({"fw_name": ">>_fw_name"}, task1)
     self.assertEqual(out_as_dict["fw_name"], "{{atomate.utils.tests.test_utils.Task1}}")
Exemplo n.º 3
0
    def run_task(self, fw_spec):
        pass_dict = self.get("pass_dict")
        parse_kwargs = self.get("parse_kwargs")
        pc_string = self.get("parse_class")
        parse_class = load_class(*pc_string.rsplit(".", 1))
        calc_dir = self.get("calc_dir", ".")
        with monty.os.cd(calc_dir):
            result = parse_class(**parse_kwargs)

        pass_dict = recursive_get_result(pass_dict, result)
        mod_spec_key = self.get("mod_spec_key", "prev_calc_result")
        mod_spec_cmd = self.get("mod_spec_cmd", "_set")
        return FWAction(mod_spec=[{mod_spec_cmd: {mod_spec_key: pass_dict}}])
Exemplo n.º 4
0
    def run_task(self, fw_spec):
        pass_dict = self.get("pass_dict")
        parse_kwargs = self.get("parse_kwargs")
        pc_string = self.get("parse_class")
        parse_class = load_class(*pc_string.rsplit(".", 1))
        calc_dir = self.get("calc_dir", ".")
        with monty.os.cd(calc_dir):
            result = parse_class(**parse_kwargs)

        pass_dict = recursive_get_result(pass_dict, result)
        mod_spec_key = self.get("mod_spec_key", "prev_calc_result")
        mod_spec_cmd = self.get("mod_spec_cmd", "_set")
        return FWAction(mod_spec=[{mod_spec_cmd: {mod_spec_key: pass_dict}}])