Beispiel #1
0
# 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")


@app.route('/api/v1/readiness')
def readiness():
def test_is_schema_defined():
    """Test if schema was initialized correctly."""
    status = g.is_schema_defined()
    logger.info(status)
    assert status is True