hi, is there a recommended way of updating the res...
# ask-the-community
m
hi, is there a recommended way of updating the resources after it has been set? I am currently doing this, wondering if this is acceptable and have any unintended side effects.
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))
k
In the example that you have posted above assuming both the parts are split in the same file it should work it all depends on the module loading
My recommendation would be to make the resources as like a concertant or a module level variable
m
My recommendation would be to make the resources as like a concertant or a module level variable
how do you do this? any doc/example you can point me to?
k
@Michael Cheng Jan Kao sorry was away from the computer. So the example would be
Copy code
REQUESTS=Resources(cpu='1', mem='16Gi')
LIMITS=Resources(cpu='1', mem='16Gi')

@task(requests=REQUESTS, limts=LIMITS)
def hello_world():
    print('hello world')
and ofcourse you can use things like
Copy code
if os.environ["XYZ"] == "blah":
   REQUESTS = ...
else:
   REQUESTS = ...
m
I see, got it. Thank you 🙏
130 Views