Exemplo n.º 1
0
def test_first_events(mock_event_records):
    mock_event_records.side_effect = get_mock_event_records([("comments", 1), ("stories", 2)])

    with instance_for_test() as instance:
        context = build_sensor_context(instance=instance)
        result = make_hn_tables_updated_sensor(job=GraphDefinition("test")).evaluate_tick(context)
        assert len(result.run_requests) == 1
        assert result.cursor == json.dumps({"comments": 1, "stories": 2})
Exemplo n.º 2
0
def get_op_result_value(op_inst):
    single_op_graph = GraphDefinition(
        name="test",
        description=None,
        node_defs=[load_num_csv_op("load_csv"), op_inst],
        dependencies={
            op_inst.name: {
                list(op_inst.input_dict.values())[0].name:
                DependencyDefinition("load_csv")
            }
        },
        input_mappings=None,
        output_mappings=None,
        config=None,
    )

    result = single_op_graph.execute_in_process()

    return result.output_for_node(op_inst.name)
Exemplo n.º 3
0
def construct_graph_with_yaml(yaml_file, op_defs) -> GraphDefinition:
    yaml_data = load_yaml_from_path(yaml_file)

    deps = {}

    for op_yaml_data in yaml_data["ops"]:
        def_name = op_yaml_data["def"]
        alias = op_yaml_data.get("alias", def_name)
        op_deps_entry = {}
        for input_name, input_data in op_yaml_data.get("deps", {}).items():
            op_deps_entry[input_name] = DependencyDefinition(
                solid=input_data["op"],
                output=input_data.get("output", "result"))
        deps[NodeInvocation(name=def_name, alias=alias)] = op_deps_entry

    return GraphDefinition(
        name=yaml_data["name"],
        description=yaml_data.get("description"),
        node_defs=op_defs,
        dependencies=deps,
    )
Exemplo n.º 4
0

# start_tag_pipeline
@job
def tagged_add_one():
    add_one.tag({"my_tag": "my_value"})(add_one(return_one()))


# end_tag_pipeline

# start_pipeline_definition_marker
one_plus_one_from_constructor = GraphDefinition(
    name="one_plus_one",
    node_defs=[return_one, add_one],
    dependencies={
        "add_one": {
            "number": DependencyDefinition("return_one")
        }
    },
).to_job()
# end_pipeline_definition_marker


# start_tags_pipeline
@job(tags={"my_tag": "my_value"})
def my_tags_job():
    my_op()


# end_tags_pipeline