Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

surface error details on unknown project hash #35

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions beebop/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,16 @@ def run_poppunk() -> json:

:return json: [response object with all job IDs stored in 'data']
"""
logit("running poppunk")
sketches = request.json['sketches'].items()
p_hash = request.json['projectHash']
name_mapping = request.json['names']
q = Queue(connection=redis)
return run_poppunk_internal(sketches, p_hash, name_mapping,
storage_location, redis, q)

def logit(s: str):
print(s, flush=True)

def run_poppunk_internal(sketches: dict,
p_hash: str,
Expand All @@ -194,12 +197,16 @@ def run_poppunk_internal(sketches: dict,
:param q: [redis queue]
:return json: [response object with all job IDs stored in 'data']
"""
logit("running poppunk internal")
# create FS
fs = PoppunkFileStore(storage_location)
logit("created fs")
# read arguments
args = get_args()
logit("got args")
# set database paths
db_paths = DatabaseFileStore(database_location)
logit("set db paths")
# store json sketches in storage, and store an initial output_cluster file
# to record sample hashes for the project
hashes_list = []
Expand All @@ -213,8 +220,10 @@ def run_poppunk_internal(sketches: dict,
fs.ensure_output_dir_exists(p_hash)
with open(fs.output_cluster(p_hash), 'wb') as f:
pickle.dump(initial_output, f)
logit("dumped sketches")
# check connection to redis
check_connection(redis)
logit("checked redis")
# submit list of hashes to redis worker
job_assign = q.enqueue(assignClusters.get_clusters,
hashes_list,
Expand All @@ -225,6 +234,9 @@ def run_poppunk_internal(sketches: dict,
job_timeout=job_timeout)
# save p-hash with job.id in redis server
redis.hset("beebop:hash:job:assign", p_hash, job_assign.id)
# check we've actually saved the value
test_value = redis.hget("beebop:hash:job:assign", p_hash)
logit(f"Read test_value {test_value} for job id {job_assign.id}")
# create visualisations
# network
job_network = q.enqueue(visualise.network,
Expand Down Expand Up @@ -304,8 +316,8 @@ def get_status_job(job, p_hash, redis):
return {"assign": status_assign,
"microreact": status_microreact,
"network": status_network}
except AttributeError:
return {"error": "Unknown project hash"}
except AttributeError as err:
return {"error": f"Unknown project hash error (for hash {p_hash}): {str(err)}"}


# get job result
Expand Down