コード例 #1
0
import data_importer
from graph_manager import BayesianGraph

# Python2.x: Make default encoding as UTF-8
if sys.version_info.major == 2:
    reload(sys)
    sys.setdefaultencoding('UTF8')


app = Flask(__name__)
app.config.from_object('config')
CORS(app)

# Check whether schema is created or not
# populate schema if not already done
if not BayesianGraph.is_index_created():
    print("Index is not created as yet, checking schema creation")
    app.logger.info("Index is not created as yet, checking schema creation")
    if not BayesianGraph.is_schema_defined():
        print("Schema is not yet created, creating now...")
        BayesianGraph.populate_schema()
        # double check
        schema_definition_success = BayesianGraph.is_schema_defined()
        print("Double check: schema_definition_success %s" % schema_definition_success)
        if not schema_definition_success:
            raise RuntimeError("Failed to setup graph schema")
        else:
            print("Ready to serve requests")
else:
    print("Ready to serve requests")
コード例 #2
0
def test_is_index_created():
    """Test validity created index."""
    status = g.is_index_created()
    logger.info(status)
    assert status is False