Skip to content

Commit

Permalink
fixing up start time variable indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
vsoch committed Dec 15, 2017
1 parent 5a76f22 commit d1f7cc3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
11 changes: 1 addition & 10 deletions sendit/apps/main/tasks/finish.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,10 @@ def upload_storage(batch_ids=None):

for batch in batches:
valid = True

batch.qa['UploadStartTime'] = time.time()
batch_ids = BatchIdentifiers.objects.get(batch=batch)

# Retrieve only images that aren't in PHI folder
images = batch.get_finished()

# Stop if no images pass filters
if len(images) == 0:
change_status(batch,"EMPTY")
Expand Down Expand Up @@ -157,18 +154,14 @@ def upload_storage(batch_ids=None):
batch_ids.shared['NumberOfSeries'] = batch.qa['NumberOfSeries']
batch_ids.shared['Series'] = batch.qa['Series']
batch_ids.shared['RemovedSeries'] = batch.qa['FlaggedSeries']

timestamp = get_timestamp(batch_ids.shared['StudyDate'],
format = "%Y%m%d")

compressed_filename = "%s/%s_%s_%s.tar.gz" %(batch.get_path(),
coded_mrn,
timestamp,
studycode)

compressed_file = generate_compressed_file(files=images, # mode="w:gz"
filename=compressed_filename)

# File will be None if no files added
if compressed_file is None:
change_status(batch,"ERROR")
Expand All @@ -183,9 +176,7 @@ def upload_storage(batch_ids=None):
batch.logs['IMAGE_COUNT'] = len(images)
batch_ids.save()
batch.save()

if valid is True:

metadata = deepcopy(batch_ids.shared)
metadata['DicomHeader'] = json.dumps(metadata)
metadata = { compressed_file: metadata }
Expand All @@ -210,7 +201,7 @@ def upload_storage(batch_ids=None):
change_status(batch,"DONE")

batch.qa['UploadFinishTime'] = time.time()
total_time = batch.qa['FinishTime'] - batch.qa['StartTime']
total_time = batch.qa['UploadFinishTime'] - batch.qa['UploadStartTime']
bot.info("Total time for %s: %s images is %f min" %(batch.uid,
batch.image_set.count(),
total_time/60))
Expand Down
4 changes: 2 additions & 2 deletions sendit/apps/main/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def update_cached(subfolder=None):
current = [x.uid for x in Batch.objects.all()]
for base in CHECK_FOLDERS:
print('Checking base %s' %base)
if os.path.exists(base):
if os.path.exists(base) and os.path.isdir(base):
contenders = get_contenders(base=base,current=current)
for contender in contenders:
dicom_dir = "%s/%s" %(base,contender)
Expand Down Expand Up @@ -151,7 +151,7 @@ def start_queue(subfolder=None, max_count=None):
update_cached(subfolder)
contenders = Batch.objects.filter(status="QUEUE")

started = 0
started = 0
for batch in contenders:
# not seen folders in queue
dicom_dir = batch.logs.get('DICOM_DIR')
Expand Down

0 comments on commit d1f7cc3

Please sign in to comment.