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
c862a29b
Commit
c862a29b
authored
Apr 02, 2015
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TESTS] celery.
parent
baff376c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
10 deletions
+71
-10
celery.py
gargantext_web/celery.py
+49
-0
settings.py
gargantext_web/settings.py
+1
-1
tasks.py
gargantext_web/tasks.py
+13
-0
views_optimized.py
gargantext_web/views_optimized.py
+8
-9
No files found.
gargantext_web/celery.py
0 → 100644
View file @
c862a29b
# -*- coding: utf-8 -*-
import
os
import
djcelery
from
celery
import
Celery
from
django.conf
import
settings
# set the default Django settings module for the 'celery' program.
os
.
environ
.
setdefault
(
'DJANGO_SETTINGS_MODULE'
,
'gargantext_web.settings'
)
app
=
Celery
(
'gargantext_web'
)
app
.
conf
.
update
(
CELERY_RESULT_BACKEND
=
'djcelery.backends.database:DatabaseBackend'
,
)
app
.
conf
.
update
(
CELERY_RESULT_BACKEND
=
'djcelery.backends.cache:CacheBackend'
,
)
# Using a string here means the worker will not have to
# pickle the object when using Windows.
app
.
config_from_object
(
'django.conf:settings'
)
app
.
autodiscover_tasks
(
lambda
:
settings
.
INSTALLED_APPS
)
@
app
.
task
(
bind
=
True
)
def
debug_task
(
self
):
print
(
'Request: {0!r}'
.
format
(
self
.
request
))
from
celery
import
shared_task
from
parsing.corpustools
import
add_resource
,
parse_resources
,
extract_ngrams
,
compute_tfidf
@
shared_task
def
apply_workflow
(
corpus
):
parse_resources
(
corpus
)
extract_ngrams
(
corpus
,
[
'title'
])
compute_tfidf
(
corpus
)
gargantext_web/settings.py
View file @
c862a29b
...
...
@@ -17,7 +17,7 @@ PROJECT_PATH = os.path.abspath(PROJECT_PATH)
import
djcelery
djcelery
.
setup_loader
()
BROKER_URL
=
'amqp://guest:guest@localhost:5672/'
CELERY_IMPORTS
=
(
"node.models"
,)
CELERY_IMPORTS
=
(
"node.models"
,
"gargantext_web"
)
# Quick-start development settings - unsuitable for production
...
...
gargantext_web/tasks.py
0 → 100644
View file @
c862a29b
from
celery
import
shared_task
from
parsing.corpustools
import
add_resource
,
parse_resources
,
extract_ngrams
,
compute_tfidf
@
shared_task
def
apply_workflow
(
corpus
):
parse_resources
(
corpus
)
extract_ngrams
(
corpus
,
[
'title'
])
compute_tfidf
(
corpus
)
gargantext_web/views_optimized.py
View file @
c862a29b
...
...
@@ -18,6 +18,8 @@ import json
from
parsing.corpustools
import
add_resource
,
parse_resources
,
extract_ngrams
,
compute_tfidf
from
gargantext_web.celery
import
apply_workflow
def
project
(
request
,
project_id
):
# SQLAlchemy session
...
...
@@ -142,15 +144,12 @@ def project(request, project_id):
)
# let's start the workflow
try
:
def
apply_workflow
(
corpus
):
parse_resources
(
corpus
)
extract_ngrams
(
corpus
,
[
'title'
])
compute_tfidf
(
corpus
)
if
DEBUG
:
apply_workflow
(
corpus
)
else
:
thread
=
Thread
(
target
=
apply_workflow
,
args
=
(
corpus
,
),
daemon
=
True
)
thread
.
start
()
# if DEBUG:
# apply_workflow(corpus)
# else:
# thread = Thread(target=apply_workflow, args=(corpus, ), daemon=True)
# thread.start()
except
Exception
as
error
:
print
(
'WORKFLOW ERROR'
)
print
(
error
)
...
...
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