Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. Will create a config file for project. Name of the file would be trueai_config.py.
  2.  
  3. file: trueai_config.py
  4. This file will contain all the config settings, related to the project. One of the main config settings, we will be storing
  5. is, the elasticsearch indexes we are using. The value of the variable, depends on the environmental variable
  6. TRUEAI_ENVIRONMENT
  7.  
  8. if getenv('TRUEAI_ENVIRONMENT', 'devel') == 'test':
  9. ELASTICSEARCH_TRUEAI_INDEX = 'test_trueai'
  10. else:
  11. ELASTICSEARCH_TRUEAI_INDEX = 'trueai'
  12.  
  13.  
  14. While registering a document class, to es document, we can do this.
  15.  
  16. import trueai_config as config
  17.  
  18. es_database_wrapper.register(Experiment, index=config.ELASTICSEARCH_TRUEAI_INDEX, doc_type='experiment')
  19.  
  20.  
  21. Advantages of the design:
  22. =============================
  23. One of the main advantages of this, design is its easy to create environments and can easily isolate them. For example.
  24. when running tests, we can set the environmental variable as test. In that way test data will be created in other index,
  25. oother than the index used in live or dev.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement