hi all. i whant to log some events in recursive f...
# ask-community
hi all. i whant to log some events in recursive function, but i've got error
'SolidExecutionContext' object has no attribute 'bind'
how can i use
without passing
in finction?
Copy code
@op(out={"raw_list": Out(List[Dict])})
def recursive_collect_data(
        # context,
        token: str, page_n: int = 1):
    limit = 100
    response = requests.request(
        headers={"Authorization": f'Bearer {token}'},
        params={'per_page': limit, 'page': page_n, 'status': ['active']},
    raw_list = response.json()
    # context.log_event(
    #     AssetMaterialization(
    #         asset_key="avito items report",
    #         metadata={
    #             "page №": <http://MetadataValue.int|MetadataValue.int>(page_n),
    #             "length": <http://MetadataValue.int|MetadataValue.int>(len(raw_list['resources'])),
    #             "report meta": MetadataValue.json(raw_list['meta']),
    #         },
    #     )
    # )
    if len(raw_list.get('resources')) < limit:
        return raw_list['resources']

        return raw_list['resources'] + recursive_collect_data(
            # context=context,
            token=token, page_n=raw_list['meta']['page'] + 1,
Hi @won. i think this boils down to a DAG design question. in dagster, you can't call ops from within ops, it's a fundamental design choice in the system. There are a couple things you could do: 1. look into using dynamic graphs - an option would be to have your first op collect make all of the
calls and yield the response json as dynamic outs that each get processed by an op that logs the asset materialization event 2. keep everything in one op, but put the
call and the event logging in a for loop that runs until
raw_list.get('resources') < limit
❤️ 1