Skip to content

Sequential Tasks using Task Class Inheritance #4028

Answered by zanieb
taylorfturner asked this question in Q&A
Discussion options

You must be logged in to vote

Hi! Your primary problem is that you're calling task.run() directly which is only for testing tasks. You build the flow by calling tasks objects e.g. my_task(arg, arg) and then task.run() is called by the executor at runtime. Here's an annotated and working version of your code

from prefect import Flow, Task, Parameter
import pandas as pd
import numpy as np


class DataReader(Task):
    def _read_dask(self):
        df = pd.DataFrame(np.random.randn(100, 4), columns=list("ABCD"))
        # return dd.from_pandas(df, npartitions=3)
        # I'm just doing this because I don't want to install dask dataframe
        return df

    def _read_pandas(self):
        raise NotImplementedError

    

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@taylorfturner
Comment options

Answer selected by taylorfturner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants