Ben Fogelson
07/14/2020, 7:09 PMimport prefect as p
@p.task
def add_one(n):
return n + 1
@p.task
def add_two(n):
return n + 2
with p.Flow('f') as f:
a = p.Parameter('a')
b = add_one(a)
b.slug = 'my_slug'
c = add_two(a)
c.slug = 'my_slug'
f.get_tasks(slug='my_slug') # returns both tasks
f.validate(). # passesJim Crist-Harif
07/14/2020, 7:15 PMJim Crist-Harif
07/14/2020, 7:16 PMJim Crist-Harif
07/14/2020, 7:17 PMimport prefect as p
@p.task
def add_one(n):
return n + 1
@p.task
def add_two(n):
return n + 2
with p.Flow('f') as f:
a = p.Parameter('a')
b = add_one(a, task_args={"slug": "my_slug"})
c = add_two(a, task_args={"slug": "my_slug"})Jim Crist-Harif
07/14/2020, 7:34 PMslug for a task ever, since the slug is autogenerated for you. We've been thinking about deprecating and removing the slug kwarg/attribute on tasks completely, since they're never used once a task is added to a flow. I just opened an issue for this here: https://github.com/PrefectHQ/prefect/issues/2964Ben Fogelson
07/14/2020, 7:36 PMitay livni
07/14/2020, 7:36 PMtargets and merge_parameters @Chris White gave me these thoughts on slugs 2531
I wouldn't expect users to really interact with `slug`s honestly - the main purpose of a slug is to have a stable ID that allows the Prefect API to determine which Python object is undergoing state updates. Slugs are not an inherent property of tasks, they're a property of tasks within flows, hence the move away from storing them on task objects directly.
Jeremiah
slug behavior we discussed (but didn’t implement) adjusting the flow’s validate() method to check slugs. - https://github.com/PrefectHQ/prefect/pull/2531#issuecomment-626094592 Perhaps we should revisit just as a matter of hygiene; validate() is a useful method for ensuring graph integrity