posit-conf-2024 / ds-workflows-python

posit::conf(2024) workshop: Data Science Workflows with Posit Tools — Python Focus
https://ferryland.posit.team/
Creative Commons Attribution Share Alike 4.0 International
11 stars 8 forks source link

Ferry API has null value types #17

Open SamEdwardes opened 2 months ago

SamEdwardes commented 2 months ago

@brooklynbagel I noticed several of the model inputs have null value types:

Screenshot 2024-07-05 at 14 06 12@2x

I think this could mean that there is no data in these fields. Can you please look into this?

SamEdwardes commented 2 months ago

For reference, I am getting the following error when when trying to call the API with data in these fields:

File "/Users/samedwardes/projects/posit/ds-workflows-python-2024/materials/05-shiny-app/src/module_model_explorer.py", line 301, in predicted_delay_text
    return f"{predict_delay()} minutes"
              ^^^^^^^^^^^^^^^
  File "/Users/samedwardes/projects/posit/ds-workflows-python-2024/materials/05-shiny-app/.venv/lib/python3.12/site-packages/shiny/reactive/_reactives.py", line 284, in __call__
    return _utils.run_coro_sync(self.get_value())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/samedwardes/projects/posit/ds-workflows-python-2024/materials/05-shiny-app/.venv/lib/python3.12/site-packages/shiny/_utils.py", line 381, in run_coro_sync
    coro.send(None)
  File "/Users/samedwardes/projects/posit/ds-workflows-python-2024/materials/05-shiny-app/.venv/lib/python3.12/site-packages/shiny/reactive/_reactives.py", line 294, in get_value
    raise self._error[0]
  File "/Users/samedwardes/projects/posit/ds-workflows-python-2024/materials/05-shiny-app/.venv/lib/python3.12/site-packages/shiny/reactive/_reactives.py", line 329, in _run_func
    self._value.append(await self._fn())
                       ^^^^^^^^^^^^^^^^
  File "/Users/samedwardes/projects/posit/ds-workflows-python-2024/materials/05-shiny-app/.venv/lib/python3.12/site-packages/shiny/_utils.py", line 263, in fn_async
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/samedwardes/projects/posit/ds-workflows-python-2024/materials/05-shiny-app/src/module_model_explorer.py", line 275, in predict_delay
    prediction_results = predict(
                         ^^^^^^^^
  File "/Users/samedwardes/projects/posit/ds-workflows-python-2024/materials/05-shiny-app/.venv/lib/python3.12/site-packages/vetiver/server.py", line 348, in predict
    raise TypeError(re.sub(r"\n", ": ", response.text))
TypeError: [{'type': 'none_required', 'loc': ('body', 0, 'PassengerOnly'), 'msg': 'Input should be None', 'input': False}, {'type': 'none_required', 'loc': ('body', 0, 'FastFerry'), 'msg': 'Input should be None', 'input': False}, {'type': 'none_required', 'loc': ('body', 0, 'departing_precipitation'), 'msg': 'Input should be None', 'input': 0}, {'type': 'none_required', 'loc': ('body', 0, 'arriving_precipitation'), 'msg': 'Input should be None', 'input': 0}]
brooklynbagel commented 1 month ago

Oddly enough, it looks like the data going in has no nulls:

from vetiver import VetiverModel

v = VetiverModel(
    model, model_name=f"{username}/ferry_delay", prototype_data=X.to_pandas()
)

X.null_count()
shape: (1, 29)
DepartingArrivingMonthWeekdayHourClassNameSpeedInKnotsEngineCountHorsepowerMaxPassengerCountPassengerOnlyFastFerryPropulsionInfoYearBuiltYearRebuiltdeparting_weather_codedeparting_temperature_2mdeparting_precipitationdeparting_cloud_coverdeparting_wind_speed_10mdeparting_wind_direction_10mdeparting_wind_gusts_10marriving_weather_codearriving_temperature_2marriving_precipitationarriving_cloud_coverarriving_wind_speed_10marriving_wind_direction_10marriving_wind_gusts_10m
u32u32u32u32u32u32u32u32u32u32u32u32u32u32u32u32u32u32u32u32u32u32u32u32u32u32u32u32u32
00000000000000000000000000000
X.to_pandas().isnull().sum()
Departing                       0
Arriving                        0
Month                           0
Weekday                         0
Hour                            0
ClassName                       0
SpeedInKnots                    0
EngineCount                     0
Horsepower                      0
MaxPassengerCount               0
PassengerOnly                   0
FastFerry                       0
PropulsionInfo                  0
YearBuilt                       0
YearRebuilt                     0
departing_weather_code          0
departing_temperature_2m        0
departing_precipitation         0
departing_cloud_cover           0
departing_wind_speed_10m        0
departing_wind_direction_10m    0
departing_wind_gusts_10m        0
arriving_weather_code           0
arriving_temperature_2m         0
arriving_precipitation          0
arriving_cloud_cover            0
arriving_wind_speed_10m         0
arriving_wind_direction_10m     0
arriving_wind_gusts_10m         0
dtype: int64

I've redeployed the vetiver model a couple of times and the nulls do reproduce.