Exemplo n.º 1
0
 def test_get_cache_return_value_matches_outputs(self):
     cache = CallCache(cfg=self.cfg, logger=self.logger)
     rundir, outputs = self._run(self.test_wdl,
                                 self.ordered_input_dict,
                                 cfg=self.cfg)
     inputs = values_from_json(self.ordered_input_dict,
                               self.doc.tasks[0].available_inputs)
     input_digest = cache.get_digest_for_inputs(inputs)
     task_digest = cache.get_digest_for_task(task=self.doc.tasks[0])
     cache_value = cache.get(
         key=f"{self.doc.tasks[0].name}_{task_digest}/{input_digest}",
         output_types=self.doc.tasks[0].effective_outputs)
     self.assertEqual(values_to_json(outputs), values_to_json(cache_value))
Exemplo n.º 2
0
 def test_task_input_cache_matches_output(self):
     # run task, check output matches what was stored in run_dir
     cache = CallCache(cfg=self.cfg, logger=self.logger)
     rundir, outputs = self._run(self.test_wdl,
                                 self.ordered_input_dict,
                                 cfg=self.cfg)
     inputs = values_from_json(self.ordered_input_dict,
                               self.doc.tasks[0].available_inputs)
     input_digest = cache.get_digest_for_inputs(inputs)
     task_digest = cache.get_digest_for_task(task=self.doc.tasks[0])
     with open(
             os.path.join(
                 self.cache_dir,
                 f"{self.doc.tasks[0].name}_{task_digest}/{input_digest}.json"
             )) as f:
         read_data = json.loads(f.read())
     self.assertEqual(read_data, WDL.values_to_json(outputs))
Exemplo n.º 3
0
    def test_input_digest_sorts_keys(self):
        # Note this fails if input array is reordered

        ordered_inputs = values_from_json(self.ordered_input_dict,
                                          self.doc.tasks[0].available_inputs)
        unordered_inputs = values_from_json(
            {
                "where": {
                    "places": {
                        "SanFan": "b",
                        "Minneapolis": "a"
                    }
                },
                "what": ["a", "ab", "b", "bc"],
                "who": "Alyssa"
            }, self.doc.tasks[0].available_inputs)

        ordered_digest = CallCache(
            cfg=self.cfg,
            logger=self.logger).get_digest_for_inputs(ordered_inputs)
        unordered_digest = CallCache(
            cfg=self.cfg,
            logger=self.logger).get_digest_for_inputs(unordered_inputs)
        self.assertEqual(ordered_digest, unordered_digest)