neulab / explainaboard_client

1 stars 1 forks source link

Check api version and prompt for auto-upgrade #55

Closed OscarWang114 closed 1 year ago

OscarWang114 commented 1 year ago

This PR ensures that every API request from the client has the X-API-version header attached. The client program handles version mismatch errors from the server and raises APIVersionMismatchException with upgrade instructions included. This allows users who are running the client through another program to handle the error the way customarily.

If the user is interacting via the CLI, it prompts for auto-upgrade. On input y (or any positive string accepted by distutils.util.strtobool), the CLI performs the auto-upgrade and exits. Similarly, on n, it instructs to upgrade manually and exits.

Tests (both for the client and CLI) are added to ensure it works.

OscarWang114 commented 1 year ago

@neubig Thanks, I didn't think of this use case and agree! Let me work on it.