https://prefect.io logo
Title
t

Tom Forbes

06/15/2021, 2:54 PM
Is there a way to get the currently defined
Result
class/instance for a given task within the task itself?
k

Kevin Kho

06/15/2021, 3:27 PM
If you’re using a subclass like
class MyTask(Task):
, just 
self.result
might work.
t

Tom Forbes

06/15/2021, 3:45 PM
Argh, I’m just using
@task
. Is there no way to reference the current task in the context?
Because referencing the above issue with local vs remote flows, there are use cases that need to know the result class (i.e you’re running locally or in k8s) to make a decision.
k

Kevin Kho

06/15/2021, 3:48 PM
I don’t think so within the task itself because it hasn’t been instantiated yet at point.
t

Tom Forbes

06/15/2021, 3:51 PM
so I’m using it specifically like this:
@task
def task():
    result = get_result_class_somehow()
    do_stuff(result.location)
    return result
https://github.com/PrefectHQ/prefect/discussions/4597
but it’s ok, I’ll work something out