import argparse
import requests

""" Post a request to server, let server init/save scheduler view. """
def post_http_request(api_url: str, action: str) -> requests.Response:
    headers = {"User-Agent": "Test Client"}
    pload = {
        "model": action,
        "prompt": "",
        "n": 1,
        "temperature": 0.0,
        "max_tokens": 16,
        "stream": True,
    }
    response = requests.post(api_url, headers=headers, json=pload, stream=True)
    return response


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--host", type=str, default="localhost")
    parser.add_argument("--port", type=int, default=6000)
    parser.add_argument("--action", type=str, default="save", choices=['init', 'save'])
    args = parser.parse_args()
    api_url = f"http://{args.host}:{args.port}/v1/completions"

    post_http_request(api_url, f"{args.action}_scheduler_view")
