diff --git a/beebop/app.py b/beebop/app.py index fe366cd5..526205a4 100644 --- a/beebop/app.py +++ b/beebop/app.py @@ -165,6 +165,7 @@ 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'] @@ -172,6 +173,8 @@ def run_poppunk() -> json: 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, @@ -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 = [] @@ -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, @@ -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, @@ -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