<commit_before>from cloudbrain.settings import DEVICE_METADATA

def map_metric_to_num_channels(device_name):
  """
  Map wearable metric names to the number of channels of this metric.
  :return: dict {metric_name: num_channels}
  """
  metadata = [metadata for metadata in DEVICE_METADATA if metadata['device_name'] == device_name][0]

  metric_name_to_num_channels = {}
  for metric in metadata['metrics']:
    metric_name_to_num_channels[metric['metric_name']] = metric['num_channels']

  return metric_name_to_num_channels

def get_metrics_names(device_name):
  """
  Get metric names for a specific device name.
  :return: list of metric names
  """
  metadata = [metadata for metadata in DEVICE_METADATA if metadata['device_name'] == device_name][0]

  metric_names = []
  for metric in metadata['metrics']:
    metric_names.append(metric['metric_name'])

  return metric_names<commit_msg>more utils methods to get metadat info<commit_after>from cloudbrain.settings import DEVICE_METADATA


class _DeviceNameNotFound(Exception):
  pass


def map_metric_to_num_channels(device_name):
  """
  Map wearable metric names to the number of channels of this metric.
  :return: dict {metric_name: num_channels}
  """
  metadata = [metadata for metadata in DEVICE_METADATA if metadata['device_name'] == device_name]

  if len(metadata) > 0:
    metrics = metadata[0]['metrics']
  else:
    raise _DeviceNameNotFound("Could not find device name '%s' in metadata" % device_name)

  metric_name_to_num_channels = {}
  for metric in metrics:
    metric_name_to_num_channels[metric['metric_name']] = metric['num_channels']

  return metric_name_to_num_channels


def get_metrics_names(device_name):
  """
  Get metric names for a specific device name.
  :return: list of metric names
  """
  metadata = [metadata for metadata in DEVICE_METADATA if metadata['device_name'] == device_name]

  if len(metadata) > 0:
    metrics = metadata[0]['metrics']
  else:
    raise _DeviceNameNotFound("Could not find device name '%s' in metadata" % device_name)

  metric_names = []
  for metric in metrics:
    metric_names.append(metric['metric_name'])

  return metric_names


def get_supported_devices():
  return [device['device_name'] for device in DEVICE_METADATA]


def get_supported_metrics():
  metrics = []
  for device_name in get_supported_devices():
    metrics.extend(get_metrics_names(device_name))
  return metrics
{'fraction_non_alphanumeric': 0.0946058091286307, 'fraction_numerical': 0.0024896265560165973, 'mean_word_length': 5.2623376623376625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4491609', 'n_tokens_mistral': 748, 'n_tokens_neox': 722, 'n_words': 202}