Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

Commit 0ffdd70

Browse files
committed
changes added
1 parent 05c4eb3 commit 0ffdd70

File tree

5 files changed

+313
-30
lines changed

5 files changed

+313
-30
lines changed

Pipfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[[source]]
2+
name = "pypi"
3+
url = "https://pypi.org/simple"
4+
verify_ssl = true
5+
6+
[dev-packages]
7+
8+
[packages]
9+
click = "==7.0"
10+
docopt = "==0.6.2"
11+
gunicorn = "==19.9.0"
12+
isodate = "==0.5.4"
13+
itsdangerous = "==1.1.0"
14+
lbp-print = {editable = true,git = "https://github.com/stenskjaer/lbp_print.git",ref = "master"}
15+
lbppy = {editable = true,git = "https://github.com/lombardpress/lbppy.git",ref = "f272e44429fcbd3f19384471c9cfb3903100fb30"}
16+
lxml = "==4.4.1"
17+
pyparsing = "==2.2.0"
18+
rdflib = "==4.2.2"
19+
redis = "==3.3.8"
20+
regex = "==2018.8.17"
21+
rq = "==1.1.0"
22+
samewords = "==0.5.3"
23+
untangle = "==1.1.0"
24+
Flask = "==1.1.1"
25+
Jinja2 = "==2.10.1"
26+
MarkupSafe = "==1.1.1"
27+
SPARQLWrapper = "==1.8.0"
28+
Werkzeug = "==0.15.5"
29+
30+
[requires]
31+
python_version = "3.6"

Pipfile.lock

Lines changed: 235 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
)
3636

3737
# App version
38-
__VERSION__ = subprocess.check_output("git describe --tags", shell=True).decode()
38+
#__VERSION__ = subprocess.check_output("git describe --tags", shell=True).decode()
3939

4040
app = Flask(__name__, instance_path=os.getcwd())
4141

processor.py

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,56 @@
1111

1212
logger = logging.getLogger()
1313
lbp_config.cache_dir = "cache"
14-
redis_connection = Redis(host="redis")
14+
redis_connection = Redis(host="localhost")
1515
q = Queue(connection=redis_connection)
1616

1717

18+
1819
def handle_job(resource_value: str, resource_type: str) -> dict:
19-
try:
20-
logger.debug(f"Checking for job with the id {resource_value}")
21-
job = Job.fetch(resource_value, connection=redis_connection)
22-
except NoSuchJobError:
23-
logger.debug(f"No existing job. Starting one up ...")
24-
job = q.enqueue(
25-
convert_resource,
26-
resource_value,
27-
resource_type,
28-
job_id=resource_value,
29-
job_timeout="1h",
30-
result_ttl=30,
31-
)
32-
return {"Status": f"Started processing {resource_value}"}
33-
34-
status = job.meta["progress"]
35-
36-
if job.result:
37-
response = {"Status": "Finished", "url": job.result}
38-
logger.debug(f"Job was finished. Result: " + job.result)
39-
elif job.is_failed:
40-
response = {"Status": "Failed. Resubmit to retry.", "error": status}
41-
logger.warn(f"Job failed." + status)
42-
job.delete()
20+
21+
# if file existsfirst route
22+
# request url, get hash
23+
# get xstl, get hash
24+
# get file name
25+
# check if file exists
26+
27+
28+
fileExists = function()
29+
30+
if fileExists
31+
response = {"Status": "Finished", "url": filename}
32+
return response
33+
34+
4335
else:
44-
response = {"Status": status}
45-
logger.debug(f"Job running. Status: " + status)
46-
return response
36+
try:
37+
logger.debug(f"Checking for job with the id {resource_value}")
38+
job = Job.fetch(resource_value, connection=redis_connection)
39+
except NoSuchJobError:
40+
logger.debug(f"No existing job. Starting one up ...")
41+
job = q.enqueue(
42+
convert_resource,
43+
resource_value,
44+
resource_type,
45+
job_id=resource_value,
46+
job_timeout="1h",
47+
result_ttl=30,
48+
)
49+
return {"Status": f"Started processing {resource_value}"}
50+
51+
status = job.meta["progress"]
52+
53+
if job.result:
54+
response = {"Status": "Finished", "url": job.result}
55+
logger.debug(f"Job was finished. Result: " + job.result)
56+
elif job.is_failed:
57+
response = {"Status": "Failed. Resubmit to retry.", "error": status}
58+
logger.warn(f"Job failed." + status)
59+
job.delete()
60+
else:
61+
response = {"Status": status}
62+
logger.debug(f"Job running. Status: " + status)
63+
return response
4764

4865

4966
def update_status(message, job):

worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
def start_worker(queues: list = ["default"]):
99
with Connection():
10-
w = Worker(queues, connection=Redis(host="redis"))
10+
w = Worker(queues, connection=Redis(host="localhost"))
1111
w.work()
1212

1313

0 commit comments

Comments
 (0)