Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
P
pdbe-graph-api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
pdbe-kb
services
pdbe-graph-api
Commits
45df1917
Commit
45df1917
authored
Aug 26, 2020
by
Sreenath Sasidharan Nair
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable memcaching
parent
9043ca26
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
44 additions
and
79 deletions
+44
-79
app/app.py
app/app.py
+1
-5
app/compound.py
app/compound.py
+1
-5
app/config.py
app/config.py
+5
-5
app/pdb.py
app/pdb.py
+0
-4
app/pdbe_pages.py
app/pdbe_pages.py
+0
-4
app/pepvep.py
app/pepvep.py
+0
-4
app/plugins.py
app/plugins.py
+25
-25
app/residue.py
app/residue.py
+0
-3
app/sifts.py
app/sifts.py
+0
-3
app/uniprot.py
app/uniprot.py
+0
-4
app/util_common.py
app/util_common.py
+5
-6
app/validation.py
app/validation.py
+0
-4
setup.sh
setup.sh
+7
-7
No files found.
app/app.py
View file @
45df1917
...
...
@@ -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__
)
...
...
app/compound.py
View file @
45df1917
...
...
@@ -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
()
...
...
app/config.py
View file @
45df1917
...
...
@@ -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
)
...
...
app/pdb.py
View file @
45df1917
...
...
@@ -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
)
...
...
app/pdbe_pages.py
View file @
45df1917
...
...
@@ -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
)
...
...
app/pepvep.py
View file @
45df1917
...
...
@@ -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
)
...
...
app/plugins.py
View file @
45df1917
...
...
@@ -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
...
...
app/residue.py
View file @
45df1917
...
...
@@ -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
()
...
...
app/sifts.py
View file @
45df1917
...
...
@@ -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
()
...
...
app/uniprot.py
View file @
45df1917
...
...
@@ -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
)
...
...
app/util_common.py
View file @
45df1917
#!/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
):
...
...
app/validation.py
View file @
45df1917
...
...
@@ -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
)
...
...
setup.sh
View file @
45df1917
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment