<#3229 Add ability to specify default resource req...
# flyte-github
c
#3229 Add ability to specify default resource requests/limits for tasks via
pyflyte run
and
pyflyte register
Pull request opened by redartera ## Why are the changes needed? When registering tasks with Flyte, users often need flexibility to specify resource requirements at registration time without modifying code. This is particularly useful in scenarios where: 1. Users want to test workflows with varied resource configurations 2. Teams need to quickly adjust resources for existing tasks without code changes during rapid development phases. Currently, the only options are to specify resources explicitly in task definitions or rely on cluster-level defaults, which lacks flexibility for selective overrides. ## What changes were proposed in this pull request? This PR introduces the ability to specify default resources for tasks that don't have resources explicitly defined. The implementation: 1. Adds a
default_resources
parameter to
SerializationSettings
that, if set, applies to tasks with unspecified resources 2. Implements a CLI option
--default-resources
for both
pyflyte run
and
pyflyte register
commands 3. Adds a resource specification parser that handles both request-only and request-limit specifications 4. Ensures tasks with explicitly defined resources are not overridden Example CLI usage: # Specify only requests pyflyte run --remote --default-resources 'cpu=1;mem=2Gi;gpu=1' workflow.py my_workflow # Specify both requests and limits pyflyte register --default-resources 'cpu=(0.5,1);mem=(2Gi,4Gi);gpu=1' package ## How was this patch tested? Added comprehensive unit tests: 1. Tests for the resource specification parser in
tests/flytekit/unit/interaction/test_click_types.py
2. Tests for default resource overrides in
tests/flytekit/unit/core/test_serialization.py
covering: • Regular
@task
decorators •
@dynamic
workflow tasks •
@eager
tasks •
map_task
functions 3. Integration tests for
pyflyte register
and
pyflyte run --remote
## Check all the applicable boxes • I updated the documentation accordingly. • All new and existing tests passed. • All commits are signed-off. ### Summary by Bito This PR adds a new CLI feature with '--default-resources' option to 'pyflyte run' and 'pyflyte register' commands, enabling users to specify default resource requests and limits for tasks. The implementation spans CLI commands, configuration settings, and repository functions to ensure proper propagation of default settings while preserving explicitly defined resources. These changes enhance resource management flexibility without requiring task code modifications. Unit tests added: True Estimated effort to review (1-5, lower is better): 4 flyteorg/flytekit