class_docstr: Store that represents persistent state for experiments.
  
  Apart from initialization, the user should not be using its methods normally.
class_docstr_tok: ["Store","that","represents","persistent","state","for","experiments",".","Apart","from","initialization",",","the","user","should","not","be","using","its","methods","normally","."]
code: def add_measure(
      self,
      trial_or_task_id: int,
      trial_or_task_type: Type,
      name,
      value,
      description=None,
      type_=None,
      lower_is_better=True,
  ):
      from powerlift.bench.experiment import Task, Trial
  
      if type_ is None:
          if isinstance(value, str):
              type_ = db.TypeEnum.STR
          elif isinstance(value, dict):
              type_ = db.TypeEnum.JSON
          elif isinstance(value, numbers.Number):
              type_ = db.TypeEnum.NUMBER
          else:
              raise RuntimeError(
                  f"Value type {type(value)} is not supported for measure"
              )
      elif isinstance(type_, str):
          type_ = db.TypeEnum[type_.upper()]
  
      # Create measure description if needed
      is_declared = name in self._declared_measures
      if not is_declared:
          if description is None:
              description = f"Measure: {name}"
  
          measure_description_orm = (
              self._session.query(db.MeasureDescription)
              .filter_by(name=name)
              .one_or_none()
          )
          if measure_description_orm is None:
              measure_description_orm = db.MeasureDescription(
                  name=name,
                  description=description,
                  type=type_,
                  lower_is_better=lower_is_better,
              )
              try:
                  self._session.add(measure_description_orm)
                  self._session.commit()
              except IntegrityError:
                  self._session.rollback()
                  measure_description_orm = (
                      self._session.query(db.MeasureDescription)
                      .filter_by(name=name)
                      .one()
                  )
          self._declared_measures[name] = measure_description_orm
      else:
          measure_description_orm = self._declared_measures[name]
  
      # Create measure
      seq_num = self._measure_counts[name] = (
          self._measure_counts.get(name, -1) + 1
      )
      timestamp = datetime.now(pytz.utc)
      measure_outcome_orm = db.MeasureOutcome(
          measure_description=measure_description_orm,
          timestamp=timestamp,
          seq_num=seq_num,
      )
      if type_ == db.TypeEnum.STR:
          measure_outcome_orm.str_val = value
      elif type_ == db.TypeEnum.JSON:
          measure_outcome_orm.json_val = value
      elif type_ == db.TypeEnum.NUMBER:
          measure_outcome_orm.num_val = value
      else:
          raise RuntimeError(
              f"Value type {type(value)} is not supported for measure"
          )
  
      if trial_or_task_type == Task:
          db_type = db.Task
      elif trial_or_task_type == Trial:
          db_type = db.Trial
      else:
          raise RuntimeError(
              f"Type {trial_or_task_type} is not Task nor Trial"
          )
  
      trial_or_task_orm = (
          self._session.query(db_type)
          .filter_by(id=trial_or_task_id)
          .one()
      )
      trial_or_task_orm.measure_outcomes.append(measure_outcome_orm)
      if not is_declared:
          self._session.add(measure_description_orm)
      self._session.add(measure_outcome_orm)
      self._session.commit()
      return measure_outcome_orm.id
  
imports: import pytz
  import base64
  from dataclasses import dataclass
  from typing import Any, Dict, Generator, Iterable, List, Optional, Tuple, Type
  import random
  import random
  from powerlift.db.actions import delete_db, create_db
  from powerlift.measures import class_stats, data_stats, regression_stats
  from sqlalchemy.exc import IntegrityError
  from sqlalchemy import create_engine
  from tqdm import tqdm
  from itertools import chain
  from sqlalchemy.orm import Session
  import io
  import os
  from powerlift.db import schema
  import numbers
  from datetime import datetime
  import pathlib
  import pandas
  import ast
label_desc: Use image node_id 21 for calling the Store obj's underlying member method code with example usage: obj.add_measure(trial_or_task_id, trial_or_task_type, name, value, description, type_, lower_is_better) and returns: measure_outcome_orm