Hi, does someone know answers to the following questions?
Is there a way to cache values in between invocations, similar how in AWS Lambda if you define an object outside the function handler, it’s cached/reused between invocations? (I tried leveraging @lru_cache but I see no cache hits). Main use case for this would be to cache oauth2 tokens which are valid for 1 hour.
Is it possible to tweak memory, vCPU & min./max. concurrency?
How are function execution environments re-used?
Is it possible to view the execution logs, maybe as internal export dataset?
To answer your question about environment reuse & caching; environments are not reused. Each execution is independent of others and have no shared state past environment creation. While there is some caching of state in the sense that some initialization and import logic may be done only once, once execution has begun that environment is considered used and will be discarded after the function completes execution.
As far as I’m aware this is the same behavior as on AWS Lambda. There are extensions that allow external caching but function executions themselves are isolated completely from each other.
For memory and timeout it is configurable through the Ontology Manager, but we do not support concurrency limits or allow CPU configuration at the moment.
Execution environments in Lambda are reused, the static initialization code is only executed once. This can be leveraged to establish connections or in my case get an oauth2 token that is reused.
We support a similar mechanism to Lambda’s snapshotting. Code in global scope will only be executed once in a warm state and will be reused on future invocations. Note that our behavior here is the same as Lambda’s – any work done in executing a function will not be available to future invocations; only work done before the function execution.
That said, because Foundry is very focused on security and data governance, during pre-execution we do not provide any user context, as the function may be executed from this state by different users with different data access permissions.
In short, initializing things like an oauth2 token is not supported at the moment.
Configuring vCPUs is on the way; the default is currently 2 vCPUs per function execution.