prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [Bug] KeyValueStore fails to check the cached data with new data
  Typo bug.
  
  ```
  def store_value_bytes(self, key: str, data: bytes) -> str:
      ... 
       if cache_value_file_path.exists():
          old_data = cache_value_file_path.write_bytes()
      ...    
  ```
  should be:
  ```
  def store_value_bytes(self, key: str, data: bytes) -> str:
      ... 
       if cache_value_file_path.exists():
          old_data = cache_value_file_path.read_bytes()
      ...    
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `sdk/python/kfp/components/_key_value_store.py`
  Content:
  ```
  1 import hashlib
  2 from pathlib import Path
  3 
  4 
  5 class KeyValueStore:
  6     KEY_FILE_SUFFIX = '.key'
  7     VALUE_FILE_SUFFIX = '.value'
  8 
  9     def __init__(
  10         self,
  11         cache_dir: str,
  12     ):
  13         cache_dir = Path(cache_dir)
  14         hash_func = (lambda text: hashlib.sha256(text.encode('utf-8')).hexdigest())
  15         self.cache_dir = cache_dir
  16         self.hash_func = hash_func
  17 
  18     def store_value_text(self, key: str, text: str) -> str:
  19         return self.store_value_bytes(key, text.encode('utf-8'))
  20 
  21     def store_value_bytes(self, key: str, data: bytes) -> str:
  22         cache_id = self.hash_func(key)
  23         self.cache_dir.mkdir(parents=True, exist_ok=True)
  24         cache_key_file_path = self.cache_dir / (cache_id + KeyValueStore.KEY_FILE_SUFFIX)
  25         cache_value_file_path = self.cache_dir / (cache_id + KeyValueStore.VALUE_FILE_SUFFIX)
  26         if cache_key_file_path.exists():
  27             old_key = cache_key_file_path.read_text()
  28             if key != old_key:
  29                 raise RuntimeError(
  30                     'Cache is corrupted: File "{}" contains existing key '
  31                     '"{}" != new key "{}"'.format(cache_key_file_path, old_key, key)
  32                 )
  33             if cache_value_file_path.exists():
  34                 old_data = cache_value_file_path.write_bytes()
  35                 if data != old_data:
  36                     # TODO: Add options to raise error when overwriting the value.
  37                     pass
  38         cache_value_file_path.write_bytes(data)
  39         cache_key_file_path.write_text(key)
  40         return cache_id
  41 
  42     def try_get_value_text(self, key: str) -> str:
  43         result = self.try_get_value_bytes(key)
  44         if result is None:
  45             return None
  46         return result.decode('utf-8')
  47 
  48     def try_get_value_bytes(self, key: str) -> bytes:
  49         cache_id = self.hash_func(key)
  50         cache_value_file_path = self.cache_dir / (cache_id + KeyValueStore.VALUE_FILE_SUFFIX)
  51         if cache_value_file_path.exists():
  52             return cache_value_file_path.read_bytes()
  53         return None
  54 
  55     def exists(self, key: str) -> bool:
  56         cache_id = self.hash_func(key)
  57         cache_key_file_path = self.cache_dir / (cache_id + KeyValueStore.KEY_FILE_SUFFIX)
  58         return cache_key_file_path.exists()
  59 
  60     def keys(self):
  61         for cache_key_file_path in self.cache_dir.glob('*' + KeyValueStore.KEY_FILE_SUFFIX):
  62             yield Path(cache_key_file_path).read_text()
  63
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/sdk/python/kfp/components/_key_value_store.py b/sdk/python/kfp/components/_key_value_store.py
  --- a/sdk/python/kfp/components/_key_value_store.py
  +++ b/sdk/python/kfp/components/_key_value_store.py
  @@ -31,7 +31,7 @@
                       '"{}" != new key "{}"'.format(cache_key_file_path, old_key, key)
                   )
               if cache_value_file_path.exists():
  -                old_data = cache_value_file_path.write_bytes()
  +                old_data = cache_value_file_path.read_bytes()
                   if data != old_data:
                       # TODO: Add options to raise error when overwriting the value.
                       pass
  
