Commit 70d05bec authored by Administrator's avatar Administrator

[FIX] Scrapper pubmed (need to be factorized).

parent cec92777
...@@ -60,6 +60,7 @@ def apply_workflow(corpus_id): ...@@ -60,6 +60,7 @@ def apply_workflow(corpus_id):
corpus_django = models.Node.objects.get(id=corpus_id) corpus_django = models.Node.objects.get(id=corpus_id)
corpus_django.metadata['Processing'] = 0 corpus_django.metadata['Processing'] = 0
corpus_django.save() corpus_django.save()
print("-" *60)
#TODO With SLA ORM (KO why?) #TODO With SLA ORM (KO why?)
# corpus.metadata['Processing'] = 0 # corpus.metadata['Processing'] = 0
......
...@@ -34,6 +34,7 @@ from gargantext_web.api import JsonHttpResponse ...@@ -34,6 +34,7 @@ from gargantext_web.api import JsonHttpResponse
from parsing.corpustools import add_resource, parse_resources, extract_ngrams, compute_tfidf from parsing.corpustools import add_resource, parse_resources, extract_ngrams, compute_tfidf
from gargantext_web.celery import apply_workflow
def getGlobalStats(request ): def getGlobalStats(request ):
print(request.method) print(request.method)
...@@ -126,6 +127,7 @@ def doTheQuery(request , project_id): ...@@ -126,6 +127,7 @@ def doTheQuery(request , project_id):
parent_id = project_id, parent_id = project_id,
type_id = cache.NodeType['Corpus'].id, type_id = cache.NodeType['Corpus'].id,
language_id = None, language_id = None,
metadata = {'Processing' : 1,}
) )
session.add(corpus) session.add(corpus)
session.commit() session.commit()
...@@ -162,14 +164,10 @@ def doTheQuery(request , project_id): ...@@ -162,14 +164,10 @@ def doTheQuery(request , project_id):
if dwnldsOK == 0: return JsonHttpResponse(["fail"]) if dwnldsOK == 0: return JsonHttpResponse(["fail"])
try: try:
def apply_workflow(corpus):
parse_resources(corpus)
extract_ngrams(corpus, ['title'])
compute_tfidf(corpus)
if DEBUG: if DEBUG:
apply_workflow.apply_async(corpus) apply_workflow.apply_async((corpus.id,),)
else: else:
thread = threading.Thread(target=apply_workflow, args=(corpus, ), daemon=True) thread = threading.Thread(target=apply_workflow, args=(corpus.id, ), daemon=True)
thread.start() thread.start()
except Exception as error: except Exception as error:
print('WORKFLOW ERROR') print('WORKFLOW ERROR')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment