<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def grid_deploy(site, nodes, options):
 """Deploy and wait for the deployment to be finished. Args: site(str):
 the site nodes(list):
 list of nodes (str) to depoy options(dict):
 option of the deployment (refer to the Grid'5000 API Specifications) Returns: tuple of deployed(list), undeployed(list) nodes. """

    gk = get_api_client()
    environment = options.pop("env_name")
    options.update(environment=environment)
    options.update(nodes=nodes)
    key_path = DEFAULT_SSH_KEYFILE
    options.update(key=key_path.read_text())
    logger.info("Deploying %s with options %s" % (nodes, options))
    deployment = gk.sites[site].deployments.create(options)
    while deployment.status not in ["terminated", "error"]:
        deployment.refresh()
        print("Waiting for the end of deployment [%s]" % deployment.uid)
        time.sleep(10)

    deploy = []
    undeploy = []
    if deployment.status == "terminated":
        deploy = [node for node, v in deployment.result.items()
                  if v["state"] == "OK"]
        undeploy = [node for node, v in deployment.result.items()
                    if v["state"] == "KO"]
    elif deployment.status == "error":
        undeploy = nodes
    return deploy, undeploy