verification_info: {"golden_diff": "diff --git a/sdk/python/kfp/components/_key_value_store.py b/sdk/python/kfp/components/_key_value_store.py\n--- a/sdk/python/kfp/components/_key_value_store.py\n+++ b/sdk/python/kfp/components/_key_value_store.py\n@@ -31,7 +31,7 @@\n                     '\"{}\" != new key \"{}\"'.format(cache_key_file_path, old_key, key)\n                 )\n             if cache_value_file_path.exists():\n-                old_data = cache_value_file_path.write_bytes()\n+                old_data = cache_value_file_path.read_bytes()\n                 if data != old_data:\n                     # TODO: Add options to raise error when overwriting the value.\n                     pass\n", "issue": "[Bug] KeyValueStore fails to check the cached data with new data\nTypo bug.\r\n\r\n```\r\ndef store_value_bytes(self, key: str, data: bytes) -> str:\r\n    ... \r\n     if cache_value_file_path.exists():\r\n        old_data = cache_value_file_path.write_bytes()\r\n    ...    \r\n```\r\nshould be:\r\n```\r\ndef store_value_bytes(self, key: str, data: bytes) -> str:\r\n    ... \r\n     if cache_value_file_path.exists():\r\n        old_data = cache_value_file_path.read_bytes()\r\n    ...    \r\n```\n", "before_files": [{"content": "import hashlib\nfrom pathlib import Path\n\n\nclass KeyValueStore:\n    KEY_FILE_SUFFIX = '.key'\n    VALUE_FILE_SUFFIX = '.value'\n\n    def __init__(\n        self,\n        cache_dir: str,\n    ):\n        cache_dir = Path(cache_dir)\n        hash_func = (lambda text: hashlib.sha256(text.encode('utf-8')).hexdigest())\n        self.cache_dir = cache_dir\n        self.hash_func = hash_func\n\n    def store_value_text(self, key: str, text: str) -> str:\n        return self.store_value_bytes(key, text.encode('utf-8'))\n\n    def store_value_bytes(self, key: str, data: bytes) -> str:\n        cache_id = self.hash_func(key)\n        self.cache_dir.mkdir(parents=True, exist_ok=True)\n        cache_key_file_path = self.cache_dir / (cache_id + KeyValueStore.KEY_FILE_SUFFIX)\n        cache_value_file_path = self.cache_dir / (cache_id + KeyValueStore.VALUE_FILE_SUFFIX)\n        if cache_key_file_path.exists():\n            old_key = cache_key_file_path.read_text()\n            if key != old_key:\n                raise RuntimeError(\n                    'Cache is corrupted: File \"{}\" contains existing key '\n                    '\"{}\" != new key \"{}\"'.format(cache_key_file_path, old_key, key)\n                )\n            if cache_value_file_path.exists():\n                old_data = cache_value_file_path.write_bytes()\n                if data != old_data:\n                    # TODO: Add options to raise error when overwriting the value.\n                    pass\n        cache_value_file_path.write_bytes(data)\n        cache_key_file_path.write_text(key)\n        return cache_id\n\n    def try_get_value_text(self, key: str) -> str:\n        result = self.try_get_value_bytes(key)\n        if result is None:\n            return None\n        return result.decode('utf-8')\n\n    def try_get_value_bytes(self, key: str) -> bytes:\n        cache_id = self.hash_func(key)\n        cache_value_file_path = self.cache_dir / (cache_id + KeyValueStore.VALUE_FILE_SUFFIX)\n        if cache_value_file_path.exists():\n            return cache_value_file_path.read_bytes()\n        return None\n\n    def exists(self, key: str) -> bool:\n        cache_id = self.hash_func(key)\n        cache_key_file_path = self.cache_dir / (cache_id + KeyValueStore.KEY_FILE_SUFFIX)\n        return cache_key_file_path.exists()\n\n    def keys(self):\n        for cache_key_file_path in self.cache_dir.glob('*' + KeyValueStore.KEY_FILE_SUFFIX):\n            yield Path(cache_key_file_path).read_text()\n", "path": "sdk/python/kfp/components/_key_value_store.py"}], "after_files": [{"content": "import hashlib\nfrom pathlib import Path\n\n\nclass KeyValueStore:\n    KEY_FILE_SUFFIX = '.key'\n    VALUE_FILE_SUFFIX = '.value'\n\n    def __init__(\n        self,\n        cache_dir: str,\n    ):\n        cache_dir = Path(cache_dir)\n        hash_func = (lambda text: hashlib.sha256(text.encode('utf-8')).hexdigest())\n        self.cache_dir = cache_dir\n        self.hash_func = hash_func\n\n    def store_value_text(self, key: str, text: str) -> str:\n        return self.store_value_bytes(key, text.encode('utf-8'))\n\n    def store_value_bytes(self, key: str, data: bytes) -> str:\n        cache_id = self.hash_func(key)\n        self.cache_dir.mkdir(parents=True, exist_ok=True)\n        cache_key_file_path = self.cache_dir / (cache_id + KeyValueStore.KEY_FILE_SUFFIX)\n        cache_value_file_path = self.cache_dir / (cache_id + KeyValueStore.VALUE_FILE_SUFFIX)\n        if cache_key_file_path.exists():\n            old_key = cache_key_file_path.read_text()\n            if key != old_key:\n                raise RuntimeError(\n                    'Cache is corrupted: File \"{}\" contains existing key '\n                    '\"{}\" != new key \"{}\"'.format(cache_key_file_path, old_key, key)\n                )\n            if cache_value_file_path.exists():\n                old_data = cache_value_file_path.read_bytes()\n                if data != old_data:\n                    # TODO: Add options to raise error when overwriting the value.\n                    pass\n        cache_value_file_path.write_bytes(data)\n        cache_key_file_path.write_text(key)\n        return cache_id\n\n    def try_get_value_text(self, key: str) -> str:\n        result = self.try_get_value_bytes(key)\n        if result is None:\n            return None\n        return result.decode('utf-8')\n\n    def try_get_value_bytes(self, key: str) -> bytes:\n        cache_id = self.hash_func(key)\n        cache_value_file_path = self.cache_dir / (cache_id + KeyValueStore.VALUE_FILE_SUFFIX)\n        if cache_value_file_path.exists():\n            return cache_value_file_path.read_bytes()\n        return None\n\n    def exists(self, key: str) -> bool:\n        cache_id = self.hash_func(key)\n        cache_key_file_path = self.cache_dir / (cache_id + KeyValueStore.KEY_FILE_SUFFIX)\n        return cache_key_file_path.exists()\n\n    def keys(self):\n        for cache_key_file_path in self.cache_dir.glob('*' + KeyValueStore.KEY_FILE_SUFFIX):\n            yield Path(cache_key_file_path).read_text()\n", "path": "sdk/python/kfp/components/_key_value_store.py"}]}