Skip to content

Commit

Permalink
Remove dm2 logic from placer, allow measurement
Browse files Browse the repository at this point in the history
  • Loading branch information
nagem committed Jan 19, 2018
1 parent dd0a87e commit 3cbf035
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions api/placer.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,27 +254,16 @@ def check(self):
validators.validate_data(self.metadata, 'enginemetadata.json', 'input', 'POST', optional=True)

###
# Remove when switch to dmv2 is complete across all gears
c_metadata = self.metadata.get(self.container_type, {}) # pragma: no cover
if self.context.get('job_id') and c_metadata and not c_metadata.get('files', []): # pragma: no cover
job = Job.get(self.context.get('job_id'))
input_names = [{'name': v.name} for v in job.inputs.itervalues()]

measurement = self.metadata.get(self.container_type, {}).pop('measurement', None)
info = self.metadata.get(self.container_type,{}).pop('metadata', None)
modality = self.metadata.get(self.container_type, {}).pop('instrument', None)
if measurement or info or modality:
files_ = self.metadata[self.container_type].get('files', [])
files_ += input_names
for f in files_:
if measurement:
f['measurements'] = [measurement]
if info:
f['info'] = info
if modality:
f['modality'] = modality

self.metadata[self.container_type]['files'] = files_
# Shuttle `measurements` key into `classification` on files
###

if self.metadata.get(self.container_type, {}): # pragma: no cover

for f in self.metadata[self.container_type].get('files', []):

if 'measurements' in f:
m = f.pop('measurements')
f['classification'] = {'Custom': m}
###


Expand Down

0 comments on commit 3cbf035

Please sign in to comment.