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

Commit

Permalink
changes added
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreycwitt committed Nov 9, 2019
1 parent 05c4eb3 commit 0ffdd70
Show file tree
Hide file tree
Showing 5 changed files with 313 additions and 30 deletions.
31 changes: 31 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
click = "==7.0"
docopt = "==0.6.2"
gunicorn = "==19.9.0"
isodate = "==0.5.4"
itsdangerous = "==1.1.0"
lbp-print = {editable = true,git = "https://github.com/stenskjaer/lbp_print.git",ref = "master"}
lbppy = {editable = true,git = "https://github.com/lombardpress/lbppy.git",ref = "f272e44429fcbd3f19384471c9cfb3903100fb30"}
lxml = "==4.4.1"
pyparsing = "==2.2.0"
rdflib = "==4.2.2"
redis = "==3.3.8"
regex = "==2018.8.17"
rq = "==1.1.0"
samewords = "==0.5.3"
untangle = "==1.1.0"
Flask = "==1.1.1"
Jinja2 = "==2.10.1"
MarkupSafe = "==1.1.1"
SPARQLWrapper = "==1.8.0"
Werkzeug = "==0.15.5"

[requires]
python_version = "3.6"
235 changes: 235 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
)

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

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

Expand Down
73 changes: 45 additions & 28 deletions processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,56 @@

logger = logging.getLogger()
lbp_config.cache_dir = "cache"
redis_connection = Redis(host="redis")
redis_connection = Redis(host="localhost")
q = Queue(connection=redis_connection)



def handle_job(resource_value: str, resource_type: str) -> dict:
try:
logger.debug(f"Checking for job with the id {resource_value}")
job = Job.fetch(resource_value, connection=redis_connection)
except NoSuchJobError:
logger.debug(f"No existing job. Starting one up ...")
job = q.enqueue(
convert_resource,
resource_value,
resource_type,
job_id=resource_value,
job_timeout="1h",
result_ttl=30,
)
return {"Status": f"Started processing {resource_value}"}

status = job.meta["progress"]

if job.result:
response = {"Status": "Finished", "url": job.result}
logger.debug(f"Job was finished. Result: " + job.result)
elif job.is_failed:
response = {"Status": "Failed. Resubmit to retry.", "error": status}
logger.warn(f"Job failed." + status)
job.delete()

# if file existsfirst route
# request url, get hash
# get xstl, get hash
# get file name
# check if file exists


fileExists = function()

if fileExists
response = {"Status": "Finished", "url": filename}
return response


else:
response = {"Status": status}
logger.debug(f"Job running. Status: " + status)
return response
try:
logger.debug(f"Checking for job with the id {resource_value}")
job = Job.fetch(resource_value, connection=redis_connection)
except NoSuchJobError:
logger.debug(f"No existing job. Starting one up ...")
job = q.enqueue(
convert_resource,
resource_value,
resource_type,
job_id=resource_value,
job_timeout="1h",
result_ttl=30,
)
return {"Status": f"Started processing {resource_value}"}

status = job.meta["progress"]

if job.result:
response = {"Status": "Finished", "url": job.result}
logger.debug(f"Job was finished. Result: " + job.result)
elif job.is_failed:
response = {"Status": "Failed. Resubmit to retry.", "error": status}
logger.warn(f"Job failed." + status)
job.delete()
else:
response = {"Status": status}
logger.debug(f"Job running. Status: " + status)
return response


def update_status(message, job):
Expand Down
2 changes: 1 addition & 1 deletion worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

def start_worker(queues: list = ["default"]):
with Connection():
w = Worker(queues, connection=Redis(host="redis"))
w = Worker(queues, connection=Redis(host="localhost"))
w.work()


Expand Down

0 comments on commit 0ffdd70

Please sign in to comment.