def test_write(wf_params, a): b = Types.MultiPartBlob() with b.create_part("0") as w: w.write("Hello world".encode("utf-8")) with b.create_part("1") as w: w.write("Hello world2".encode("utf-8")) a.set(b)
def write_special_types(wf_params, a, b, c, d, e): blob = Types.Blob() with blob as w: w.write("hello I'm a blob".encode('utf-8')) csv = Types.CSV() with csv as w: w.write("hello,i,iz,blob") mpcsv = Types.MultiPartCSV() with mpcsv.create_part('000000') as w: w.write("hello,i,iz,blob") with mpcsv.create_part('000001') as w: w.write("hello,i,iz,blob2") mpblob = Types.MultiPartBlob() with mpblob.create_part('000000') as w: w.write("hello I'm a mp blob".encode('utf-8')) with mpblob.create_part('000001') as w: w.write("hello I'm a mp blob too".encode('utf-8')) schema = Types.Schema([('a', Types.Integer), ('b', Types.Integer)])() with schema as w: w.write(_pd.DataFrame.from_dict({'a': [1, 2, 3], 'b': [4, 5, 6]})) w.write(_pd.DataFrame.from_dict({'a': [3, 2, 1], 'b': [6, 5, 4]})) a.set(blob) b.set(csv) c.set(mpcsv) d.set(mpblob) e.set(schema)
def test_multipartblob_passing(): @inputs(a=Types.MultiPartBlob) @outputs(b=Types.MultiPartBlob) @python_task def test_pass(wf_params, a, b): b.set(a) b = Types.MultiPartBlob() with b.create_part("0") as w: w.write("Hello world".encode("utf-8")) with b.create_part("1") as w: w.write("Hello world2".encode("utf-8")) out = test_pass.unit_test(a=b) assert len(out) == 1 with out["b"] as r: assert len(r) == 2 assert r[0].read().decode("utf-8") == "Hello world" assert r[1].read().decode("utf-8") == "Hello world2" out = test_pass.unit_test(a=out["b"]) assert len(out) == 1 with out["b"] as r: assert len(r) == 2 assert r[0].read().decode("utf-8") == "Hello world" assert r[1].read().decode("utf-8") == "Hello world2"