Skip to content

Commit

Permalink
Version 1.2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
filak committed Mar 25, 2019
1 parent 957f966 commit 112e6b0
Show file tree
Hide file tree
Showing 27 changed files with 139,978 additions and 137 deletions.
3 changes: 1 addition & 2 deletions flask-app/!!build__mtw-server-win-service.bat
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ echo rem call %targetDir%\%fileHandle%.exe stop
echo.
echo Building %srcFile% ...

rem CALL c:\Python37\Scripts\pyinstaller.exe --log-level ERROR --onedir -y --hidden-import=_cffi_backend --distpath %targetDir% %srcFile% >> %logFile% 2>&1
CALL c:\Python37\Scripts\pyinstaller.exe --log-level ERROR --onefile --hidden-import=_cffi_backend --distpath %targetDir% %srcFile% >> %logFile% 2>&1
CALL c:\Python37\Scripts\pyinstaller.exe --log-level ERROR --onefile --hidden-import=_cffi_backend --add-data mtw_utils/pyuca/*.txt;pyuca --distpath %targetDir% %srcFile% >> %logFile% 2>&1

echo - Done!
echo.
Expand Down
3 changes: 1 addition & 2 deletions flask-app/!!build__mtw-server-win-worker.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ echo rem call %targetDir%\%fileHandle%.exe stop
echo.
echo Building %srcFile% ...

rem CALL c:\Python37\Scripts\pyinstaller.exe --log-level ERROR --onedir -y --distpath %targetDir% %srcFile% >> %logFile% 2>&1
CALL c:\Python37\Scripts\pyinstaller.exe --log-level ERROR --onefile --distpath %targetDir% %srcFile% >> %logFile% 2>&1
CALL c:\Python37\Scripts\pyinstaller.exe --log-level ERROR --onefile --add-data mtw_utils/pyuca/*.txt;pyuca --distpath %targetDir% %srcFile% >> %logFile% 2>&1

echo - Done!

Expand Down
1 change: 0 additions & 1 deletion flask-app/!!build__set-mtw-admin.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ echo. > %logFile%
echo.
echo Building %srcFile% ...

rem CALL c:\Python37\Scripts\pyinstaller.exe --log-level ERROR --onedir -y --hidden-import=_cffi_backend --distpath %targetDir% %srcFile% >> %logFile% 2>&1
CALL c:\Python37\Scripts\pyinstaller.exe --log-level ERROR --onefile --hidden-import=_cffi_backend --distpath %targetDir% %srcFile% >> %logFile% 2>&1

echo.
Expand Down
4 changes: 2 additions & 2 deletions flask-app/instance/conf/mesh.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
@prefix fuseki: <http://jena.apache.org/fuseki#> .
@prefix meshv: <http://id.nlm.nih.gov/mesh/vocab#> .
@prefix mesht: <http://www.medvik.cz/schema/mesh/vocab/#> .
@prefix meshcs: <http://mesh.medvik.cz/link/> .
@prefix meshx: <http://mesh.medvik.cz/link/> .

### Version 1.0.1
### Version 1.0.2

## Initialize text query
[] ja:loadClass "org.apache.jena.query.text.TextQuery" .
Expand Down
4 changes: 2 additions & 2 deletions flask-app/instance/conf/mtw.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# *** Config version 0.1.5 ***
# *** Config version 0.1.6 ***
### Important values are marked with ! ###
### ! This file MUST BE UTF-8 encoded ! ###
### ! Restart the App after modifying ! ###
Expand Down Expand Up @@ -105,9 +105,9 @@ TARGET_NS = http://mesh.medvik.cz/link/

### Default values:
#SPARQL_HOST = http://localhost:3030/
#SPARQL_DATASET = mesh

### DO NOT EDIT BELOW THIS LINE ###
#SPARQL_DATASET = mesh

### MeSH RDF SPARQL Endpoint
#MESH_RDF = http://id.nlm.nih.gov/mesh/sparql
Expand Down
6 changes: 3 additions & 3 deletions flask-app/mtw-server-win-service.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ def run_server():
##asyncio.set_event_loop(asyncio.new_event_loop())

http_server = HTTPServer(WSGIContainer(app))
http_server.listen(SERVER_PORT)
http_server.listen( int( os.environ.get('MTW_SERVER_PORT', SERVER_PORT) ) )

IOLoop.instance().start()

def stop_server():
IOLoop.instance().stop()

class Service(win32serviceutil.ServiceFramework):
_svc_name_ = SERVICE_NAME
_svc_display_name_ = SERVICE_DISPLAY_NAME
_svc_name_ = SERVICE_NAME + '-' + str( os.environ.get('MTW_SERVER_PORT', SERVER_PORT) )
_svc_display_name_ = SERVICE_DISPLAY_NAME + ' - port:' + str( os.environ.get('MTW_SERVER_PORT', SERVER_PORT) )
_svc_description_ = SERVICE_DESCRIPTION

def __init__(self, *args, **kwargs):
Expand Down
6 changes: 3 additions & 3 deletions flask-app/mtw-server-win-worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ def run_server():
app.template_folder = os.path.join(os.path.dirname(sys.executable), 'templates')

http_server = HTTPServer(WSGIContainer(app))
http_server.listen(SERVER_PORT)
http_server.listen( int( os.environ.get('MTW_WORKER_PORT', SERVER_PORT) ) )

IOLoop.instance().start()

def stop_server():
IOLoop.instance().stop()

class Service(win32serviceutil.ServiceFramework):
_svc_name_ = SERVICE_NAME
_svc_display_name_ = SERVICE_DISPLAY_NAME
_svc_name_ = SERVICE_NAME + '-' + str( os.environ.get('MTW_WORKER_PORT', SERVER_PORT) )
_svc_display_name_ = SERVICE_DISPLAY_NAME + ' - port:' + str( os.environ.get('MTW_WORKER_PORT', SERVER_PORT) )
_svc_description_ = SERVICE_DESCRIPTION

def __init__(self, *args, **kwargs):
Expand Down
12 changes: 6 additions & 6 deletions flask-app/mtw/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __call__(self, environ, start_response):

app.config.update(dict(
APP_NAME = 'MTW',
APP_VER = '1.2.7',
APP_VER = '1.2.8',
API_VER = '1.0.0',
APP_URL = '/mtw',
DEFAULT_THEME = 'slate',
Expand Down Expand Up @@ -1244,8 +1244,8 @@ def manage(action):
### YYYY_lookups.json.gz
exports['lookups'] = mtu.getStatsFpath('lookups', ext='json.gz')

### YYYY_lookups_notes.json.gz
exports['lookups_notes'] = mtu.getStatsFpath('lookups_notes', ext='json.gz')
### YYYY_lookups_rest.json.gz
exports['lookups_rest'] = mtu.getStatsFpath('lookups_rest', ext='json.gz')

### YYYY_js_all.json.gz
exports['js_all'] = mtu.getStatsFpath('js_all', ext='json.gz')
Expand Down Expand Up @@ -1284,8 +1284,8 @@ def manage(action):
show_lookups_exports = True

show_marc_exports = False
lookups_notes = mtu.getTempFpath('lookups_notes')
if lookups_notes.is_file():
lookups_rest = mtu.getTempFpath('lookups_rest')
if lookups_rest.is_file():
show_marc_exports = True

lpath = mtu.getLockFpath('stats')
Expand Down Expand Up @@ -1328,7 +1328,7 @@ def update_stats(stat):
flash(msg, 'warning')
return render_template('errors/error_page.html', errcode=403, error=msg), 403

if stat not in ('initial','actual','umls','lookups','lookups_notes','js_all','js_elastic','xml_desc','xml_qualif','marc'):
if stat not in ('initial','actual','umls','lookups','lookups_rest','js_all','js_elastic','xml_desc','xml_qualif','marc'):
msg = 'Unknown params for update_stats'
flash(msg, 'danger')
return render_template('errors/error_page.html', errcode=404, error=msg), 404
Expand Down
23 changes: 13 additions & 10 deletions flask-app/mtw/templates/manage.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ <h5>Initial stats </h5>

<ul class="list-inline mb-2">
<li class="list-inline-item mt-2">
<h4>Exports <small class="text-warning">Always do Checks before exports!</small></h4>
<h4>Exports <small class="text-warning">Always do Checks before!</small></h4>
</li>
<li class="list-inline-item float-right">
</li>
Expand Down Expand Up @@ -154,10 +154,10 @@ <h5>UMLS TSV</h5>

<div class="row mb-4">
<div class="col">
<h5>Base &amp; Notes<small class="text-success"> [generate to enable more exports]</small></h5>
<h5>Base Exports<small class="text-success"> [generate to enable more exports]</small></h5>
<form action="{{ url_for('update_stats', stat='lookups') }}" method="post">
<input type="hidden" name="_csrf_token" value="{{ csrf_token() }}">
<button class="btn btn-sm btn-success mb-2" type="submit" title="Create export Base file (JSON)" {{ export_disabled }}>
<button class="btn btn-sm btn-success mb-2" type="submit" title="Create Base-export file (JSON)" {{ export_disabled }}>
Generate Base
</button>

Expand All @@ -173,14 +173,14 @@ <h5>Base &amp; Notes<small class="text-success"> [generate to enable more export

</form>

<form action="{{ url_for('update_stats', stat='lookups_notes') }}" method="post">
<form action="{{ url_for('update_stats', stat='lookups_rest') }}" method="post">
<input type="hidden" name="_csrf_token" value="{{ csrf_token() }}">
<button class="btn btn-sm btn-success mb-2" type="submit" title="Create export Notes file (JSON)" {{ export_disabled }}>
Generate Notes
<button class="btn btn-sm btn-success mb-2" type="submit" title="Create Base-rest file (JSON)" {{ export_disabled }}>
Generate Rest
</button>

{% if exports['lookups_notes'] %}
{% set file = exports['lookups_notes'] %}
{% if exports['lookups_rest'] %}
{% set file = exports['lookups_rest'] %}
<p class="mb-1">
[{{ file['fdate'] }}]
<a href="{{ url_for('download', fname=file['fname']) }}" title="Download file" target="_blank">
Expand Down Expand Up @@ -241,11 +241,11 @@ <h5>Settings</h5>
<div class="form-group mb-2">
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="radioMarcTreeDef" name="tree_style" value="def" class="custom-control-input" {{ def_checked }}>
<label class="custom-control-label" for="radioMarcTreeDef">Default tree (field 072)</label>
<label class="custom-control-label" for="radioMarcTreeDef">Default tree (fld 072)</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="radioMarcTreeCustom" name="tree_style" value="daw" class="custom-control-input" {{ daw_checked }}>
<label class="custom-control-label" for="radioMarcTreeCustom">Custom tree (field 686)</label>
<label class="custom-control-label" for="radioMarcTreeCustom">Custom tree (fld 686)</label>
</div>
</div>

Expand Down Expand Up @@ -342,6 +342,8 @@ <h5>JSON <small class="text-info">for Javascript</small></h5>
<div class="row mb-4">
<div class="col">
<h5>JSON <small class="text-info">for Elastic</small></h5>

{% if show_marc %}
<form action="{{ url_for('update_stats', stat='js_elastic') }}" method="post">
<input type="hidden" name="_csrf_token" value="{{ csrf_token() }}">

Expand All @@ -364,6 +366,7 @@ <h5>JSON <small class="text-info">for Elastic</small></h5>
{% endif %}

</form>
{% endif %}
</div>
</div>

Expand Down
5 changes: 2 additions & 3 deletions flask-app/mtw/templates/modals/edit-concept.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,10 @@ <h4 class="modal-title">

<button type="button" class="btn btn-link ml-3" data-dismiss="modal">Close</button>

{% if item['active'] == 'false' %}
<!-- set submit_inactive = 'disabled' -->
{% if item['active'] == 'false' and item['lang'] == config.TARGET_LANG and item['lang'] != 'en' %}
{% set submit_inactive = 'disabled' %}
{% endif %}


{% if session.ugroup in ('admin','manager','editor','contributor') and not isDbLocked() %}
{% if descriptor.get('lockedBy','') %}
{% if getLockedBy(session.userid, session.uname) == descriptor.get('lockedBy','') %}
Expand Down
1 change: 0 additions & 1 deletion flask-app/mtw/templates/sparql/concepts_terms.sparql
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
## Descriptor query v1.0
## endpoint: http://localhost:3030/mesh/query

{% include 'sparql/_namespaces.sparql' %}

Expand Down
22 changes: 4 additions & 18 deletions flask-app/mtw/templates/sparql/exports/lookups_base.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ SELECT ?dui ?cui ?dtype ?den ?trx ?notrx ?active ?crt ?nlm ?rn ?cas
(GROUP_CONCAT(DISTINCT ?bd ; separator='~') AS ?btd)
(GROUP_CONCAT(DISTINCT ?nd ; separator='~') AS ?ntd)
(GROUP_CONCAT(DISTINCT ?rd ; separator='~') AS ?rtd)
(GROUP_CONCAT(DISTINCT ?term ; separator='~') AS ?terms)
(GROUP_CONCAT(DISTINCT ?xterm ; separator='~') AS ?xterms)
WHERE {
?d rdf:type ?dtype .
FILTER(?dtype IN(meshv:TopicalDescriptor,meshv:GeographicalDescriptor,meshv:PublicationType,meshv:CheckTag,meshv:Qualifier))
Expand All @@ -18,29 +16,17 @@ WHERE {
?d meshv:dateCreated ?crt .
OPTIONAL {
?d meshv:treeNumber ?tree .
?tree rdfs:label ?trns .
?tree meshv:active ?activetrn .
FILTER(?activetrn)
?tree rdfs:label ?trns
}
?d meshv:preferredConcept ?c .
?c meshv:identifier ?cui .
?c meshv:preferredTerm ?t .
?t meshv:prefLabel ?den .
OPTIONAL {
?c mesht:preferredTerm ?tp .
?tp mesht:prefLabel ?trx .
}
OPTIONAL {
?c meshv:term|mesht:term ?ptt .
?ptt meshv:prefLabel|mesht:prefLabel ?term .
}
OPTIONAL {
?d meshv:concept ?ct .
?ct meshv:preferredTerm|meshv:term ?tt .
?tt meshv:prefLabel ?xterm .
}
OPTIONAL {
?d mesht:concept ?ctt .
?ctt mesht:preferredTerm|mesht:term ?ttt .
?ttt mesht:prefLabel ?xterm .
?tp mesht:prefLabel ?trx
}
OPTIONAL {
?d meshv:broaderDescriptor ?bdx .
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Base export query v1.0
## Base allowed qualifs export query v1.0

{% include 'sparql/_namespaces.sparql' %}

Expand All @@ -7,8 +7,12 @@ SELECT ?dui
WHERE {
?d rdf:type ?dtype .
FILTER(?dtype IN(meshv:TopicalDescriptor,meshv:GeographicalDescriptor,meshv:PublicationType,meshv:CheckTag))
?d meshv:active ?actived .
FILTER(?actived)
?d meshv:identifier ?dui .
?d meshv:allowableQualifier ?q .
?q meshv:active ?activeq .
FILTER(?activeq)
?q meshv:identifier ?qui
}
GROUP BY ?dui
Expand Down
1 change: 0 additions & 1 deletion flask-app/mtw/templates/sparql/exports/umls.sparql
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
## UMLS export query v1.0
## endpoint: http://localhost:3030/mesh/query

{% include 'sparql/_namespaces.sparql' %}

Expand Down
1 change: 0 additions & 1 deletion flask-app/mtw/templates/sparql/tree-browse.sparql
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
## Browse query v1.0 - always with a treeNumber prefix !
## endpoint: http://localhost:3030/mesh/query

## Preferred concepts AKA descriptors

Expand Down
1 change: 0 additions & 1 deletion flask-app/mtw/templates/sparql/tree.sparql
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
## Tree display query v1.0
## endpoint: http://localhost:3030/mesh/query

{% include 'sparql/_namespaces.sparql' ignore missing %}

Expand Down
2 changes: 1 addition & 1 deletion flask-app/mtw/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def hello_world():
@app.route('/refresh_stats/get:<stat>', methods=['GET','POST'])
def refresh_stats(stat):

if stat in ('initial','actual','all','duplicates','lookups','lookups_notes'):
if stat in ('initial','actual','all','duplicates','lookups','lookups_rest'):

app.logger.info('Stats gen started ...')
mtu.refreshStats(stat)
Expand Down
1 change: 1 addition & 0 deletions flask-app/mtw_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Flask==1.0.2
Flask_SeaSurf==0.2.2
flask_talisman==0.6.0
Jinja2==2.10
pyuca==1.2
requests==2.20.0
requests_futures==0.9.8
bcrypt==3.1.4 # NOT python-bcrypt !!!
Expand Down
4 changes: 2 additions & 2 deletions flask-app/mtw_sparql/mtw_sparql.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def getSparqlData(template, query='', show='', status='', top='', tn='', concept
out = {}

try:
with closing(requests.post(endpoint, headers=headers, data=sparql.encode('utf-8'), timeout=300) ) as r:
with closing(requests.post(endpoint, headers=headers, data=sparql.encode('utf-8'), timeout=600) ) as r:
if r.status_code == 200:
if output == 'json':
return r.json()
Expand Down Expand Up @@ -219,7 +219,7 @@ def parseSparqlStats(data, template):

metadata['hits_cnt'] = hits_cnt

elif template in ('lookups_base','lookups_notes','lookups_qualifs'):
elif template in ('lookups_base','lookups_terms','lookups_notes','lookups_qualifs'):
metadata['data'] = []
items = data['head']['vars']
for row in data['results']['bindings']:
Expand Down
Loading

0 comments on commit 112e6b0

Please sign in to comment.