From 371b5e0de75a4970e049c72fac47c653da5f6143 Mon Sep 17 00:00:00 2001 From: Megan Henning <meganhenning@flywheel.io> Date: Thu, 8 Dec 2016 17:05:03 -0600 Subject: [PATCH] Fix bugs --- api/dao/hierarchy.py | 28 +++++++++++++++------------- api/placer.py | 6 +++--- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/api/dao/hierarchy.py b/api/dao/hierarchy.py index 469492ec..ba586ff8 100644 --- a/api/dao/hierarchy.py +++ b/api/dao/hierarchy.py @@ -150,22 +150,24 @@ def is_session_compliant(session, template): Return True if container satisfies requirements. Return False otherwise. """ + log.debug('entering with {} {}'.format(cont, reqs)) for req_k, req_v in reqs.iteritems(): if req_k == 'files': - file_reqs = req_v - min_count = file_reqs.pop('minimum') - count = 0 - for f in cont.get('files', []): - if not check_cont(f, req_v): - # Didn't find a match, on to the next one - continue - else: - count += 1 - if count >= min_count: - break - if count < min_count: - return False + for fr in req_v: + fr_temp = fr.copy() #so subsequent calls don't have their minimum missing + min_count = fr_temp.pop('minimum') + count = 0 + for f in cont.get('files', []): + if not check_cont(f, fr_temp): + # Didn't find a match, on to the next one + continue + else: + count += 1 + if count >= min_count: + break + if count < min_count: + return False else: if not check_req(cont, req_k, req_v): diff --git a/api/placer.py b/api/placer.py index 6e2edc31..317ffa6e 100644 --- a/api/placer.py +++ b/api/placer.py @@ -237,7 +237,8 @@ class EnginePlacer(Placer): ### # Remove when switch to dmv2 is complete across all gears - if self.context.get('job_id') and self.metadata.get(self.container_type): + c_metadata = self.metadata.get(self.container_type, {}) + if self.context.get('job_id') and c_metadata and not c_metadata.get('files', []): job = Job.get(self.context.get('job_id')) input_names = [{'name': v.name} for k,v in job.inputs.iteritems()] @@ -281,8 +282,7 @@ class EnginePlacer(Placer): saved_file_names = [x.get('name') for x in self.saved] for file_md in file_mds: if file_md['name'] not in saved_file_names: - # Updating file that already exists - hierarchy.update_fileinfo(self.container_type, self.id_, file_md) + hierarchy.update_fileinfo(self.container_type+'s', bid, file_md) # Remove file metadata as it was already updated in process_file_field for k in self.metadata.keys(): -- GitLab