Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement