class_docstr: Class that contains methods for loading an Ax experiment from SQLAlchemy.
  
  Instantiate with an instance of Config to customize the functionality.
  For even more flexibility, create a subclass.
  
  Attributes:
      config: Metadata needed to save and load an experiment to SQLAlchemy.
class_docstr_tok: ["Class","that","contains","methods","for","loading","an","Ax","experiment","from","SQLAlchemy",".","Instantiate","with","an","instance","of","Config","to","customize","the","functionality",".","For","even","more","flexibility",",","create","a","subclass",".","Attributes",":","config",":","Metadata","needed","to","save","and","load","an","experiment","to","SQLAlchemy","."]
docstr: Convert a list of SQLAlchemy Parameters and ParameterConstraints to an
  Ax SearchSpace.
docstr_tok: ["Convert","a","list","of","SQLAlchemy","Parameters","and","ParameterConstraints","to","an","Ax","SearchSpace","."]
code: def search_space_from_sqa(
      self,
      parameters_sqa: List[SQAParameter],
      parameter_constraints_sqa: List[SQAParameterConstraint],
  ) -> Optional[SearchSpace]:
      """Convert a list of SQLAlchemy Parameters and ParameterConstraints to an
      Ax SearchSpace.
      """
      parameters, environmental_variables = [], []
      for parameter_sqa in parameters_sqa:
          if (
              parameter_sqa.domain_type
              == DomainType.ENVIRONMENTAL_RANGE
          ):
              environmental_variables.append(
                  self.environmental_variable_from_sqa(
                      parameter_sqa=parameter_sqa
                  )
              )
          else:
              parameters.append(
                  self.parameter_from_sqa(parameter_sqa=parameter_sqa)
              )
      parameter_constraints = [
          self.parameter_constraint_from_sqa(
              parameter_constraint_sqa=parameter_constraint_sqa,
              parameters=parameters,
          )
          for parameter_constraint_sqa in parameter_constraints_sqa
          if parameter_constraint_sqa.type
          != ParameterConstraintType.DISTRIBUTION
      ]
      (
          parameter_distributions,
          num_samples,
      ) = self.parameter_distributions_from_sqa(
          [
              parameter_constraint_sqa
              for parameter_constraint_sqa in parameter_constraints_sqa
              if parameter_constraint_sqa.type
              == ParameterConstraintType.DISTRIBUTION
          ]
      )
  
      if len(parameters) == 0:
          return None
  
      if num_samples is not None:
          return RobustSearchSpace(
              parameters=parameters,
              parameter_distributions=parameter_distributions,
              num_samples=num_samples,
              environmental_variables=environmental_variables,
              parameter_constraints=parameter_constraints,
          )
      elif any(p.is_hierarchical for p in parameters):
          return HierarchicalSearchSpace(
              parameters=parameters,
              parameter_constraints=parameter_constraints,
          )
      else:
          return SearchSpace(
              parameters=parameters,
              parameter_constraints=parameter_constraints,
          )
  
imports: import json
  from collections import defaultdict, OrderedDict
  from enum import Enum
  from logging import Logger
  from typing import Any, cast, Dict, List, Optional, Tuple, Type, Union
  import pandas
  from ax.core.arm import Arm
  from ax.core.base_trial import BaseTrial, TrialStatus
  from ax.core.batch_trial import AbandonedArm, BatchTrial, GeneratorRunStruct
  from ax.core.data import Data
  from ax.core.experiment import Experiment
  from ax.core.generator_run import GeneratorRun, GeneratorRunType
  from ax.core.metric import Metric
  from ax.core.multi_type_experiment import MultiTypeExperiment
  from ax.core.objective import MultiObjective, Objective, ScalarizedObjective
  from ax.core.optimization_config import MultiObjectiveOptimizationConfig, OptimizationConfig
  from ax.core.outcome_constraint import ObjectiveThreshold, OutcomeConstraint, ScalarizedOutcomeConstraint
  from ax.core.parameter import ChoiceParameter, FixedParameter, Parameter, RangeParameter
  from ax.core.parameter_constraint import OrderConstraint, ParameterConstraint, SumConstraint
  from ax.core.parameter_distribution import ParameterDistribution
  from ax.core.risk_measures import RiskMeasure
  from ax.core.runner import Runner
  from ax.core.search_space import HierarchicalSearchSpace, RobustSearchSpace, SearchSpace
  from ax.core.trial import Trial
  from ax.exceptions.storage import SQADecodeError
  from ax.modelbridge.generation_strategy import GenerationStrategy
  from ax.storage.json_store.decoder import object_from_json
  from ax.storage.sqa_store.db import session_scope
  from ax.storage.sqa_store.sqa_classes import SQAAbandonedArm, SQAArm, SQAData, SQAExperiment, SQAGenerationStrategy, SQAGeneratorRun, SQAMetric, SQAParameter, SQAParameterConstraint, SQARunner, SQATrial
  from ax.storage.sqa_store.sqa_config import SQAConfig
  from ax.storage.utils import DomainType, MetricIntent, ParameterConstraintType
  from ax.utils.common.constants import Keys
  from ax.utils.common.logger import get_logger
  from ax.utils.common.typeutils import not_none
  from sqlalchemy.orm.exc import DetachedInstanceError
label_desc: Use image node_id 10 for calling the Decoder obj's underlying member method code with example usage: obj.search_space_from_sqa(parameters_sqa, parameter_constraints_sqa) and returns: None, RobustSearchSpace, HierarchicalSearchSpace, SearchSpace