flyte icon indicating copy to clipboard operation
flyte copied to clipboard

[Core feature] Access decorator attributes from within the task definition

Open pryce-turner opened this issue 1 year ago • 0 comments

Motivation: Why do you think this is important?

Being able to access attributes passed to the task decorator (e.g. CPU requests/limits) from within the task definition itself would enable more sophisticated tasks. For example, if you're running on with x threads you can pass that information to the threading parameter of the tool being called by a ShellTask. You could also have a benchmarking workflow with a number of different configs that are all automatically compiled into a report alongside the run statistics.

Goal: What should the final outcome look like, ideally?

from flytekit import current_context

num_cpu = current_context.task_config['resources']['cpu']

Describe alternatives you've considered

These things could be recorded manually but this is much more dynamic. It's possible to access these properties now but there's no easy way to do it.

Propose: Link/Inline OR Additional context

No response

Are you sure this issue hasn't been raised already?

  • [X] Yes

Have you read the Code of Conduct?

  • [X] Yes

pryce-turner avatar Feb 01 '24 21:02 pryce-turner