Exemplo n.º 1
0
 def it_returns_whole_block():
     assert utils.block_search({"a": [{
         "b": 1
     }, {
         "c": 2
     }]}, None) == {
         "a": [{
             "b": 1
         }, {
             "c": 2
         }]
     }
Exemplo n.º 2
0
    def execute(self, **kwargs):
        failure = None
        logs = []
        start_time = time.time()
        try:
            pipeline = RunPipeline(self.run_folder, self.dst_dir, self.tasks,
                                   **kwargs)
            logs = pipeline.logs()
        except Exception as e:
            failure = e

        if "_erisyon" in self.tasks:
            utils.yaml_save(str(self.run_folder / "_erisyon.yaml"),
                            self.tasks._erisyon)

        # WRITE manifest
        utils.yaml_write(
            self.run_folder / "run_manifest.yaml",
            uuid=uuid.uuid4().hex,
            run_dir=str(self.run_folder),
            run_name=utils.block_search(self.config, "_erisyon.run_name", ""),
            elapsed_secs=time.time() - start_time,
            timestamp=time.time(),
            who=local.env.get("RUN_USER", "Unknown"),
            n_cpus=os.cpu_count(),
            tasks=self.tasks,
            kwargs=kwargs,
            cmdline_args=sys.argv,
            logs=logs,
            errors=dict(
                failure=f"{failure.__class__.__name__}: {failure}"
                if failure else None,
                pipeline_failures=[
                    f"{i[1]}: {i[3]}" for i in logs if i[2] == "failed"
                ],
            ),
        )

        if failure is not None:
            raise failure

        return pipeline.failed_count()
Exemplo n.º 3
0
 def mp(block_name, default=None):
     return utils.block_search(
         full.metadata_seq.SLxPictureMetadata, block_name,
         default)
Exemplo n.º 4
0
 def me(block_name, default=None):
     return utils.block_search(full.metadata.SLxExperiment,
                               block_name, default)
Exemplo n.º 5
0
 def it_does_not_raise_on_bad_form():
     assert utils.block_search({"a": []}, "a.q") is None
Exemplo n.º 6
0
 def it_returns_none():
     assert utils.block_search({"a": [{"b": 1}, {"c": 2}]}, "a.0.q") is None
Exemplo n.º 7
0
 def it_returns_pointer():
     c = {"c": 2}
     assert utils.block_search({"a": [{"b": 1}, c]}, "a.1") is c
Exemplo n.º 8
0
 def it_searches_blocks():
     assert utils.block_search({"a": [{"b": 1}, {"c": 2}]}, "a.1.c") == 2