Skip to content

write/read vetiver model pin changes class 'bool' to 'Nonetype' #217

@dsdaveh

Description

@dsdaveh

Describe the bug
Protoype class changes from 'bool' to 'Nonetype' when writing a vetiver model as pin and then retrieving it.
To Reproduce

Steps to reproduce the behavior:
This code (derived from do4ds.org lab2) reproduces the problem.

import pins
import vetiver
import logging
from palmerpenguins import penguins
from pandas import get_dummies
from sklearn.linear_model import LinearRegression

# logging.basicConfig(level=logging.DEBUG)

df = penguins.load_penguins().dropna()
X = get_dummies(df[['bill_length_mm', 'species', 'sex']], drop_first = True)
y = df['body_mass_g']
model = LinearRegression().fit(X, y)

v = vetiver.VetiverModel(model, model_name='penguin_model', prototype_data=X)

# running API here works
# app = vetiver.VetiverAPI(v, check_prototype = True)
# app.run(port = 8080)

model_board = pins.board_folder("data/model", allow_pickle_read = True)
vetiver.vetiver_pin_write(model_board, v)
v2 = vetiver.VetiverModel.from_pin(model_board, 'penguin_model')

# This does not work because the species_ class has been change from bool to NoneType
# app = vetiver.VetiverAPI(v2, check_prototype = True)
# app.run(port = 8080)

print(v.prototype.__annotations__)
print(v2.prototype.__annotations__)

Expected behavior
the prototypes for v and v2 should be identical, but are not. As a result the API /predict endpoint doesn't work for v2.

Screenshots
NA

Desktop (please complete the following information):

  • OS: Mac Ventura 13.0.1 also reproduced on Linux Ubuntu 19
  • Browser NA
  • Version NA

Smartphone (please complete the following information):
NA

Additional context
NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions