def query_assets(self, query: str) -> List[Asset]: """Returns all assets that match the query. The supported query syntax is described in detail at https://docs.dagster.io/overview/solid-selection. """ traverser = Traverser(graph=self._dep_graph) return [ self._assets_by_path_str[pstr] for pstr in clause_to_subset(traverser, self._dep_graph, query) ]
def query_assets(self, query: Optional[str]) -> List[Asset]: """Returns all assets that match the query. The supported query syntax is described in detail at https://docs.dagster.io/overview/solid-selection. """ if query is None: return list(self._assets_by_path_str.values()) queried_asset_path = parse_clause(query)[1] if queried_asset_path not in self._assets_by_path_str.keys(): raise LakehouseAssetQueryError( f"{queried_asset_path} does not exist in set of assets.") traverser = Traverser(graph=self._dep_graph) return [ self._assets_by_path_str[pstr] for pstr in clause_to_subset(traverser, self._dep_graph, query) ]
def test_traverser(): graph = generate_dep_graph(foo_pipeline) traverser = Traverser(graph) assert traverser.fetch_upstream(item_name='return_one', depth=1) == set() assert traverser.fetch_downstream(item_name='return_one', depth=1) == set(['add_nums']) assert traverser.fetch_upstream(item_name='multiply_two', depth=0) == set() assert traverser.fetch_upstream(item_name='multiply_two', depth=2) == set( ['add_nums', 'return_one', 'return_two'], ) assert traverser.fetch_downstream(item_name='multiply_two', depth=2) == set(['add_one'])
def test_traverser(): graph = generate_dep_graph(foo_pipeline) traverser = Traverser(graph) assert traverser.fetch_upstream(item_name="return_one", depth=1) == set() assert traverser.fetch_downstream(item_name="return_one", depth=1) == {"add_nums"} assert traverser.fetch_upstream(item_name="multiply_two", depth=0) == set() assert traverser.fetch_upstream(item_name="multiply_two", depth=2) == { "add_nums", "return_one", "return_two", } assert traverser.fetch_downstream(item_name="multiply_two", depth=2) == {"add_one"}
def test_traverser_invalid(): graph = generate_dep_graph(foo_pipeline) traverser = Traverser(graph) assert traverser.fetch_upstream(item_name="some_solid", depth=1) == set()