Skip to content

Instantly share code, notes, and snippets.

@omkar0001
Last active October 7, 2016 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omkar0001/288fe19a4dcda9c3650669641673a8b3 to your computer and use it in GitHub Desktop.
Save omkar0001/288fe19a4dcda9c3650669641673a8b3 to your computer and use it in GitHub Desktop.
Will create a config file for project. Name of the file would be trueai_config.py.
file: trueai_config.py
This file will contain all the config settings, related to the project. One of the main config settings, we will be storing
is, the elasticsearch indexes we are using. The value of the variable, depends on the environmental variable
TRUEAI_ENVIRONMENT
if getenv('TRUEAI_ENVIRONMENT', 'devel') == 'test':
ELASTICSEARCH_TRUEAI_INDEX = 'test_trueai'
else:
ELASTICSEARCH_TRUEAI_INDEX = 'trueai'
While registering a document class, to es document, we can do this.
import trueai_config as config
es_database_wrapper.register(Experiment, index=config.ELASTICSEARCH_TRUEAI_INDEX, doc_type='experiment')
Advantages of the design:
=============================
One of the main advantages of this, design is its easy to create environments and can easily isolate them. For example.
when running tests, we can set the environmental variable as test. In that way test data will be created in other index,
oother than the index used in live or dev.
@naomiaro
Copy link

This is much better than having a flag in the class function.

@pyrytakala
Copy link

potentially relevant for testing tensorflow/tensorflow#4819 (discussed 7-Oct-2016)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment