コード例 #1
0
 def _create_ensemble(
     policies: Union[List[Policy], PolicyEnsemble, None]
 ) -> Optional[PolicyEnsemble]:
     if policies is None:
         return None
     if isinstance(policies, list):
         return SimplePolicyEnsemble(policies)
     elif isinstance(policies, PolicyEnsemble):
         return policies
     else:
         passed_type = type(policies).__name__
         raise InvalidParameterException(
             f"Invalid param `policies`. Passed object is "
             f"of type '{passed_type}', but should be policy, an array of "
             f"policies, or a policy ensemble.")
コード例 #2
0
    def _create_domain(domain: Union[Domain, Text, None]) -> Domain:

        if isinstance(domain, str):
            domain = Domain.load(domain)
            domain.check_missing_templates()
            return domain
        elif isinstance(domain, Domain):
            return domain
        elif domain is None:
            return Domain.empty()
        else:
            raise InvalidParameterException(
                f"Invalid param `domain`. Expected a path to a domain "
                f"specification or a domain instance. But got "
                f"type '{type(domain)}' with value '{domain}'.")