-
I am working on writing two ConfigSource plugins; one for AWS Secrets Manager and Weights and Biases. I was able to get these plugins working, but I noticed that they are run twice by Hydra. These plugins are quite slow compared to the file system plugins Hydra ships with, since they make network calls. Is there any way to only run these plugins during the main hydra configuration loading and not run them the first time? Checking the source, it appears the first time it is called is during 'get_mode' hydra/hydra/_internal/hydra.py Lines 81 to 96 in 2f76287 However, this is only to get the Is there is a way to specify ConfigSource plugins do not support this value to avoid running it twice? This would significantly speed up the time it takes to start the application. edit: I guess its not a significant speed-up if local caching is used but its awkward to explain why it is happening to devs and work around from inside the plugin. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Not sure, but maybe you can use a cache in your plugins so that the second call is much faster? |
Beta Was this translation helpful? Give feedback.
Its okay. I added in memory caching to my plugins and have gotten the second execution down to 200ms. I think this will be good enough.
Wanted to have the cache to be static to survive plugin deletion so I used a global decorator. I've included the code snippet below in case someone else has the same issue.
could be improved as a class-level annotation. i also am not sure if it needs to be global or if defining it in
aws_secrets_manager_global_cache
would work.