Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
e390703a
Commit
e390703a
authored
Feb 24, 2017
by
delanoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] SQL POOL: closing after executed.
parent
00949019
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
4 deletions
+16
-4
db.py
gargantext/util/db.py
+2
-0
metric_tfidf.py
gargantext/util/toolchain/metric_tfidf.py
+2
-1
ngram_coocs.py
gargantext/util/toolchain/ngram_coocs.py
+12
-3
No files found.
gargantext/util/db.py
View file @
e390703a
...
@@ -171,3 +171,5 @@ def bulk_insert_ifnotexists(model, uniquekey, fields, data, cursor=None, do_stat
...
@@ -171,3 +171,5 @@ def bulk_insert_ifnotexists(model, uniquekey, fields, data, cursor=None, do_stat
cursor
.
execute
(
'COMMIT WORK;'
)
cursor
.
execute
(
'COMMIT WORK;'
)
cursor
.
close
()
gargantext/util/toolchain/metric_tfidf.py
View file @
e390703a
...
@@ -177,6 +177,7 @@ def compute_ti_ranking(corpus,
...
@@ -177,6 +177,7 @@ def compute_ti_ranking(corpus,
- overwrite_id: optional id of a pre-existing XXXX node for this corpus
- overwrite_id: optional id of a pre-existing XXXX node for this corpus
(the Node and its previous Node NodeNgram rows will be replaced)
(the Node and its previous Node NodeNgram rows will be replaced)
"""
"""
print
(
"compute_ti_ranking"
)
# validate string params
# validate string params
if
count_scope
not
in
[
"local"
,
"global"
]:
if
count_scope
not
in
[
"local"
,
"global"
]:
raise
ValueError
(
"compute_ti_ranking: count_scope param allowed values: 'local', 'global'"
)
raise
ValueError
(
"compute_ti_ranking: count_scope param allowed values: 'local', 'global'"
)
...
@@ -371,7 +372,7 @@ def compute_ti_ranking(corpus,
...
@@ -371,7 +372,7 @@ def compute_ti_ranking(corpus,
# TODO 2 release these 2 typenames TFIDF-CORPUS and TFIDF-GLOBAL
# TODO 2 release these 2 typenames TFIDF-CORPUS and TFIDF-GLOBAL
# TODO 3 recreate them elsewhere in their sims (WeightedIndex) version
# TODO 3 recreate them elsewhere in their sims (WeightedIndex) version
# TODO 4 requalify this here as a NodeNgram
# TODO 4 requalify this here as a NodeNgram
#
then TODO 5 use WeightedList.save() !
#
TODO 5 use WeightedList.save()
# reflect that in NodeNodeNgrams
# reflect that in NodeNodeNgrams
bulk_insert
(
bulk_insert
(
...
...
gargantext/util/toolchain/ngram_coocs.py
View file @
e390703a
...
@@ -3,7 +3,7 @@ COOCS
...
@@ -3,7 +3,7 @@ COOCS
(this is the full SQL version, should be more reliable on outerjoin)
(this is the full SQL version, should be more reliable on outerjoin)
"""
"""
from
gargantext
import
settings
from
gargantext
import
settings
from
sqlalchemy
import
create_engine
from
sqlalchemy
import
create_engine
,
exc
from
gargantext.util.lists
import
WeightedMatrix
from
gargantext.util.lists
import
WeightedMatrix
# from gargantext.util.db import session, aliased, func
# from gargantext.util.db import session, aliased, func
from
gargantext.util.db_cache
import
cache
from
gargantext.util.db_cache
import
cache
...
@@ -223,10 +223,19 @@ def compute_coocs( corpus,
...
@@ -223,10 +223,19 @@ def compute_coocs( corpus,
# 6) EXECUTE QUERY
# 6) EXECUTE QUERY
# ----------------
# ----------------
# debug
# debug
print
(
final_sql
)
#
print(final_sql)
# executing the SQL statement
# executing the SQL statement
results
=
connection
.
execute
(
final_sql
)
try
:
# suppose the database has been restarted.
results
=
connection
.
execute
(
final_sql
)
connection
.
close
()
except
exc
.
DBAPIError
as
e
:
# an exception is raised, Connection is invalidated.
if
e
.
connection_invalidated
:
print
(
"Connection was invalidated for ngram_coocs"
)
else
:
print
(
e
)
# => storage in our matrix structure
# => storage in our matrix structure
matrix
=
WeightedMatrix
(
results
)
matrix
=
WeightedMatrix
(
results
)
...
...
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