Disable memcaching

parent 9043ca26
......@@ -12,10 +12,6 @@ import pepvep
import simplejson
app = bottle.Bottle()
mc_plugin = util_common.create_memcache_plugin()
# Installs the memcache plugin
app.install(mc_plugin)
app.install(request_handler)
mounts = {
......@@ -149,7 +145,7 @@ reSlashOrNot = '<:re:/{0,1}>'
"""
@app.route('/version')
def api_version(mc):
def api_version():
import version
return str(version.__version__)
......
......@@ -27,10 +27,6 @@ BONDLENGTH_QUANTIZE_DECIMAL = Decimal("0.001")
app = bottle.Bottle()
mc_plugin = util_common.create_memcache_plugin()
# Installs the memcache plugin
app.install(mc_plugin)
# Installs the request handler plugin
app.install(request_handler)
......@@ -286,7 +282,7 @@ def get_compound_in_pdb(chem_comp_id):
@apiExample {json=./examples/success/compound_co_factors.json} apiSuccessExample Example success response JSON
"""
@app.get('/cofactors'+reSlashOrNot)
def get_compound_co_factors_api(mc):
def get_compound_co_factors_api():
response, response_status = get_compound_co_factors()
......
......@@ -29,16 +29,16 @@ for h, l in parser.items(level, raw=True):
exec(h.upper() + "=" + l)
# memcache configuration
fmt = "{host}:{port}"
port = "11211"
MEMCACHE_SERVERS = [fmt.format(host=socket.getfqdn(), port=port)]
# fmt = "{host}:{port}"
# port = "11211"
# MEMCACHE_SERVERS = [fmt.format(host=socket.getfqdn(), port=port)]
print("=" * 80)
print("Executing at %s level" % level.upper())
print("MEMCACHE_DISTRIBUTED: %s" % MEMCACHE_DISTRIBUTED)
print("MEMCACHE_SERVERS: %s" % MEMCACHE_SERVERS)
# print("MEMCACHE_DISTRIBUTED: %s" % MEMCACHE_DISTRIBUTED)
# print("MEMCACHE_SERVERS: %s" % MEMCACHE_SERVERS)
print("NEO4J_DEST_URL: %s" % NEO4J_DEST_URL)
print("OUTPUT_JSON_PATH: %s" % OUTPUT_JSON_PATH)
......
......@@ -31,10 +31,6 @@ BONDLENGTH_QUANTIZE_DECIMAL = Decimal("0.001")
list_re = r'[\s\']'
app = bottle.Bottle()
mc_plugin = util_common.create_memcache_plugin()
# Installs the memcache plugin
app.install(mc_plugin)
# Installs the request handler plugin
app.install(request_handler)
......
......@@ -19,10 +19,6 @@ from uniprot import get_uniprot_variation_api
print('[PDBE PAGES] Starting')
app = bottle.Bottle()
mc_plugin = util_common.create_memcache_plugin()
# Installs the memcache plugin
app.install(mc_plugin)
# Installs the request handler plugin
app.install(request_handler)
......
......@@ -21,10 +21,6 @@ from uniprot import get_uniprot_sequence
print('[PEPVEP] Starting')
app = bottle.Bottle()
mc_plugin = util_common.create_memcache_plugin()
# Installs the memcache plugin
app.install(mc_plugin)
# Installs the request handler plugin
app.install(request_handler)
......
......@@ -78,17 +78,17 @@ def request_handler(fn):
if kwargs[key].count(',') > 999:
bottle.response.status = 400
return simplejson.dumps({}, indent=4)
else:
# else:
# Check if it's a string and starts with '
if isinstance(kwargs[key], str) and len(kwargs[key]) and kwargs[key][0] != "'":
kwargs[key] = "'%s'" % kwargs[key]
# if isinstance(kwargs[key], str) and len(kwargs[key]) and kwargs[key][0] != "'":
# kwargs[key] = "'%s'" % kwargs[key]
# If it matches the re convert to lowercase
if key != "mc" and re_list_PDB.match(kwargs[key]):
kwargs[key] = kwargs[key].lower()
# if key != "mc" and re_list_PDB.match(kwargs[key]):
# kwargs[key] = kwargs[key].lower()
mc = None
# mc = None
output = None
# Check if call needs to check for static files
......@@ -109,33 +109,33 @@ def request_handler(fn):
pass
# If the call requests caching
if bottle.request.method == 'GET' and kwargs.get("mc") is not None:
mc = kwargs["mc"]
# if bottle.request.method == 'GET' and kwargs.get("mc") is not None:
# mc = kwargs["mc"]
cache_url = urlsplit(bottle.request.url).path
# cache_url = urlsplit(bottle.request.url).path
if cache_url[-1] != "/":
cache_url += "/"
# if cache_url[-1] != "/":
# cache_url += "/"
try:
output = mc.get(cache_url)
bottle.response.status = mc.get(cache_url + "_status")
except Exception as e:
pass
# try:
# output = mc.get(cache_url)
# bottle.response.status = mc.get(cache_url + "_status")
# except Exception as e:
# pass
# Caching is not active
if not output:
output = fn(*args, **kwargs)
if bottle.request.method == 'GET' and mc:
try:
# to overcome key-size < 250 issue, can't set it in ctor :-o
mc.set(cache_url, output)
# save the status code in the cache
mc.set(cache_url + "_status", bottle.response.status)
except Exception as e:
pass
# if bottle.request.method == 'GET' and mc:
# try:
# # to overcome key-size < 250 issue, can't set it in ctor :-o
# mc.set(cache_url, output)
# # save the status code in the cache
# mc.set(cache_url + "_status", bottle.response.status)
# except Exception as e:
# pass
if len(output) == 0:
bottle.response.status = 404
......
......@@ -22,9 +22,6 @@ print('[RESIDUE] Starting')
app = bottle.Bottle()
mc_plugin = util_common.create_memcache_plugin()
app.install(mc_plugin)
app.install(request_handler)
graph = neo4j_model.get_neo4j_instance()
......
......@@ -21,9 +21,6 @@ print('[SIFTS] Starting')
app = bottle.Bottle()
mc_plugin = util_common.create_memcache_plugin()
app.install(mc_plugin)
app.install(request_handler)
graph = neo4j_model.get_neo4j_instance()
......
......@@ -41,10 +41,6 @@ POOL_MAX_WORKERS = 10
ALLOWED_OVERLAP_PERCENT_BEST_STRUCTURE = 30
app = bottle.Bottle()
mc_plugin = util_common.create_memcache_plugin()
# Installs the memcache plugin
app.install(mc_plugin)
# Installs the request handler plugin
app.install(request_handler)
......
#!/usr/bin/env python
import bottle
from bottle.ext import memcache as bottle_memcache
# import memcache as bottle_memcache
import config
from amino_acid_codes import amino_acid_codes, amino_acid_codes_one_to_three
......@@ -11,11 +10,11 @@ PEPVEP_RECORD_LIMIT = 10
PEPVEP_POSITION_LIMIT = 20
def create_memcache_plugin():
return bottle_memcache.MemcachePlugin(
servers=config.MEMCACHE_SERVERS,
server_max_value_length=1024 * 1024 * 128
)
# def create_memcache_plugin():
# return bottle_memcache.MemcachePlugin(
# servers=config.MEMCACHE_SERVERS,
# server_max_value_length=1024 * 1024 * 128
# )
def split_nonconsecutive_residues(list_of_tuples):
......
......@@ -27,10 +27,6 @@ print('[VALIDATION] Starting')
list_re = r'[\s\']'
app = bottle.Bottle()
mc_plugin = util_common.create_memcache_plugin()
# Installs the memcache plugin
app.install(mc_plugin)
# Installs the request handler plugin
app.install(request_handler)
......
......@@ -17,16 +17,18 @@ echo "Setting up ${environment} environment"
CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Creating Python environment"
if [[ $environment == 'local' ]]; then
python3 -m venv $CURR_DIR/venv
else
python3.6 -m venv $CURR_DIR/venv
fi
# if [[ $environment == 'local' ]]; then
# python3 -m venv $CURR_DIR/venv
# else
# python3.6 -m venv $CURR_DIR/venv
# fi
if [[ $environment == 'dev' ]]; then
git checkout development
fi
python3 -m venv $CURR_DIR/venv
source $CURR_DIR/venv/bin/activate
echo "Upgrade pip and setuptools"
......@@ -40,8 +42,6 @@ fi
echo "Install project specific Python modules"
pip install -r $CURR_DIR/requirements.txt
easy_install bottle_memcache
if [[ $environment != 'local' ]]; then
echo "Cloning pdbe-graph-api-config to get config"
git clone git@gitlab.ebi.ac.uk:pdbe-kb/pdbe-graph-api-config.git
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment