Ejemplo n.º 1
0
    def test_pipeline_stage_status(self):
        backend = LocalArtifactBackend(config={"path": "./test_storage/"})
        artifact = Artifact(self.stage_config)
        payload = "SHRIM"
        artifact.item = Item(payload=payload)

        status = backend.pipeline_stage_run_status(self.stage_config,
                                                   artifact._dependency_hash)
        self.assertEqual(status, STAGE_DOES_NOT_EXIST)

        backend.save_artifact(artifact)

        status = backend.pipeline_stage_run_status(self.stage_config,
                                                   artifact._dependency_hash)
        self.assertEqual(status, STAGE_IN_PROGRESS)

        backend.log_pipeline_stage_run_complete(self.stage_config,
                                                artifact._dependency_hash)
        status = backend.pipeline_stage_run_status(self.stage_config,
                                                   artifact._dependency_hash)
        self.assertEqual(status, STAGE_COMPLETE)

        meta = backend._get_pipeline_stage_run_meta(self.stage_config,
                                                    artifact._dependency_hash)

        self.assertEqual(len(meta['artifacts']), 1)
Ejemplo n.º 2
0
    def test_find_artifact(self):
        backend = LocalArtifactBackend(config={"path": "./test_storage/"})
        artifact = Artifact(self.stage_config)
        payload = "SHRIM"
        artifact.item = Item(payload="SHRIM")
        backend.save_artifact(artifact)

        loaded_artifact = backend._find_cached_artifact(artifact)

        # Ensure that we found the artifact
        self.assertNotEqual(None, loaded_artifact)

        # Ensure that the artifact doesn't have a payload
        self.assertNotEqual(None, loaded_artifact.item)
        self.assertEqual(None, loaded_artifact.item.payload)

        # Ensure that meta properties are correctly set on artifact
        self.assertEqual(loaded_artifact._specific_hash,
                         artifact._specific_hash)
        self.assertEqual(loaded_artifact._dependency_hash,
                         artifact._dependency_hash)
        self.assertEqual(loaded_artifact._definition_hash,
                         artifact._definition_hash)
        self.assertEqual(loaded_artifact._pipeline_stage,
                         artifact._pipeline_stage)
        self.assertEqual(loaded_artifact.item.type, artifact.item.type)
Ejemplo n.º 3
0
    def test_load_artifact(self):
        backend = LocalArtifactBackend(config={"path": "./test_storage/"})
        artifact = Artifact(self.stage_config)
        payload = "SHRIM"
        artifact.item = Item(payload="SHRIM")
        backend.save_artifact(artifact)

        loaded_artifact = backend.load_artifact(artifact)
        self.assertEqual(loaded_artifact.item.payload, artifact.item.payload)
Ejemplo n.º 4
0
 def test_save_missing_payload(self):
     backend = LocalArtifactBackend(config={"path": "./test_storage/"})
     artifact = Artifact(self.stage_config)
     try:
         backend.save_artifact(artifact)
         self.assertEqual(
             0, "The above line should fail " +
             "due to the artifact having no payload")
         self.fail()
     except ArtifactMissingPayloadError:
         pass
Ejemplo n.º 5
0
 def __init__(self, filepath, loop=None, backend=None):
     super().__init__(filepath, loop)
     self._local_cpu_executor = LocalCPUExecutor(self._loop)
     self._default_executor = self._local_cpu_executor
     if backend is None:
         backend = LocalArtifactBackend()
     self._artifact_backend = backend
Ejemplo n.º 6
0
    def test_pipeline_stage_run_meta(self):
        backend = LocalArtifactBackend(config={"path": "./test_storage/"})
        artifact = Artifact(self.stage_config)
        payload = "SHRIM"
        artifact.item = Item(payload=payload)
        backend.save_artifact(artifact)

        backend.log_pipeline_stage_run_complete(self.stage_config,
                                                artifact._dependency_hash)

        arts = backend.find_pipeline_stage_run_artifacts(
            self.stage_config, artifact._dependency_hash)
        self.assertEqual(len(arts), 1)
        self.assertEqual(arts[0].get_uid(), artifact.get_uid())
Ejemplo n.º 7
0
 def test_run(self):
     backend = LocalArtifactBackend()
     arts = self.pregenerate_artifacts(backend)
     loop = asyncio.set_event_loop(asyncio.new_event_loop())
     executor = LocalCPUExecutor(loop=loop)
     server = ExecutorServer(backend, executor)
     job_id = server.enqueue_job({
         "stage_name":
         "StageB",
         "stage_config":
         self.generate_pipeline_config()["StageB"],
         "artifacts":
         list(map(lambda x: x.meta_to_dict(), arts))
     })
     server.run_event_loop(2)
     job_result = server.retrieve_job(job_id)
     self.assertEqual(len(job_result['artifacts']), 1)
     self.assertEqual(self.testfile_contents,
                      job_result['artifacts'][0].item.payload)
Ejemplo n.º 8
0
 def test_save_artifact(self):
     backend = LocalArtifactBackend(config={"path": "./test_storage/"})
     artifact = Artifact(self.stage_config)
     artifact.item = Item(payload="SHRIM")
     backend.save_artifact(artifact)
     pass