Jonas Bernhard
09/28/2020, 2:36 PMfetch_feed_for_url
and then save them with save_feed_entries
(with trigger any_successful
). However, some of the urls might not work leading to all subsequent tasks mapping over the result (and with that the flow) also failing. What I'm looking for is to map only over "successful feeds_list
entries"
feeds_list = fetch_feed_for_url.map(url=feed_urls)
save_feed_entries = save_feed_entries_to_db.map(feed=feeds_list)
2. Is it possible to initialize a task from a Task class using EnvVarSecret
? For example, creating a Task using the Task Library often requires the credentials upfront. Are all the secrets required to be available at "flow building time" to work with Task classes?
fetch_mysql = MySQLFetch(
user=EnvVarSecret("USER)
password=EnvVarSecret("PASSWORD)
)
Thanks!Kyle Moon-Wright
09/28/2020, 3:32 PMEnvVarSecret
outside of your fetch_mysql
task because ultimately secrets are also tasks and we need the value of a successful taskrun.Jonas Bernhard
09/28/2020, 6:39 PMany_successful
behavior was what I was looking for, but in fact removing it solved the problem 👍
2. Sorry, I did not quite get how I can instantiate the EnvVarSecret
in a way that can be used by task classes
Running
class SayHiToUser(Task):
def __init__(self, username, **kwargs):
self.username = username
super().__init__(**kwargs)
def run(self):
print(f"Hi {self.username}")
with Flow("EnvVar Test") as flow:
username = EnvVarSecret("NAME")
say_hi = SayHiToUser(username=username)
hi = say_hi()
flow.run()
prints "Hi <Task: NAME>"
since the class is instantiated not with the result of the EnvVarSecret
task but with the task itselfKyle Moon-Wright
09/28/2020, 7:30 PMEnvVarSecret
when instantiating your task because that value is always deferred to runtime.Kyle Moon-Wright
09/28/2020, 7:35 PMSayHiToUser
, then pass in the value of my EnvVarSecret
which is also a task whose value is defined at runtime:
class SayHiToUser(Task):
def run(self, username):
print(f"Hi {username}")
with Flow("EnvVar Test") as flow:
username = EnvVarSecret("NAME")
say_hi = SayHiToUser()
say_hi(username)
Jonas Bernhard
09/29/2020, 5:17 PM