...
When defining a new python method on a Type, there are two ways to specify which action runtime to use. First, is to specify the n amewe specify the ActionRuntime environment with the `py` annotation. For example, consider the method 'getFileSourceSpec' in the IDXFile type in the mnistExample: https://github.com/c3aidti/mnistExample
Code Block |
---|
@py(env='idxfile')
getFileSourceSpecPreprocess: member function(serializedPreprocessor: string, preprocessFuncName: string, enableLocalClientStorage: boolean = true): !FileSourceSpec py server |
Here, we see the 'py' annotation being used with the parameter 'env'. This paramter contains the string 'idxfile'. This means the 'getFileSourceSpecPreprocess' function will be run with the 'py-idxfile' ActionRuntime Environment.
Inline Python Methods
Methods can be implemented as 'inline' (see 'Inline Methods' here: https://developer.c3.ai/docs/7.12.17/topic/methods ). In the context of Python methods, this means if you're currently executing the function from a Python context, the method will be executed in your current python context. This means if you define an inline python method which requires specific packages not normally available, the method will fail if your context doesn't have the necessary packages.