Thread
#prefect-server
    Tom Forbes

    Tom Forbes

    1 year ago
    Is there a way to get the currently defined
    Result
    class/instance for a given task within the task itself?
    Kevin Kho

    Kevin Kho

    1 year ago
    If you’re using a subclass like
    class MyTask(Task):
    , just 
    self.result
    might work.
    Tom Forbes

    Tom Forbes

    1 year ago
    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.
    Kevin Kho

    Kevin Kho

    1 year ago
    I don’t think so within the task itself because it hasn’t been instantiated yet at point.
    Tom Forbes

    Tom Forbes

    1 year ago
    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