def init_feature_vector_graph(vector, query_options, update_stats=False): try: from storey import SyncEmitSource except ImportError as exc: raise ImportError(f"storey not installed, use pip install storey, {exc}") feature_set_objects, feature_set_fields = vector.parse_features( offline=False, update_stats=update_stats ) graph = _build_feature_vector_graph( vector, feature_set_fields, feature_set_objects, query_options ) graph.set_flow_source(SyncEmitSource()) server = create_graph_server(graph=graph, parameters={}) cache = ResourceCache() index_columns = [] for featureset in feature_set_objects.values(): driver = get_online_target(featureset) if not driver: raise mlrun.errors.MLRunInvalidArgumentError( f"resource {featureset.uri} does not have an online data target" ) cache.cache_table(featureset.uri, driver.get_table_object()) for key in featureset.spec.entities.keys(): if not vector.spec.with_indexes and key not in index_columns: index_columns.append(key) server.init_states(context=None, namespace=None, resource_cache=cache) server.init_object(None) return graph, index_columns
def test_v2_mock(): host = create_graph_server(graph=RouterState()) host.graph.add_route( "my", class_name=ModelTestingClass, model_path="", multiplier=100 ) host.init(None, globals()) logger.info(host.to_yaml()) resp = host.test("/v2/models/my/infer", testdata) logger.info(f"resp: {resp}") # expected: source (5) * multiplier (100) assert resp["outputs"] == 5 * 100, f"wrong health response {resp}"
def init_featureset_graph(source, featureset, namespace, targets=None, return_df=True): """create storey ingestion graph/DAG from feature set object""" cache = ResourceCache() graph = featureset.spec.graph.copy() # init targets (and table) targets = targets or [] _add_data_states( graph, cache, featureset, targets=targets, source=source, return_df=return_df, ) server = create_graph_server(graph=graph, parameters={}) server.init(None, namespace, cache) return graph
def init_feature_vector_graph(vector): try: from storey import Source except ImportError as e: raise ImportError(f"storey not installed, use pip install storey, {e}") feature_set_objects, feature_set_fields = vector.parse_features() graph = _build_feature_vector_graph(vector, feature_set_fields, feature_set_objects) graph.set_flow_source(Source()) server = create_graph_server(graph=graph, parameters={}) cache = ResourceCache() for featureset in feature_set_objects.values(): driver = get_online_target(featureset) cache.cache_table(featureset.uri, driver.get_table_object()) server.init(None, None, cache) return graph
def init_feature_vector_graph(vector): try: from storey import SyncEmitSource except ImportError as exc: raise ImportError(f"storey not installed, use pip install storey, {exc}") feature_set_objects, feature_set_fields = vector.parse_features(False) graph = _build_feature_vector_graph(vector, feature_set_fields, feature_set_objects) graph.set_flow_source(SyncEmitSource()) server = create_graph_server(graph=graph, parameters={}) cache = ResourceCache() index_columns = [] for featureset in feature_set_objects.values(): driver = get_online_target(featureset) cache.cache_table(featureset.uri, driver.get_table_object()) for key in featureset.spec.entities.keys(): if not vector.spec.with_indexes and key not in index_columns: index_columns.append(key) server.init(None, None, cache) return graph, index_columns