prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Help doesn't render with FlagValuesProxy.
  Example:
  
  ```
  [:~/git/PerfKitBenchmarker] [perfkit] release-0.23.0+* 1 ± python pkb.py --benchmarks redis_ycsb  --machine_type n1-standard-4 --json_output redis_ycsb.json
  ERROR:root:Unknown command line flag 'json_output'
  Usage: pkb.py ARGS
  <perfkitbenchmarker.context.FlagValuesProxy object at 0x7f51910bc050>
  ```
  
  @ehankland - do you have a minute to look at this? If not assign back to me.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `perfkitbenchmarker/context.py`
  Content:
  ```
  1 # Copyright 2015 Google Inc. All rights reserved.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #   http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 """Module for working with the current thread context."""
  16 
  17 import threading
  18 
  19 import gflags as flags
  20 
  21 
  22 class FlagsModuleProxy(object):
  23   """Class which acts as a proxy for the flags module.
  24 
  25   When the FLAGS attribute is accessed, BENCHMARK_FLAGS will be returned
  26   rather than the global FlagValues object. BENCHMARK_FLAGS is an instance
  27   of FlagValuesProxy, which enables benchmarks to run with different and
  28   even conflicting flags. Accessing the GLOBAL_FLAGS attribute will return
  29   the global FlagValues object. Otherwise, this will behave just like the
  30   flags module.
  31   """
  32 
  33   def __getattr__(self, name):
  34     if name == 'FLAGS':
  35       return BENCHMARK_FLAGS
  36     elif name == 'GLOBAL_FLAGS':
  37       return flags.FLAGS
  38     return flags.__dict__[name]
  39 
  40 
  41 class FlagValuesProxy(object):
  42   """Class which provides the same interface as FlagValues.
  43 
  44   By acting as a proxy for the FlagValues object (i.e. flags.FLAGS),
  45   this enables benchmark specific flags. This proxy attempts to
  46   use the current thread's BenchmarkSpec's FlagValues object, but
  47   falls back to using flags.FLAGS if the thread has no BenchmarkSpec
  48   object.
  49   """
  50 
  51   @property
  52   def _thread_flag_values(self):
  53     """Returns the correct FlagValues object for the current thread.
  54 
  55     This first tries to get the BenchmarkSpec object corresponding to the
  56     current thread. If there is one, it returns that spec's FlagValues
  57     object. If there isn't one, it will return the global FlagValues
  58     object.
  59     """
  60     benchmark_spec = GetThreadBenchmarkSpec()
  61     if benchmark_spec:
  62       return benchmark_spec.FLAGS
  63     else:
  64       return flags.FLAGS
  65 
  66   def __setattr__(self, name, value):
  67     self._thread_flag_values.__setattr__(name, value)
  68 
  69   def __getattr__(self, name):
  70     return self._thread_flag_values.__getattr__(name)
  71 
  72   def __setitem__(self, key, value):
  73     self._thread_flag_values.__setitem__(key, value)
  74 
  75   def __getitem__(self, key):
  76     return self._thread_flag_values.__getitem__(key)
  77 
  78   def __call__(self, argv):
  79     return self._thread_flag_values.__call__(argv)
  80 
  81   def FlagDict(self):
  82     return self._thread_flag_values.FlagDict()
  83 
  84 
  85 BENCHMARK_FLAGS = FlagValuesProxy()
  86 
  87 
  88 class _ThreadData(threading.local):
  89   def __init__(self):
  90     self.benchmark_spec = None
  91 
  92 
  93 _thread_local = _ThreadData()
  94 
  95 
  96 def SetThreadBenchmarkSpec(benchmark_spec):
  97   """Sets the current thread's BenchmarkSpec object."""
  98   _thread_local.benchmark_spec = benchmark_spec
  99 
  100 
  101 def GetThreadBenchmarkSpec():
  102   """Gets the current thread's BenchmarkSpec object.
  103 
  104   If SetThreadBenchmarkSpec() has not been called in either the current thread
  105   or in an ancestor, then this method will return None by default.
  106   """
  107   return _thread_local.benchmark_spec
  108
  ```
  --- 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/perfkitbenchmarker/context.py b/perfkitbenchmarker/context.py
  --- a/perfkitbenchmarker/context.py
  +++ b/perfkitbenchmarker/context.py
  @@ -63,23 +63,24 @@
       else:
         return flags.FLAGS
   
  -  def __setattr__(self, name, value):
  -    self._thread_flag_values.__setattr__(name, value)
   
  -  def __getattr__(self, name):
  -    return self._thread_flag_values.__getattr__(name)
  -
  -  def __setitem__(self, key, value):
  -    self._thread_flag_values.__setitem__(key, value)
  -
  -  def __getitem__(self, key):
  -    return self._thread_flag_values.__getitem__(key)
  -
  -  def __call__(self, argv):
  -    return self._thread_flag_values.__call__(argv)
  -
  -  def FlagDict(self):
  -    return self._thread_flag_values.FlagDict()
  +def _AddProxyMethod(f_name):
  +  """Adds a method to FlagValuesProxy that forwards to _thread_flag_values."""
  +  def f(self, *args, **kwargs):
  +    return getattr(self._thread_flag_values, f_name)(*args, **kwargs)
  +  f.__name__ = f_name
  +  f.__doc__ = 'Proxied ' + f_name
  +  setattr(FlagValuesProxy, f_name, f)
  +
  +
  +# TODO: introduce a more generic proxy.
  +for _f_name in ['FlagDict', 'Reset', 'SetDefault', 'RegisteredFlags',
  +                'FlagValuesDict', '__contains__', '__iter__', '__call__',
  +                '__setattr__', '__getattr__', '__setitem__', '__getitem__',
  +                '__str__']:
  +  _AddProxyMethod(_f_name)
  +del _f_name
  +del _AddProxyMethod
   
   
   BENCHMARK_FLAGS = FlagValuesProxy()
  
