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
95016278
Commit
95016278
authored
Apr 03, 2015
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] Aysnc ok, code need to be cleaned.
parent
e3c7663f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
15 deletions
+28
-15
celery.py
gargantext_web/celery.py
+14
-5
views.py
gargantext_web/views.py
+2
-1
views_optimized.py
gargantext_web/views_optimized.py
+6
-6
corpustools.py
parsing/corpustools.py
+6
-3
No files found.
gargantext_web/celery.py
View file @
95016278
...
...
@@ -28,20 +28,29 @@ app.conf.update(
app
.
config_from_object
(
'django.conf:settings'
)
app
.
autodiscover_tasks
(
lambda
:
settings
.
INSTALLED_APPS
)
from
celery
import
shared_task
#@app.task(bind=True)
@
shared_task
def
debug_task
(
request
):
print
(
'Request: {0!r}'
.
format
(
request
))
@
app
.
task
(
bind
=
True
)
def
debug_task
(
self
):
print
(
'Request: {0!r}'
.
format
(
self
.
request
))
from
gargantext_web.db
import
*
@
shared_task
def
apply_sum
(
x
,
y
):
print
(
x
+
y
)
print
(
session
.
query
(
Node
.
name
)
.
first
())
from
celery
import
shared_task
from
parsing.corpustools
import
add_resource
,
parse_resources
,
extract_ngrams
,
compute_tfidf
@
shared_task
def
apply_workflow
(
corpus
):
def
apply_workflow
(
corpus_id
):
corpus
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
corpus_id
)
.
first
()
parse_resources
(
corpus
)
extract_ngrams
(
corpus
,
[
'title'
])
compute_tfidf
(
corpus
)
...
...
gargantext_web/views.py
View file @
95016278
...
...
@@ -46,6 +46,8 @@ from sqlalchemy import or_, func
from
gargantext_web
import
about
def
login_user
(
request
):
logout
(
request
)
username
=
password
=
''
...
...
@@ -199,7 +201,6 @@ def home_view(request):
t
=
get_template
(
'home.html'
)
user
=
request
.
user
date
=
datetime
.
datetime
.
now
()
html
=
t
.
render
(
Context
({
\
'user'
:
user
,
\
'date'
:
date
,
\
...
...
gargantext_web/views_optimized.py
View file @
95016278
...
...
@@ -144,12 +144,12 @@ def project(request, project_id):
)
# let's start the workflow
try
:
apply_workflow
(
corpus
)
# if DEBUG:
# apply_workflow(corpus)
# else:
# thread = Thread(target=apply_workflow, args=(corpus
, ), daemon=True)
#
thread.start()
if
DEBUG
is
not
True
:
apply_workflow
.
apply_async
((
corpus
.
id
,),)
else
:
#apply_workflow(corpus)
thread
=
Thread
(
target
=
apply_workflow
,
args
=
(
corpus
.
id
,
),
daemon
=
True
)
thread
.
start
()
except
Exception
as
error
:
print
(
'WORKFLOW ERROR'
)
print
(
error
)
...
...
parsing/corpustools.py
View file @
95016278
...
...
@@ -7,7 +7,7 @@ from math import log
from
gargantext_web.db
import
*
from
.parsers_config
import
parsers
as
_parsers
class
DebugTime
:
...
...
@@ -29,10 +29,13 @@ class DebugTime:
# keep all the parsers in a cache
class
Parsers
(
defaultdict
):
from
.parsers_config
import
parsers
as
_parsers
def
__init__
(
self
):
self
.
_parsers
=
_parsers
def
__missing__
(
self
,
key
):
if
key
not
in
self
.
_parsers
:
#print(self._parsers.keys())
if
key
not
in
self
.
_parsers
.
keys
():
raise
NotImplementedError
(
'No such parser: "
%
s"'
%
(
key
))
parser
=
self
.
_parsers
[
key
]()
self
[
key
]
=
parser
...
...
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