winter-telescope / winterapi

API interactions for WINTER
MIT License
1 stars 1 forks source link

Update documentation to note that the cache may have to be deleted when the backend API is updated #30

Closed geoffreymo closed 9 months ago

geoffreymo commented 9 months ago

In a previous version, I had added my program to a WinterAPI object, which saved my credentials and program to $HOME/.winter.txt (based on https://github.com/winter-telescope/winterapi/blob/main/winterapi/credentials.py#L37). Upon updating the package, attempting to make a new WinterAPI object failed with this error:

ValidationError                           Traceback (most recent call last)
Cell In[3], line 1
----> 1 winter = WinterAPI()

File ~/winter/winterapi/winterapi/messenger.py:62, in WinterAPI.__init__(self)
     61 def __init__(self):
---> 62     self.fidelius = Fidelius()
     63     ping = self.ping()
     64     if not ping:

File ~/winter/winterapi/winterapi/fidelius.py:29, in Fidelius.__init__(self)
     28 def __init__(self):
---> 29     self.credentials = self.load_secrets()

File ~/winter/winterapi/winterapi/fidelius.py:39, in Fidelius.load_secrets()
     33 """
     34 Load the secrets from the keyring.
     35 
     36 :return:
     37 """
     38 secret_dict = get_secrets()
---> 39 return WinterAPICredentials(**secret_dict)

File ~/miniconda3/envs/winter/lib/python3.11/site-packages/pydantic/main.py:164, in BaseModel.__init__(__pydantic_self__, **data)
    162 # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    163 __tracebackhide__ = True
--> 164 __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)

ValidationError: 1 validation error for WinterAPICredentials
programs.2023A010.hours_remaining
  Extra inputs are not permitted [type=extra_forbidden, input_value=100.0, input_type=float]
    For further information visit https://errors.pydantic.dev/2.5/v/extra_forbidden

Deleting the $HOME/.winter.txt and associated lockfile, then re-adding my credentials and program solved the problem for me. The documentation might need to be updated to suggest this when the package is updated. Another solution might be to save the version of WinterAPI with which a program was created into the secret_path, and prompting a reinstantiation of the program when a WinterAPI object is created with a newer version of winterapi.