Skip to content

SNOW-1995584: how to register a method with a ragged output #147

@deadsoul44

Description

@deadsoul44

Hello,

I am able to register a custom model but cannot use its predict_nodes method. When I use inference_api decorator, it fails due to ragged output of the method.

class PerpetualCustomRegressionModel(custom_model.CustomModel):
    def __init__(self, context: custom_model.ModelContext) -> None:
        super().__init__(context)
        with open(context["model_file"], "rb") as f:
            self.model = pickle.load(f)

    @custom_model.inference_api
    def predict(self, input: pd.DataFrame) -> pd.DataFrame:
        return pd.DataFrame({"output": self.model.predict(input)})

    def predict_nodes(self, input: pd.DataFrame):
        return self.model.predict_nodes(input)

When I don't use the ìnference_api decorator, I get the following error:

ValueError: There is no method with name predict_nodes available in the model CAL_HOUSING.CAL_HOUSING_FS.MODEL_EXTRA_METHODS version NEW_WARTHOG_1

How can I use this method?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions