Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23276

How to set up different sets of class methods in based on an environment variable?

$
0
0

I am developing a toy crypto project that involves training keras models and then deploying them in AWS lambda. I test the models locally and deploy them as lambda functions in AWS. Some classes are used both locally and during lambda invocation, but they have wildly different internal working. For instance, a class Asset implements current_price method, but it calls API in one case and local db in another.

I thought of using environment variables to distinguish two environments. How do I instantiate the same class with a different set of methods or different method implementations based on an environment variable? Is there a better approach to this problem? I'm writing in python.


Viewing all articles
Browse latest Browse all 23276

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>