(
    op: CustomizeOpType,
    schemas: Optional[Schema] = None,
    relevantToOptimizer: Optional[List[str]] = None,
    constraint: Union[Schema, JSON_TYPE, List[Union[Schema, JSON_TYPE]], None] = None,
    tags: Optional[Dict] = None,
    forwards: Union[bool, List[str], None] = None,
    set_as_available: bool = False,
    **kwargs: Union[Schema, JSON_TYPE, None],
)
return op
Return a new operator with a customized schema

    Parameters
    ----------
    schemas : Schema
        A dictionary of json schemas for the operator. Override the entire schema and ignore other arguments
    input : Schema
        (or `input_*`) override the input schema for method `*`.
        `input_*` must be an existing method (already defined in the schema for lale operators, existing method for external operators)
    output : Schema
        (or `output_*`) override the output schema for method `*`.
        `output_*` must be an existing method (already defined in the schema for lale operators, existing method for external operators)
    constraint : Schema
        Add a constraint in JSON schema format.
    relevantToOptimizer : String list
        update the set parameters that will be optimized.
    param : Schema
        Override the schema of the hyperparameter.
        `param` must be an existing parameter (already defined in the schema for lale operators, __init__ parameter for external operators)
    tags : Dict
        Override the tags of the operator.
    forwards: boolean or a list of strings
        Which methods/properties to forward to the underlying impl.  (False for none, True for all).
    set_as_available: bool
        Override the list of available operators so `get_available_operators` returns this customized operator.

    Returns
    -------
    PlannedIndividualOp
        Copy of the operator with a customized schema
Return a new operator with a customized schema
Return a new operator with a customized schema
def customize_schema(
    op: CustomizeOpType,
    schemas: Optional[Schema] = None,
    relevantToOptimizer: Optional[List[str]] = None,
    constraint: Union[Schema, JSON_TYPE, List[Union[Schema, JSON_TYPE]], None] = None,
    tags: Optional[Dict] = None,
    forwards: Union[bool, List[str], None] = None,
    set_as_available: bool = False,
    **kwargs: Union[Schema, JSON_TYPE, None],
) -> CustomizeOpType:
    """Return a new operator with a customized schema

    Parameters
    ----------
    schemas : Schema
        A dictionary of json schemas for the operator. Override the entire schema and ignore other arguments
    input : Schema
        (or `input_*`) override the input schema for method `*`.
        `input_*` must be an existing method (already defined in the schema for lale operators, existing method for external operators)
    output : Schema
        (or `output_*`) override the output schema for method `*`.
        `output_*` must be an existing method (already defined in the schema for lale operators, existing method for external operators)
    constraint : Schema
        Add a constraint in JSON schema format.
    relevantToOptimizer : String list
        update the set parameters that will be optimized.
    param : Schema
        Override the schema of the hyperparameter.
        `param` must be an existing parameter (already defined in the schema for lale operators, __init__ parameter for external operators)
    tags : Dict
        Override the tags of the operator.
    forwards: boolean or a list of strings
        Which methods/properties to forward to the underlying impl.  (False for none, True for all).
    set_as_available: bool
        Override the list of available operators so `get_available_operators` returns this customized operator.

    Returns
    -------
    PlannedIndividualOp
        Copy of the operator with a customized schema
    """
    op_index = -1
    try:
        op_index = _all_available_operators.index(op)
    except ValueError:
        pass
    # TODO: why are we doing a deeopcopy here?
    op = copy.deepcopy(op)
    methods = ["fit", "transform", "predict", "predict_proba", "decision_function"]
    # explicitly enable the hyperparams schema check because it is important
    from lale.settings import (
        disable_hyperparams_schema_validation,
        set_disable_hyperparams_schema_validation,
    )

    existing_disable_hyperparams_schema_validation = (
        disable_hyperparams_schema_validation
    )
    set_disable_hyperparams_schema_validation(False)

    if schemas is not None:
        schemas.schema["$schema"] = "http://json-schema.org/draft-04/schema#"
        lale.type_checking.validate_is_schema(schemas.schema)
        op._schemas = schemas.schema
    else:
        if relevantToOptimizer is not None:
            assert isinstance(relevantToOptimizer, list)
            op._schemas["properties"]["hyperparams"]["allOf"][0][
                "relevantToOptimizer"
            ] = relevantToOptimizer
        if constraint is not None:
            cl: List[Union[Schema, JSON_TYPE]]
            if isinstance(constraint, list):
                cl = constraint
            else:
                cl = [constraint]

            for c in cl:
                if isinstance(c, Schema):
                    c = c.schema
                op._schemas["properties"]["hyperparams"]["allOf"].append(c)
        if tags is not None:
            assert isinstance(tags, dict)
            op._schemas["tags"] = tags
        if forwards is not None:
            assert isinstance(forwards, (bool, list))
            op._schemas["forwards"] = forwards

        for arg in kwargs:
            value = kwargs[arg]
            if value is not None and isinstance(value, Schema):
                value = value.schema
            if value is not None:
                lale.type_checking.validate_is_schema(value)
            if arg in [p + n for p in ["input_", "output_"] for n in methods]:
                # multiple input types (e.g., fit, predict)
                assert value is not None
                lale.type_checking.validate_method(op, arg)
                op._schemas["properties"][arg] = value
            elif value is None:
                scm = op._schemas["properties"]["hyperparams"]["allOf"][0]
                scm["required"] = [k for k in scm["required"] if k != arg]
                scm["relevantToOptimizer"] = [
                    k for k in scm["relevantToOptimizer"] if k != arg
                ]
                scm["properties"] = {
                    k: scm["properties"][k] for k in scm["properties"] if k != arg
                }
            else:
                op._schemas["properties"]["hyperparams"]["allOf"][0]["properties"][
                    arg
                ] = value
    # since the schema has changed, we need to invalidate any
    # cached enum attributes
    op._invalidate_enum_attributes()
    set_disable_hyperparams_schema_validation(
        existing_disable_hyperparams_schema_validation
    )
    # we also need to prune the hyperparameter, if any, removing defaults (which may have changed)
    op._hyperparams = op.hyperparams()
    if set_as_available and op_index >= 0:
        _all_available_operators[op_index] = op
    return op
