https://prefect.io logo
#prefect-community
Title
# prefect-community
t

Tabari Brannon

05/04/2022, 8:37 PM
Newbie question - I am getting this error when I try to register my flow.
Copy code
File "C:\etls\tractor_hours_analyzer\tractor_hours_analyzer.py", line 89, in <module>
    transformed = transform_add_files_to_dataframe(extracted)
    raise TypeError('too many positional arguments') from None
    TypeError: too many positional argumentswith
k

Kevin Kho

05/04/2022, 8:38 PM
Can you show the
transform_add_files_to_dataframe
task definition?
t

Tabari Brannon

05/04/2022, 8:39 PM
Copy code
def transform_add_files_to_dataframe():
    cwd = os.path.abspath('\\etls\\tractor_hours_analyzer')
    files = os.listdir(cwd)
    df = pd.DataFrame()
    for file in files:
        if file.endswith('.xlsx'):
            df = df.append(pd.read_excel(file), ignore_index=True)
    df.head()
    return df
k

Kevin Kho

05/04/2022, 8:39 PM
But you are passing something called
extracted
to that but it doesn’t accept anything
t

Tabari Brannon

05/04/2022, 8:40 PM
with Flow("tractor_hours_analyzer") as flow: extracted = extract_hours_from_website() transformed = transform_add_files_to_dataframe(extracted) load = load_into_database(transform) clean_up_directory(load)
k

Kevin Kho

05/04/2022, 8:40 PM
Are you trying to pass something to it or just set an upstream dependency?
t

Tabari Brannon

05/04/2022, 8:40 PM
It's when I declare my flow for the dependencies. I have done it that way before.
Upstream dependency
k

Kevin Kho

05/04/2022, 8:41 PM
You can do it if
transform_add_files_to_dataframe
accepted something. Otherwise you can do
Copy code
with Flow() as flow:
    a = task_a()
    b = task_b(upstream_tasks=[a])
The issue here is the task doesn’t accept input
t

Tabari Brannon

05/04/2022, 8:43 PM
ahh makes sense.
I just added a variable to it and it worked for me. Thanks for your help!
k

Kevin Kho

05/04/2022, 8:45 PM
Sure!