コード例 #1
0
    def test_file_retrieval(self):
        file_manager = InMemoryFileManager({
            'path/to/a': b'a',
            'path/to/b': b'b' * 37
        })
        retrieval_service = artifact_service.ArtifactRetrievalService(
            file_manager.file_reader, chunk_size=10)
        dep_a = self.file_artifact('path/to/a')
        self.assertEqual(
            retrieval_service.ResolveArtifacts(
                beam_artifact_api_pb2.ResolveArtifactsRequest(
                    artifacts=[dep_a])),
            beam_artifact_api_pb2.ResolveArtifactsResponse(
                replacements=[dep_a]))

        self.assertEqual(
            list(
                retrieval_service.GetArtifact(
                    beam_artifact_api_pb2.GetArtifactRequest(artifact=dep_a))),
            [beam_artifact_api_pb2.GetArtifactResponse(data=b'a')])
        self.assertEqual(
            list(
                retrieval_service.GetArtifact(
                    beam_artifact_api_pb2.GetArtifactRequest(
                        artifact=self.file_artifact('path/to/b')))),
            [
                beam_artifact_api_pb2.GetArtifactResponse(data=b'b' * 10),
                beam_artifact_api_pb2.GetArtifactResponse(data=b'b' * 10),
                beam_artifact_api_pb2.GetArtifactResponse(data=b'b' * 10),
                beam_artifact_api_pb2.GetArtifactResponse(data=b'b' * 7)
            ])
コード例 #2
0
 def ResolveArtifacts(self, request):
     replacements = []
     for artifact in request.artifacts:
         if artifact.type_urn == 'unresolved':
             replacements += [resolved_a, resolved_b]
         else:
             replacements.append(artifact)
     return beam_artifact_api_pb2.ResolveArtifactsResponse(
         replacements=replacements)
コード例 #3
0
 def ResolveArtifacts(self, request, context=None):
   return beam_artifact_api_pb2.ResolveArtifactsResponse(
       replacements=request.artifacts)