def test_inputs(): ec = make_test_run_context() env = ec.env g = graph() n1 = g.create_node(function=function_t1_source) n2 = g.create_node(function=function_t1_to_t2, inputs={"input": n1}) pi = n2.instantiate(env).get_interface() assert pi is not None n4 = g.create_node(function=function_multiple_input) n4.set_inputs({"input": n1}) pi = n4.instantiate(env).get_interface() assert pi is not None # ec.graph = g.instantiate(env) n1 = n1.instantiate(env) n4 = n4.instantiate(env) with env.md_api.begin(): exe = Executable(node=n1, function=n1.function, execution_context=ec) im = NodeInterfaceManager(exe) bi = im.get_bound_interface() assert bi is not None exe = Executable(node=n4, function=n4.function, execution_context=ec) im = NodeInterfaceManager(exe) db = DataBlockMetadata( nominal_schema_key="_test.TestSchema1", realized_schema_key="_test.TestSchema1", ) env.md_api.add(db) bi = im.get_bound_interface( {"input": StreamBuilder().as_managed_stream(ec)}) assert bi is not None
def test_inputs(): ec = make_test_run_context() env = ec.env g = graph() n1 = g.create_node(pipe=pipe_t1_source) n2 = g.create_node(pipe=pipe_t1_to_t2, upstream={"input": n1}) pi = n2.instantiate(env).get_interface() assert pi is not None n4 = g.create_node(pipe=pipe_multiple_input) n4.set_upstream({"input": n1}) pi = n4.instantiate(env).get_interface() assert pi is not None ec.graph = g.instantiate(env) with env.session_scope() as sess: im = NodeInterfaceManager(ctx=ec, sess=sess, node=n1.instantiate(env)) bi = im.get_bound_interface() assert bi is not None im = NodeInterfaceManager(ctx=ec, sess=sess, node=n4.instantiate(env)) db = DataBlockMetadata( nominal_schema_key="_test.TestSchema1", realized_schema_key="_test.TestSchema1", ) sess.add(db) bi = im.get_bound_interface( {"input": StreamBuilder().as_managed_stream(ec, sess)} ) assert bi is not None
def test_bigcommerce_order_products(): from snapflow_bigcommerce import module as snapflow_bigcommerce env = Environment(metadata_storage="sqlite://") env.add_module(snapflow_bigcommerce) g = graph() # Initial graph api_key = ensure_api_key() store_id = ensure_store_id() get_orders = g.create_node( snapflow_bigcommerce.functions.import_order_products, params={"api_key": api_key, "store_id": store_id,}, ) blocks = env.produce(get_orders, g, execution_timelimit_seconds=2,) assert len(blocks[0].as_records()) > 0
def run_test_crunchbase_import_funding_rounds(user_key): from snapflow_crunchbase import module as snapflow_crunchbase env = Environment() env.add_module(snapflow_crunchbase) env.add_storage("file://.") g = graph() # test funding rounds importer import_funding_rounds = g.create_node( snapflow_crunchbase.functions.import_funding_rounds, params={ "user_key": user_key, "use_sample": True }, ) output = env.produce(node_like=import_funding_rounds, graph=g) assert len(output[0].as_dataframe()) == 50