Commit 8e38ad36 authored by Administrator's avatar Administrator

[FEAT] Adding steps of processing.

parent 36fc9f74
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#import os #import os
#import djcelery #import djcelery
# #
...@@ -46,39 +45,31 @@ def apply_sum(x, y): ...@@ -46,39 +45,31 @@ def apply_sum(x, y):
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 admin.utils import PrintException
def update_processing(corpus, step=0):
try:
corpus.metadata['Processing'] = step
corpus.save()
except :
PrintException()
@shared_task @shared_task
def apply_workflow(corpus_id): def apply_workflow(corpus_id):
corpus = session.query(Node).filter(Node.id==corpus_id).first() corpus = session.query(Node).filter(Node.id==corpus_id).first()
corpus_django = models.Node.objects.get(id=corpus_id)
update_processing(corpus_django, 1)
parse_resources(corpus) parse_resources(corpus)
try: update_processing(corpus_django, 2)
print("-" *60)
# With Django ORM
corpus_django = models.Node.objects.get(id=corpus_id)
corpus_django.metadata['Processing'] = "2"
corpus_django.save()
print("-" *60)
#TODO With SLA ORM (KO why?)
# corpus.metadata['Processing'] = 0
# session.add(corpus)
# session.flush()
except Exception as error:
print(error)
extract_ngrams(corpus, ['title', 'abstract']) extract_ngrams(corpus, ['title', 'abstract'])
update_processing(corpus_django, 3)
compute_tfidf(corpus) compute_tfidf(corpus)
try: update_processing(corpus_django, 0)
corpus_django.metadata['Processing'] = 0
corpus_django.save()
except Exception as error:
print(error)
...@@ -2,7 +2,6 @@ from gargantext_web import settings ...@@ -2,7 +2,6 @@ from gargantext_web import settings
from node import models from node import models
__all__ = ['literalquery', 'session', 'cache', 'Session', 'bulk_insert', 'engine', 'get_cursor'] __all__ = ['literalquery', 'session', 'cache', 'Session', 'bulk_insert', 'engine', 'get_cursor']
......
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