I'm having a similar problem regarding the `serve(...
# prefect-cloud
d
I'm having a similar problem regarding the
serve()
method as Banias above. The hello_world trivial example from the docs works fine for me. However, when using
serve()
on a flow that reads a file and writes to BigQuery I get the following error:
AttributeError: 'NoneType' object has no attribute 'serve'
prefect version: 2.13.5
1
n
hmm can you share your code for defining your flow that you're calling
serve
on?
upvote 1
d
Copy code
@flow(validate_parameters=False)
def gsheet_flow(**kwargs):
    logger = get_run_logger()

    data = base.Data(**kwargs)
    data.create_bq_client()
    <http://logger.info|logger.info>(f'{data.table_name} running')

    if data.file_type == 'gsheet':
        data.get_gsheet(sheets_service=sheets_service)
    else:
        data.get_file(drive_service=drive_service)
    <http://logger.info|logger.info>(f'{data.table_name} data collected')

    data.clean_col_names()
    if not data.does_dataset_exist():
        data.create_dataset()
    if not data.does_table_exist():
        data.create_table_and_load_df()
    else:
        data.database_upsert()
    <http://logger.info|logger.info>(f'{data.table_name} inserted successfully')


if __name__ == '__main__':
    # testing with single file
    table_name = 'client_dataset'
    file_params = files[table_name]
    kwargs.update({'table_name':table_name, 'file_params': file_params})
    
    # trying to create deployment with serve
    gsheet_flow(**kwargs).serve(name='gsheet_bq_deployment')
I'm wrapping a class instance and subsequent method calls in a flow decorated function since class methods can't be tasks/flows
n
ah, you're calling
.serve
on the result of your flow, not your flow object
you'd want to pass your kwargs when triggering the deployment that results from
.serve
d
Ahh silly me. Thank you and thanks for the quick replies
n
sure thing!