<#2478 [Docs] Updating a task's resources after th...
# flyte-github
a
#2478 [Docs] Updating a task's resources after they've been set Issue created by marc-union Description The doc needs to cover a recommended way to update resources for a task after the task has been defined. In this example, we can update resources in the same Python file like this:
Copy code
@task(requests=Resources(cpu="1", mem="4Gi"), limits=Resources(cpu="2", mem="32Gi"))
def hello_world():
    print('hello world')

hello_world._resources = ResourceSpec(requests=Resources(cpu='1', mem='16Gi', gpu=None, storage=None, ephemeral_storage=None), limits=Resources(cpu='2', mem='32Gi', gpu=None, storage=None, ephemeral_storage=None))
@freezing-airport-6809 recommends making the resources like a constant or a module level variable:
Copy code
REQUESTS=Resources(cpu='1', mem='16Gi')
LIMITS=Resources(cpu='1', mem='16Gi')

@task(requests=REQUESTS, limits=LIMITS)
def hello_world():
    print('hello world')
These resources constants can be customized too:
Copy code
if os.environ["XYZ"] == "blah":
   REQUESTS = ...
else:
   REQUESTS = ...
For details, see https://flyte-org.slack.com/archives/CP2HDHKE1/p1652231703319939 Are you sure this issue hasn't been raised already? ☑︎ Yes Have you read the Code of Conduct? ☑︎ Yes flyteorg/flyte