示例#1
0
    def _get_dataset_name(self, metadata_dict, hash_dataset):
        if self._discovery:
            return GCProvider._get_dataset_name(self, metadata_dict,
                                                hash_dataset)
        if 'CMSSW_DATATIER' not in metadata_dict:
            raise DatasetError('Incompatible data tiers in dataset: %s' %
                               repr(metadata_dict))

        def _get_path_components(path):
            if path:
                return path.strip('/').split('/')
            return []

        user_dataset_part_list = tuple(
            _get_path_components(self._dataset_pattern))

        (primary, processed, tier) = (None, None, None)
        # In case of a child dataset, use the parent infos to construct new path
        for parent in metadata_dict.get('PARENT_PATH', []):
            if len(user_dataset_part_list) == 3:
                (primary, processed, tier) = user_dataset_part_list
            else:
                try:
                    (primary, processed,
                     tier) = tuple(_get_path_components(parent))
                except Exception:
                    clear_current_exception()
        if (primary is None) and (len(user_dataset_part_list) > 0):
            primary = user_dataset_part_list[0]
            user_dataset_part_list = user_dataset_part_list[1:]

        if len(user_dataset_part_list) == 2:
            (processed, tier) = user_dataset_part_list
        elif len(user_dataset_part_list) == 1:
            (processed, tier) = (user_dataset_part_list[0],
                                 metadata_dict['CMSSW_DATATIER'])
        elif len(user_dataset_part_list) == 0:
            (processed, tier) = ('Dataset_%s' % hash_dataset,
                                 metadata_dict['CMSSW_DATATIER'])

        raw_dataset_name = '/%s/%s/%s' % (primary, processed, tier)
        if None in (primary, processed, tier):
            raise DatasetError(
                'Invalid dataset name supplied: %r\nresulting in %s' %
                (self._dataset_pattern, raw_dataset_name))
        return replace_with_dict(raw_dataset_name, metadata_dict)
	def _get_dataset_name(self, metadata_dict, hash_dataset):
		if self._discovery:
			return GCProvider._get_dataset_name(self, metadata_dict, hash_dataset)
		if 'CMSSW_DATATIER' not in metadata_dict:
			raise DatasetError('Incompatible data tiers in dataset: %s' % repr(metadata_dict))

		def _get_path_components(path):
			if path:
				return path.strip('/').split('/')
			return []
		user_dataset_part_list = tuple(_get_path_components(self._dataset_pattern))

		(primary, processed, tier) = (None, None, None)
		# In case of a child dataset, use the parent infos to construct new path
		for parent in metadata_dict.get('PARENT_PATH', []):
			if len(user_dataset_part_list) == 3:
				(primary, processed, tier) = user_dataset_part_list
			else:
				try:
					(primary, processed, tier) = tuple(_get_path_components(parent))
				except Exception:
					clear_current_exception()
		if (primary is None) and (len(user_dataset_part_list) > 0):
			primary = user_dataset_part_list[0]
			user_dataset_part_list = user_dataset_part_list[1:]

		if len(user_dataset_part_list) == 2:
			(processed, tier) = user_dataset_part_list
		elif len(user_dataset_part_list) == 1:
			(processed, tier) = (user_dataset_part_list[0], metadata_dict['CMSSW_DATATIER'])
		elif len(user_dataset_part_list) == 0:
			(processed, tier) = ('Dataset_%s' % hash_dataset, metadata_dict['CMSSW_DATATIER'])

		raw_dataset_name = '/%s/%s/%s' % (primary, processed, tier)
		if None in (primary, processed, tier):
			raise DatasetError('Invalid dataset name supplied: %r\nresulting in %s' % (
				self._dataset_pattern, raw_dataset_name))
		return replace_with_dict(raw_dataset_name, metadata_dict)