From 1b0ec9f0da755aad9cb0c3f8e52a898d83b8e024 Mon Sep 17 00:00:00 2001 From: Megan Henning <meganhenning@flywheel.io> Date: Thu, 27 Apr 2017 11:03:32 -0500 Subject: [PATCH] Respect type param from create hierarchy --- api/dao/hierarchy.py | 9 ++++----- api/placer.py | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/api/dao/hierarchy.py b/api/dao/hierarchy.py index d36f6ef8..093f3a0e 100644 --- a/api/dao/hierarchy.py +++ b/api/dao/hierarchy.py @@ -418,7 +418,7 @@ def _get_targets(project_obj, session, acquisition, type_, timestamp): return target_containers -def find_existing_hierarchy(metadata, user=None, site=None): +def find_existing_hierarchy(metadata, type_='uid', user=None, site=None): #pylint: disable=unused-argument project = metadata.get('project', {}) session = metadata.get('session', {}) @@ -447,7 +447,7 @@ def find_existing_hierarchy(metadata, user=None, site=None): now = datetime.datetime.utcnow() project_files = dict_fileinfos(project.pop('files', [])) project_obj = config.db.projects.find_one({'_id': session_obj['project']}, projection=PROJECTION_FIELDS + ['name']) - target_containers = _get_targets(project_obj, session, acquisition, 'uid', now) + target_containers = _get_targets(project_obj, session, acquisition, type_, now) target_containers.append( (TargetContainer(project_obj, 'project'), project_files) ) @@ -455,7 +455,6 @@ def find_existing_hierarchy(metadata, user=None, site=None): def upsert_bottom_up_hierarchy(metadata, type_='uid', user=None, site=None): - # pylint: disable=unused-argument group = metadata.get('group', {}) project = metadata.get('project', {}) session = metadata.get('session', {}) @@ -480,13 +479,13 @@ def upsert_bottom_up_hierarchy(metadata, type_='uid', user=None, site=None): now = datetime.datetime.utcnow() project_files = dict_fileinfos(project.pop('files', [])) project_obj = config.db.projects.find_one({'_id': session_obj['project']}, projection=PROJECTION_FIELDS + ['name']) - target_containers = _get_targets(project_obj, session, acquisition, 'uid', now) + target_containers = _get_targets(project_obj, session, acquisition, type_, now) target_containers.append( (TargetContainer(project_obj, 'project'), project_files) ) return target_containers else: - return upsert_top_down_hierarchy(metadata, 'uid', user=user, site=site) + return upsert_top_down_hierarchy(metadata, type_=type_, user=user, site=site) def upsert_top_down_hierarchy(metadata, type_='label', user=None, site=None): diff --git a/api/placer.py b/api/placer.py index 10f2b17f..c339b124 100644 --- a/api/placer.py +++ b/api/placer.py @@ -152,7 +152,7 @@ class UIDPlacer(Placer): metadata_validator(self.metadata, 'POST') # If not a superuser request, pass uid of user making the upload request - targets = self.create_hierarchy(self.metadata, self.match_type, user=self.context.get('uid'), site=self.context.get('site')) + targets = self.create_hierarchy(self.metadata, type_=self.match_type, user=self.context.get('uid'), site=self.context.get('site')) self.metadata_for_file = {} -- GitLab