Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TextGrid FCS Endpoint
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Textplus
TextPlus Collections
TextGrid FCS Endpoint
Commits
2664c739
Verified
Commit
2664c739
authored
1 year ago
by
Ubbo Veentjer
Browse files
Options
Downloads
Patches
Plain Diff
feat: configure textgrid host from env, reuse tgsearch client
parent
fc1f6899
No related branches found
No related tags found
No related merge requests found
Pipeline
#442599
passed
1 year ago
Stage: build
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/tg-fcs-endpoint/service.py
+12
-3
12 additions, 3 deletions
src/tg-fcs-endpoint/service.py
with
12 additions
and
3 deletions
src/tg-fcs-endpoint/service.py
+
12
−
3
View file @
2664c739
...
...
@@ -3,6 +3,7 @@
# SPDX-License-Identifier: MIT
from
typing
import
Any
,
Dict
,
List
,
Optional
,
Union
from
os
import
getenv
import
logging
from
flask
import
Flask
,
Response
,
request
...
...
@@ -17,7 +18,8 @@ from clarin.sru.fcs.xml.writer import FCSRecordXMLStreamWriter
from
clarin.sru.exception
import
SRUException
from
tgclients
import
TextgridSearch
from
tgclients
import
TextgridSearch
,
TextgridConfig
from
tgclients.config
import
PROD_SERVER
from
tgclients.databinding.tgsearch
import
(
Response
as
SearchResponse
,
ResultType
,
...
...
@@ -56,6 +58,14 @@ MIMETYPE_TEI_XML = "application/x-tei+xml"
logger
=
logging
.
getLogger
(
__name__
)
app
=
Flask
(
__name__
)
# config textgrid server urls from env
TEXTGRID_HOST
=
getenv
(
'
TEXTGRID_HOST
'
,
PROD_SERVER
)
TGREP_HOST
=
getenv
(
'
TGREP_HOST
'
,
'
https://textgridrep.org
'
)
# only instantiate tgsearch once globally, for connection and databinding reuse
tgconf
=
TextgridConfig
(
TEXTGRID_HOST
)
tgsearch
=
TextgridSearch
(
tgconf
)
def
_cql2cqp
(
query
:
CQLQuery
)
->
str
:
node
:
Union
[
cql
.
parser
.
CQLTriple
,
cql
.
parser
.
CQLSearchClause
]
=
(
...
...
@@ -212,8 +222,7 @@ class TgFCSEndpointSearchEngine(SimpleEndpointSearchEngineBase):
# print("search within project: ", request.request.tg_project_id)
project_filter
=
f
"
project.id:
{
request
.
request
.
tg_project_id
}
"
search
=
TextgridSearch
()
results
=
search
.
search
(
results
=
tgsearch
.
search
(
query
,
limit
=
request
.
get_maximum_records
(),
start
=
request
.
get_start_record
(),
...
...
This diff is collapsed.
Click to expand it.
Ubbo Veentjer
@uveentj
mentioned in merge request
!1 (closed)
·
1 year ago
mentioned in merge request
!1 (closed)
mentioned in merge request !1
Toggle commit list
Ubbo Veentjer
@uveentj
mentioned in issue
#1 (closed)
·
1 year ago
mentioned in issue
#1 (closed)
mentioned in issue #1
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment