Skip to content

Commit

Permalink
Add check if live_data exists, assuming live_data first type
Browse files Browse the repository at this point in the history
  • Loading branch information
mflierm committed Apr 20, 2022
1 parent b48fe42 commit b3e1d91
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions bin/bootstrax
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,17 @@ def main():
message = f"Trying to process single run but no run numbered {number} exists"
log_warning(message, priority='fatal')
raise ValueError(message)
set_state('busy')
process_run(rd)
log.info(
f'bootstrax ({hostname}) finished run {number} in {(now() - t_start).seconds} seconds')
wait_on_delete_thread()
if args.production:
if not rd['data'][0].get('type','no_type') == 'live':
message = f"Live data does not exist. Maybe run {number} is already processed?"
log_warning(message, priority='fatal')
raise ValueError(message)
else:
set_state('busy')
process_run(rd)
log.info(
f'bootstrax ({hostname}) finished run {number} in {(now() - t_start).seconds} seconds')
wait_on_delete_thread()

else:
# Start processing
Expand Down

2 comments on commit b3e1d91

@mflierm
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JoranAngevaare I tried this, but I was not really sure how to test it other than testing if the syntax in l.354 is doing what I want ;-)

Two comments:

  1. It makes use of the assumption that the live data datatype is always the first entry in that list;
  2. I put it now only in the main() function, since I expect the troubles to arise here (all the runs are in principle auto processed, so if you want to process a single run, you might overdo it).

There might be a smarter way/place to do it, but this was my first guess. Let me know what you think!

@JoranAngevaare
Copy link
Contributor

@JoranAngevaare JoranAngevaare commented on b3e1d91 Apr 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, very good! This is indeed where it should go (approximately).

If you look on L348, you can see that rd = consider_run({'number': number}) is already going to change the bootstrax.status so the change you made will be too late to catch that.

So if you change this a bit (you don't need to look for data, and the live-data being the first unfortunately is often not true), to at line L347, you say bootstrax_state = run_col.find_one({'number': number}, projection={'bootstrax': True}).get('bootstrax', {}).get{'state', 'no-state') you can raise an error if args.production and bootstrax_state in ['done', 'processing', 'considering']. (I always make typos, but I think you get the idea)

By the way, you don't want to push all of the logic under the args.production since we want to be able to test a single run (even if it processed already 😄 ).

Please sign in to comment.