I'm trying to build a new generic task for working...
# ask-community
f
I'm trying to build a new generic task for working with airtable. When trying to do it, building a separate package where I have the task
Copy code
class ReadTable(Task):
    def __init__(
        self,
        # table: str = None,
        app: str = None,
        formula: str = None,
        api_key_name: str = "default_cred",
        project_id: str = "some_id",
        **kwargs: Any,
    ):
        # self.table = table
        <http://self.app|self.app> = app
        self.formula = formula
        self.api_key_name = api_key_name
        self.project_id = project_id

        super().__init__(**kwargs)

    @defaults_from_attrs("app", "formula", "api_key_name", "project_id")
    def run(
        self,
        table: str = None,
        app: str = None,
        formula: str = None,
        api_key_name: str = None,
        project_id: str = None,
    ) -> List[Any]:
        # some code
        return json.dumps(ret)
Trying to call this passing table as a
prefect.Parameter
it does not "resolve" to a string. However wrapping the call in a
Copy code
readTable = ReadTable(app="some_app_space")

@task
def wrapper(table: str) -> List[Any]:
    return readTable.run(table=table)
Then it works and
table
gets resolved correctly to its string value. Why is this? I've been looking allover for documentation.
k
Hey @Filip Lindvall, can you show me the original call with the Parameter that failed? This should work.
f
Copy code
@task
def print_plus_one(x):
    print(x)

readTable = ReadTable(app="<secret>")

with Flow(
    name="sheculde", storage=GCS(bucket="some-bucket")
) as flow:
    table = Parameter("table", default="48")

    print_plus_one(table)

    ret = readTable.run(table=table)
    print_plus_one(ret)
k
Can you try without the
.run()
? It will be called automatically inside the Flow block
Copy code
ret = readTable(table=table)
f
Will try
That did it
Okay, then it makes sense, thanks @Kevin Kho 😄
So I guess
___call___
does the unpacking and magic so that run does not have to think about it
Many thanks
k
Yep!