def put_metadata(staging_token, name, sha256=None): return beam_artifact_api_pb2.PutArtifactRequest( metadata=beam_artifact_api_pb2.PutArtifactMetadata( staging_session_token=staging_token, metadata=beam_artifact_api_pb2.ArtifactMetadata( name=name, sha256=sha256)))
def artifact_request_generator(): artifact_metadata = beam_artifact_api_pb2.ArtifactMetadata( name=artifact_name, sha256=_get_file_hash(local_path_to_artifact)) metadata = beam_artifact_api_pb2.PutArtifactMetadata( staging_session_token=self._staging_session_token, metadata=artifact_metadata) request = beam_artifact_api_pb2.PutArtifactRequest(metadata=metadata) yield request with open(local_path_to_artifact, 'rb') as f: while True: chunk = f.read(1 << 21) # 2MB if not chunk: break request = beam_artifact_api_pb2.PutArtifactRequest( data=beam_artifact_api_pb2.ArtifactChunk(data=chunk)) yield request self._artifacts.append(artifact_metadata)
def put_data(chunk): return beam_artifact_api_pb2.PutArtifactRequest( data=beam_artifact_api_pb2.ArtifactChunk(data=chunk))