async def value_async( self, executor: Optional[Callable[[ast.AST, Optional[str]], Any]] = None, title: Optional[str] = None, ) -> Any: r""" Evaluate the ObjectStream computation graph. Tracks back to the source dataset to understand how to evaluate the AST. It is possible to pass in an executor to override that behavior (used mostly for testing). Arguments: executor A function that when called with the ast will return a future for the result. If None, then uses the default executor. Normally is none and the default executor specified by the `EventDatasource` is called instead. title Optional title to hand to the transform Returns The first element of the ObjectStream after evaluation. Note This is the non-blocking version - it will return a future which can be `await`ed upon until the query is done. """ # Fetch the executor exe = self._get_executor(executor) # Run it from func_adl.ast.meta_data import remove_empty_metadata return await exe(remove_empty_metadata(self._q_ast), title)
def test_remove_metadata_no_change_2_levels(): "Removing metadata should not alter original query" orig = my_event().MetaData({}).MetaData({}) remove_empty_metadata(orig.query_ast) assert "MetaData" in ast.dump(orig.query_ast)
def test_remove_empty_metadata_not_empty(): r = remove_empty_metadata(my_event().MetaData({"hi": "there"}).value()) assert "MetaData" in ast.dump(r)
def test_remove_empty_metadata_empty(): r = remove_empty_metadata(my_event().MetaData({}).value()) assert "MetaData" not in ast.dump(r)