https://dagster.io/ logo
#ask-community
Title
# ask-community
j

Jesse Myers

04/04/2023, 9:23 PM
Hi y'all is it possible to run ops form a while loop? I keep getting an error:
Compute function of op 'get_data_to_score' has context argument, but no context was provided when invoking
the op with the loop looks like this:
Copy code
@op
def jit_scoring(trained_model):
    result = []
    while True:
        data_to_score = get_data_to_score()
        nrows = data_to_score['row_count']

        print(f'JIT NRows: {nrows}')
        if nrows < 1:
            break

        result.append(
            key_to_score(data_to_score['df'])
            .map(
                lambda key: ingest_data_and_score(
                    recruiter_in_batch=key, trained_model=trained_model
                )
            )
            .collect()
        )

    return result
d

Danny Steffy

04/04/2023, 9:30 PM
That error looks like the definition of
get_data_to_score
takes an argument called
context
and you didn't pass one in the invocation
j

Jesse Myers

04/04/2023, 9:35 PM
from what i understand
context
should be passed in by dagster. But just in case i was wrong in this assumption i tried to pass it in explicitly, it still failed with the same error
s

sandy

04/05/2023, 12:03 AM
Hi @Jesse Myers - Dagster doesn't support the ability to run ops from other ops. You can still directly invoke them, as you're doing here, but it will treat them like a regular Python function, not invoke them using Dagster's execution machinery
j

Jesse Myers

04/05/2023, 11:39 PM
Thanks Sandy, i'd see if using a plane function will be possible in this case. unfortunately that approach prevents us from using the IO manager that was used for that op