verification_info: {"golden_diff": "diff --git a/perfkitbenchmarker/context.py b/perfkitbenchmarker/context.py\n--- a/perfkitbenchmarker/context.py\n+++ b/perfkitbenchmarker/context.py\n@@ -63,23 +63,24 @@\n     else:\n       return flags.FLAGS\n \n-  def __setattr__(self, name, value):\n-    self._thread_flag_values.__setattr__(name, value)\n \n-  def __getattr__(self, name):\n-    return self._thread_flag_values.__getattr__(name)\n-\n-  def __setitem__(self, key, value):\n-    self._thread_flag_values.__setitem__(key, value)\n-\n-  def __getitem__(self, key):\n-    return self._thread_flag_values.__getitem__(key)\n-\n-  def __call__(self, argv):\n-    return self._thread_flag_values.__call__(argv)\n-\n-  def FlagDict(self):\n-    return self._thread_flag_values.FlagDict()\n+def _AddProxyMethod(f_name):\n+  \"\"\"Adds a method to FlagValuesProxy that forwards to _thread_flag_values.\"\"\"\n+  def f(self, *args, **kwargs):\n+    return getattr(self._thread_flag_values, f_name)(*args, **kwargs)\n+  f.__name__ = f_name\n+  f.__doc__ = 'Proxied ' + f_name\n+  setattr(FlagValuesProxy, f_name, f)\n+\n+\n+# TODO: introduce a more generic proxy.\n+for _f_name in ['FlagDict', 'Reset', 'SetDefault', 'RegisteredFlags',\n+                'FlagValuesDict', '__contains__', '__iter__', '__call__',\n+                '__setattr__', '__getattr__', '__setitem__', '__getitem__',\n+                '__str__']:\n+  _AddProxyMethod(_f_name)\n+del _f_name\n+del _AddProxyMethod\n \n \n BENCHMARK_FLAGS = FlagValuesProxy()\n", "issue": "Help doesn't render with FlagValuesProxy.\nExample:\n\n```\n[:~/git/PerfKitBenchmarker] [perfkit] release-0.23.0+* 1 \u00b1 python pkb.py --benchmarks redis_ycsb  --machine_type n1-standard-4 --json_output redis_ycsb.json\nERROR:root:Unknown command line flag 'json_output'\nUsage: pkb.py ARGS\n<perfkitbenchmarker.context.FlagValuesProxy object at 0x7f51910bc050>\n```\n\n@ehankland - do you have a minute to look at this? If not assign back to me.\n\n", "before_files": [{"content": "# Copyright 2015 Google Inc. All rights reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#   http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Module for working with the current thread context.\"\"\"\n\nimport threading\n\nimport gflags as flags\n\n\nclass FlagsModuleProxy(object):\n  \"\"\"Class which acts as a proxy for the flags module.\n\n  When the FLAGS attribute is accessed, BENCHMARK_FLAGS will be returned\n  rather than the global FlagValues object. BENCHMARK_FLAGS is an instance\n  of FlagValuesProxy, which enables benchmarks to run with different and\n  even conflicting flags. Accessing the GLOBAL_FLAGS attribute will return\n  the global FlagValues object. Otherwise, this will behave just like the\n  flags module.\n  \"\"\"\n\n  def __getattr__(self, name):\n    if name == 'FLAGS':\n      return BENCHMARK_FLAGS\n    elif name == 'GLOBAL_FLAGS':\n      return flags.FLAGS\n    return flags.__dict__[name]\n\n\nclass FlagValuesProxy(object):\n  \"\"\"Class which provides the same interface as FlagValues.\n\n  By acting as a proxy for the FlagValues object (i.e. flags.FLAGS),\n  this enables benchmark specific flags. This proxy attempts to\n  use the current thread's BenchmarkSpec's FlagValues object, but\n  falls back to using flags.FLAGS if the thread has no BenchmarkSpec\n  object.\n  \"\"\"\n\n  @property\n  def _thread_flag_values(self):\n    \"\"\"Returns the correct FlagValues object for the current thread.\n\n    This first tries to get the BenchmarkSpec object corresponding to the\n    current thread. If there is one, it returns that spec's FlagValues\n    object. If there isn't one, it will return the global FlagValues\n    object.\n    \"\"\"\n    benchmark_spec = GetThreadBenchmarkSpec()\n    if benchmark_spec:\n      return benchmark_spec.FLAGS\n    else:\n      return flags.FLAGS\n\n  def __setattr__(self, name, value):\n    self._thread_flag_values.__setattr__(name, value)\n\n  def __getattr__(self, name):\n    return self._thread_flag_values.__getattr__(name)\n\n  def __setitem__(self, key, value):\n    self._thread_flag_values.__setitem__(key, value)\n\n  def __getitem__(self, key):\n    return self._thread_flag_values.__getitem__(key)\n\n  def __call__(self, argv):\n    return self._thread_flag_values.__call__(argv)\n\n  def FlagDict(self):\n    return self._thread_flag_values.FlagDict()\n\n\nBENCHMARK_FLAGS = FlagValuesProxy()\n\n\nclass _ThreadData(threading.local):\n  def __init__(self):\n    self.benchmark_spec = None\n\n\n_thread_local = _ThreadData()\n\n\ndef SetThreadBenchmarkSpec(benchmark_spec):\n  \"\"\"Sets the current thread's BenchmarkSpec object.\"\"\"\n  _thread_local.benchmark_spec = benchmark_spec\n\n\ndef GetThreadBenchmarkSpec():\n  \"\"\"Gets the current thread's BenchmarkSpec object.\n\n  If SetThreadBenchmarkSpec() has not been called in either the current thread\n  or in an ancestor, then this method will return None by default.\n  \"\"\"\n  return _thread_local.benchmark_spec\n", "path": "perfkitbenchmarker/context.py"}], "after_files": [{"content": "# Copyright 2015 Google Inc. All rights reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#   http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Module for working with the current thread context.\"\"\"\n\nimport threading\n\nimport gflags as flags\n\n\nclass FlagsModuleProxy(object):\n  \"\"\"Class which acts as a proxy for the flags module.\n\n  When the FLAGS attribute is accessed, BENCHMARK_FLAGS will be returned\n  rather than the global FlagValues object. BENCHMARK_FLAGS is an instance\n  of FlagValuesProxy, which enables benchmarks to run with different and\n  even conflicting flags. Accessing the GLOBAL_FLAGS attribute will return\n  the global FlagValues object. Otherwise, this will behave just like the\n  flags module.\n  \"\"\"\n\n  def __getattr__(self, name):\n    if name == 'FLAGS':\n      return BENCHMARK_FLAGS\n    elif name == 'GLOBAL_FLAGS':\n      return flags.FLAGS\n    return flags.__dict__[name]\n\n\nclass FlagValuesProxy(object):\n  \"\"\"Class which provides the same interface as FlagValues.\n\n  By acting as a proxy for the FlagValues object (i.e. flags.FLAGS),\n  this enables benchmark specific flags. This proxy attempts to\n  use the current thread's BenchmarkSpec's FlagValues object, but\n  falls back to using flags.FLAGS if the thread has no BenchmarkSpec\n  object.\n  \"\"\"\n\n  @property\n  def _thread_flag_values(self):\n    \"\"\"Returns the correct FlagValues object for the current thread.\n\n    This first tries to get the BenchmarkSpec object corresponding to the\n    current thread. If there is one, it returns that spec's FlagValues\n    object. If there isn't one, it will return the global FlagValues\n    object.\n    \"\"\"\n    benchmark_spec = GetThreadBenchmarkSpec()\n    if benchmark_spec:\n      return benchmark_spec.FLAGS\n    else:\n      return flags.FLAGS\n\n\ndef _AddProxyMethod(f_name):\n  \"\"\"Adds a method to FlagValuesProxy that forwards to _thread_flag_values.\"\"\"\n  def f(self, *args, **kwargs):\n    return getattr(self._thread_flag_values, f_name)(*args, **kwargs)\n  f.__name__ = f_name\n  f.__doc__ = 'Proxied ' + f_name\n  setattr(FlagValuesProxy, f_name, f)\n\n\n# TODO: introduce a more generic proxy.\nfor _f_name in ['FlagDict', 'Reset', 'SetDefault', 'RegisteredFlags',\n                'FlagValuesDict', '__contains__', '__iter__', '__call__',\n                '__setattr__', '__getattr__', '__setitem__', '__getitem__',\n                '__str__']:\n  _AddProxyMethod(_f_name)\ndel _f_name\ndel _AddProxyMethod\n\n\nBENCHMARK_FLAGS = FlagValuesProxy()\n\n\nclass _ThreadData(threading.local):\n  def __init__(self):\n    self.benchmark_spec = None\n\n\n_thread_local = _ThreadData()\n\n\ndef SetThreadBenchmarkSpec(benchmark_spec):\n  \"\"\"Sets the current thread's BenchmarkSpec object.\"\"\"\n  _thread_local.benchmark_spec = benchmark_spec\n\n\ndef GetThreadBenchmarkSpec():\n  \"\"\"Gets the current thread's BenchmarkSpec object.\n\n  If SetThreadBenchmarkSpec() has not been called in either the current thread\n  or in an ancestor, then this method will return None by default.\n  \"\"\"\n  return _thread_local.benchmark_spec\n", "path": "perfkitbenchmarker/context.py"}]}