Hamed Sheykhlou
12/09/2020, 8:48 AMimport requests
from prefect import Flow, task
from prefect.engine.results import SecretResult
@task(name='extract_task')
def extract():
res = requests.get('<https://jsonplaceholder.typicode.com/todos/1>')
res_txt = res.text
print(res_txt)
return res_txt
@task()
def load():
"""Print the data to indicate it was received"""
print(SECRET_RESULT.location)
res_txt = SECRET_RESULT.read('secret1')
print("Here's your data: {}".format(res_txt))
with Flow("Callback-Example") as flow:
SECRET_RESULT = SecretResult(extract, location='somewhere.json')
e = extract()
l = load()
l.set_upstream(e)
flow.run()
but when I run it, gave some error on prefect source:
File "/home/hamed/PycharmProjects/etlprefectcloud/venv/lib/python3.8/site-packages/prefect/engine/results/secret_result.py", line 38, in read
new.value = self.secret_task.run(name=location)
TypeError: extract() got an unexpected keyword argument 'name'
its on prefect/engine/results/secret_result.py
line 38: new.value = self.secret_task.run(name=location)
. and if I delete the name argumans, it works.
am I using the SecretResult wrong way?Sébastien
12/09/2020, 12:01 PMSecret
https://docs.prefect.io/core/concepts/secrets.html#local-context
SecretResult
looks like it's only meant to be a return type — not something you create yourself.Hamed Sheykhlou
12/09/2020, 2:16 PM