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

Quy

06/14/2023, 7:42 PM
Hi folks I am using the latest version of dagster, I got a problem where an op returns a data frame but outside doesn't recognize it and throws an error
Copy code
@op(required_resource_keys={"analytic_db"},)
def query(context) -> pd.DataFrame:
    engine = create_engine(context.resources.analytic_db)
    query = """
        select  * from foo;
    """
    df = pd.read_sql_query(query, con=engine.connect())
    context.log.debug(df.shape)
    return df

@graph
def main():   
    result = query()
    print(result.shape)
context.log.debug
can show my data frame shape, but outside said
AttributeError: 'InvokedNodeOutputHandle' object has no attribute 'shape'
Not sure what I missed? I used all default configs
o

owen

06/14/2023, 10:25 PM
hi @Quy! the code inside an
@graph
decorated function is purely for defining dependencies between ops (or other graphs). so when the code inside
main
is executed, it's not actually executing the ops themselves, it's just telling dagster which outputs should be fed into which inputs.
❇️ 1
1
in this case, you'd want to either put that print statement within the original query op, or create a new op that would consume
result
and then print out
result.shape
4 Views