Filip Lindvall
09/08/2021, 3:35 PMclass 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
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.Kevin Kho
Filip Lindvall
09/08/2021, 4:04 PM@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)
Kevin Kho
.run()
? It will be called automatically inside the Flow block
ret = readTable(table=table)
Filip Lindvall
09/08/2021, 4:06 PMFilip Lindvall
09/08/2021, 4:07 PMFilip Lindvall
09/08/2021, 4:08 PMFilip Lindvall
09/08/2021, 4:08 PM___call___
does the unpacking and magic so that run does not have to think about itFilip Lindvall
09/08/2021, 4:09 PMKevin Kho