def customize_schema ( op : CustomizeOpType , schemas : Optional [ Schema ] = None , relevantToOptimizer : Optional [ List [ str ] ] = None , constraint : Union [ Schema , JSON_TYPE , List [ Union [ Schema , JSON_TYPE ] ] , None ] = None , tags : Optional [ Dict ] = None , forwards : Union [ bool , List [ str ] , None ] = None , set_as_available : bool = False , * * kwargs : Union [ Schema , JSON_TYPE , None ] , ) -> CustomizeOpType : op_index = - 1 try : op_index = _all_available_operators . index ( op ) except ValueError : pass # TODO: why are we doing a deeopcopy here? op = copy . deepcopy ( op ) methods = [ "fit" , "transform" , "predict" , "predict_proba" , "decision_function" ] # explicitly enable the hyperparams schema check because it is important from lale . settings import ( disable_hyperparams_schema_validation , set_disable_hyperparams_schema_validation , ) existing_disable_hyperparams_schema_validation = ( disable_hyperparams_schema_validation ) set_disable_hyperparams_schema_validation ( False ) if schemas is not None : schemas . schema [ "$schema" ] = "http://json-schema.org/draft-04/schema#" lale . type_checking . validate_is_schema ( schemas . schema ) op . _schemas = schemas . schema else : if relevantToOptimizer is not None : assert isinstance ( relevantToOptimizer , list ) op . _schemas [ "properties" ] [ "hyperparams" ] [ "allOf" ] [ 0 ] [ "relevantToOptimizer" ] = relevantToOptimizer if constraint is not None : cl : List [ Union [ Schema , JSON_TYPE ] ] if isinstance ( constraint , list ) : cl = constraint else : cl = [ constraint ] for c in cl : if isinstance ( c , Schema ) : c = c . schema op . _schemas [ "properties" ] [ "hyperparams" ] [ "allOf" ] . append ( c ) if tags is not None : assert isinstance ( tags , dict ) op . _schemas [ "tags" ] = tags if forwards is not None : assert isinstance ( forwards , ( bool , list ) ) op . _schemas [ "forwards" ] = forwards for arg in kwargs : value = kwargs [ arg ] if value is not None and isinstance ( value , Schema ) : value = value . schema if value is not None : lale . type_checking . validate_is_schema ( value ) if arg in [ p + n for p in [ "input_" , "output_" ] for n in methods ] : # multiple input types (e.g., fit, predict) assert value is not None lale . type_checking . validate_method ( op , arg ) op . _schemas [ "properties" ] [ arg ] = value elif value is None : scm = op . _schemas [ "properties" ] [ "hyperparams" ] [ "allOf" ] [ 0 ] scm [ "required" ] = [ k for k in scm [ "required" ] if k != arg ] scm [ "relevantToOptimizer" ] = [ k for k in scm [ "relevantToOptimizer" ] if k != arg ] scm [ "properties" ] = { k : scm [ "properties" ] [ k ] for k in scm [ "properties" ] if k != arg } else : op . _schemas [ "properties" ] [ "hyperparams" ] [ "allOf" ] [ 0 ] [ "properties" ] [ arg ] = value # since the schema has changed, we need to invalidate any # cached enum attributes op . _invalidate_enum_attributes ( ) set_disable_hyperparams_schema_validation ( existing_disable_hyperparams_schema_validation ) # we also need to prune the hyperparameter, if any, removing defaults (which may have changed) op . _hyperparams = op . hyperparams ( ) if set_as_available and op_index >= 0 : _all_available_operators [ op_index ] = op return op