-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
58 lines (42 loc) · 1.68 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from celery import Celery
from clients.dobie_client import send_data_to_dobie
from clients.fuseki_server import FusekiServer
from utils import parse_dobie_response, handle_raw_annotation
app = Celery('qualichain_mediator')
app.config_from_object('settings', namespace='CELERY_')
@app.task()
def send_dobie_input(message):
"""
This task is used to received job posting text and feed DOBIE component
"""
print(message['tasks'], flush=True)
fuseki_server = FusekiServer()
dobie_response = send_data_to_dobie(message)
if dobie_response.status_code == 200:
extracted_skills_xml = dobie_response.text
saro_data = parse_dobie_response(extracted_skills_xml)
if saro_data:
fuseki_response = fuseki_server.update_dataset(saro_data)
if fuseki_response !=201:
print("Some problems occurred in Fuseki Server with your request Object", flush=True)
print(fuseki_response.reason, flush=True)
else:
print("Some errors occured with Dobie", flush=True)
print(dobie_response.reason, flush=True)
@app.task()
def query_fuseki_async(message):
"""
This function is used to query fuseki server
"""
sparql_query = message["query"]
fuseki = FusekiServer()
response = fuseki.query_fuseki_server(sparql_query)
if response.status_code == 200:
print(response.json(), flush=True)
else:
print("some error occurred", flush=True)
@app.task()
def extract_skills_async(dobie_output):
"""This function is used to receive Dobie Output and process the annotations"""
extracted_skills = handle_raw_annotation(dobie_output)
print(extracted_skills, flush=True)