prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  precommit flake8 check is missing files
  elasticdl/python/data/recordio_gen/sample_pyspark_recordio_gen/spark_gen_recordio.py is missed by the checker.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `elasticdl/python/data/codec/__init__.py`
  Content:
  ```
  1 from elasticdl.python.data.codec.bytes_codec import BytesCodec
  2 from elasticdl.python.data.codec.tf_example_codec import TFExampleCodec
  3 
  4 __all__ = [BytesCodec, TFExampleCodec]
  5
  ```
  
  Path: `elasticdl/python/data/recordio_gen/sample_pyspark_recordio_gen/spark_gen_recordio.py`
  Content:
  ```
  1 import argparse
  2 import os
  3 
  4 from pyspark import SparkContext
  5 from pyspark import TaskContext
  6 
  7 import numpy as np
  8 from elasticdl.python.elasticdl.common.model_helper import load_user_model
  9 from elasticdl.python.data.recordio_gen.convert_numpy_to_recordio import \
  10     convert_numpy_to_recordio
  11 
  12 
  13 def process_data(
  14     feature_label_columns,
  15     single_file_preparation_func,
  16     output_dir,
  17     records_per_file,
  18     codec_type,
  19 ):
  20     def _process_data(file_list):
  21         ctx = TaskContext()
  22         feature_list = []
  23         label_list = []
  24         for file in file_list:
  25             feature_label_tuple = single_file_preparation_func(file)
  26             assert len(feature_label_tuple) == 2
  27             feature_list.append(feature_label_tuple[0])
  28             label_list.append(feature_label_tuple[1])
  29         convert_numpy_to_recordio(
  30             output_dir,
  31             np.array(feature_list),
  32             np.array(label_list),
  33             feature_label_columns,
  34             records_per_file,
  35             codec_type,
  36             str(ctx.partitionId()),
  37         )
  38         return file_list
  39     return _process_data
  40 
  41 
  42 def main():
  43     parser = argparse.ArgumentParser(
  44         description="Spark job to convert training data to RecordIO format"
  45     )
  46     parser.add_argument(
  47         "--training_data_dir",
  48         help="Directory that contains training data and will be traversed \
  49             recursively",
  50         required=True,
  51     )
  52     parser.add_argument(
  53         "--output_dir",
  54         help="Directory of output RecordIO data",
  55         required=True,
  56     )
  57     parser.add_argument(
  58         "--model_file",
  59         required=True,
  60         help="User-defined model file which data processing logic is in",
  61     )
  62     parser.add_argument(
  63         "--records_per_file", default=1024, type=int, help="Record per file"
  64     )
  65     parser.add_argument(
  66         "--codec_type",
  67         default="tf_example",
  68         choices=["tf_example", "bytes"],
  69         help="Type of codec(tf_example or bytes)",
  70     )
  71     parser.add_argument(
  72         "--num_workers",
  73         default=2,
  74         type=int,
  75         help="Number of workers of Spark job",
  76     )
  77 
  78     args = parser.parse_args()
  79 
  80     # Get training data files recursively from training_data_dir
  81     file_list = []
  82     for dir_name, subdir_list, files in os.walk(args.training_data_dir):
  83         for fname in files:
  84             if not fname.startswith('.'):
  85                 file_list.append(os.path.join(dir_name, fname))
  86 
  87     # Load user-defined model
  88     model_module = load_user_model(args.model_file)
  89     
  90     if not os.path.exists(args.output_dir):
  91         os.makedirs(args.output_dir)
  92 
  93     # Start the Spark job
  94     sc = SparkContext()
  95     rdd = sc.parallelize(file_list, args.num_workers)
  96     rdd.mapPartitions(
  97         process_data(
  98             model_module.feature_columns() + model_module.label_columns(),
  99             model_module.prepare_data_for_a_single_file,
  100             args.output_dir,
  101             args.records_per_file,
  102             args.codec_type,
  103         )
  104     ).collect()
  105 
  106 
  107 if __name__ == "__main__":
  108     main()
  109
  ```
  --- 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/elasticdl/python/data/codec/__init__.py b/elasticdl/python/data/codec/__init__.py
  --- a/elasticdl/python/data/codec/__init__.py
  +++ b/elasticdl/python/data/codec/__init__.py
  @@ -1,4 +1,4 @@
   from elasticdl.python.data.codec.bytes_codec import BytesCodec
   from elasticdl.python.data.codec.tf_example_codec import TFExampleCodec
   
  -__all__ = [BytesCodec, TFExampleCodec]
  +__all__ = ["BytesCodec", "TFExampleCodec"]
  diff --git a/elasticdl/python/data/recordio_gen/sample_pyspark_recordio_gen/spark_gen_recordio.py b/elasticdl/python/data/recordio_gen/sample_pyspark_recordio_gen/spark_gen_recordio.py
  --- a/elasticdl/python/data/recordio_gen/sample_pyspark_recordio_gen/spark_gen_recordio.py
  +++ b/elasticdl/python/data/recordio_gen/sample_pyspark_recordio_gen/spark_gen_recordio.py
  @@ -6,8 +6,9 @@
   
   import numpy as np
   from elasticdl.python.elasticdl.common.model_helper import load_user_model
  -from elasticdl.python.data.recordio_gen.convert_numpy_to_recordio import \
  -    convert_numpy_to_recordio
  +from elasticdl.python.data.recordio_gen.convert_numpy_to_recordio import (
  +    convert_numpy_to_recordio,
  +)
   
   
   def process_data(
  @@ -36,6 +37,7 @@
               str(ctx.partitionId()),
           )
           return file_list
  +
       return _process_data
   
   
  @@ -50,9 +52,7 @@
           required=True,
       )
       parser.add_argument(
  -        "--output_dir",
  -        help="Directory of output RecordIO data",
  -        required=True,
  +        "--output_dir", help="Directory of output RecordIO data", required=True
       )
       parser.add_argument(
           "--model_file",
  @@ -81,12 +81,12 @@
       file_list = []
       for dir_name, subdir_list, files in os.walk(args.training_data_dir):
           for fname in files:
  -            if not fname.startswith('.'):
  +            if not fname.startswith("."):
                   file_list.append(os.path.join(dir_name, fname))
   
       # Load user-defined model
       model_module = load_user_model(args.model_file)
  -    
  +
       if not os.path.exists(args.output_dir):
           os.makedirs(args.output_dir)
  
verification_info: {"golden_diff": "diff --git a/elasticdl/python/data/codec/__init__.py b/elasticdl/python/data/codec/__init__.py\n--- a/elasticdl/python/data/codec/__init__.py\n+++ b/elasticdl/python/data/codec/__init__.py\n@@ -1,4 +1,4 @@\n from elasticdl.python.data.codec.bytes_codec import BytesCodec\n from elasticdl.python.data.codec.tf_example_codec import TFExampleCodec\n \n-__all__ = [BytesCodec, TFExampleCodec]\n+__all__ = [\"BytesCodec\", \"TFExampleCodec\"]\ndiff --git a/elasticdl/python/data/recordio_gen/sample_pyspark_recordio_gen/spark_gen_recordio.py b/elasticdl/python/data/recordio_gen/sample_pyspark_recordio_gen/spark_gen_recordio.py\n--- a/elasticdl/python/data/recordio_gen/sample_pyspark_recordio_gen/spark_gen_recordio.py\n+++ b/elasticdl/python/data/recordio_gen/sample_pyspark_recordio_gen/spark_gen_recordio.py\n@@ -6,8 +6,9 @@\n \n import numpy as np\n from elasticdl.python.elasticdl.common.model_helper import load_user_model\n-from elasticdl.python.data.recordio_gen.convert_numpy_to_recordio import \\\n-    convert_numpy_to_recordio\n+from elasticdl.python.data.recordio_gen.convert_numpy_to_recordio import (\n+    convert_numpy_to_recordio,\n+)\n \n \n def process_data(\n@@ -36,6 +37,7 @@\n             str(ctx.partitionId()),\n         )\n         return file_list\n+\n     return _process_data\n \n \n@@ -50,9 +52,7 @@\n         required=True,\n     )\n     parser.add_argument(\n-        \"--output_dir\",\n-        help=\"Directory of output RecordIO data\",\n-        required=True,\n+        \"--output_dir\", help=\"Directory of output RecordIO data\", required=True\n     )\n     parser.add_argument(\n         \"--model_file\",\n@@ -81,12 +81,12 @@\n     file_list = []\n     for dir_name, subdir_list, files in os.walk(args.training_data_dir):\n         for fname in files:\n-            if not fname.startswith('.'):\n+            if not fname.startswith(\".\"):\n                 file_list.append(os.path.join(dir_name, fname))\n \n     # Load user-defined model\n     model_module = load_user_model(args.model_file)\n-    \n+\n     if not os.path.exists(args.output_dir):\n         os.makedirs(args.output_dir)\n", "issue": "precommit flake8 check is missing files\nelasticdl/python/data/recordio_gen/sample_pyspark_recordio_gen/spark_gen_recordio.py is missed by the checker.\n", "before_files": [{"content": "from elasticdl.python.data.codec.bytes_codec import BytesCodec\nfrom elasticdl.python.data.codec.tf_example_codec import TFExampleCodec\n\n__all__ = [BytesCodec, TFExampleCodec]\n", "path": "elasticdl/python/data/codec/__init__.py"}, {"content": "import argparse\nimport os\n\nfrom pyspark import SparkContext\nfrom pyspark import TaskContext\n\nimport numpy as np\nfrom elasticdl.python.elasticdl.common.model_helper import load_user_model\nfrom elasticdl.python.data.recordio_gen.convert_numpy_to_recordio import \\\n    convert_numpy_to_recordio\n\n\ndef process_data(\n    feature_label_columns,\n    single_file_preparation_func,\n    output_dir,\n    records_per_file,\n    codec_type,\n):\n    def _process_data(file_list):\n        ctx = TaskContext()\n        feature_list = []\n        label_list = []\n        for file in file_list:\n            feature_label_tuple = single_file_preparation_func(file)\n            assert len(feature_label_tuple) == 2\n            feature_list.append(feature_label_tuple[0])\n            label_list.append(feature_label_tuple[1])\n        convert_numpy_to_recordio(\n            output_dir,\n            np.array(feature_list),\n            np.array(label_list),\n            feature_label_columns,\n            records_per_file,\n            codec_type,\n            str(ctx.partitionId()),\n        )\n        return file_list\n    return _process_data\n\n\ndef main():\n    parser = argparse.ArgumentParser(\n        description=\"Spark job to convert training data to RecordIO format\"\n    )\n    parser.add_argument(\n        \"--training_data_dir\",\n        help=\"Directory that contains training data and will be traversed \\\n            recursively\",\n        required=True,\n    )\n    parser.add_argument(\n        \"--output_dir\",\n        help=\"Directory of output RecordIO data\",\n        required=True,\n    )\n    parser.add_argument(\n        \"--model_file\",\n        required=True,\n        help=\"User-defined model file which data processing logic is in\",\n    )\n    parser.add_argument(\n        \"--records_per_file\", default=1024, type=int, help=\"Record per file\"\n    )\n    parser.add_argument(\n        \"--codec_type\",\n        default=\"tf_example\",\n        choices=[\"tf_example\", \"bytes\"],\n        help=\"Type of codec(tf_example or bytes)\",\n    )\n    parser.add_argument(\n        \"--num_workers\",\n        default=2,\n        type=int,\n        help=\"Number of workers of Spark job\",\n    )\n\n    args = parser.parse_args()\n\n    # Get training data files recursively from training_data_dir\n    file_list = []\n    for dir_name, subdir_list, files in os.walk(args.training_data_dir):\n        for fname in files:\n            if not fname.startswith('.'):\n                file_list.append(os.path.join(dir_name, fname))\n\n    # Load user-defined model\n    model_module = load_user_model(args.model_file)\n    \n    if not os.path.exists(args.output_dir):\n        os.makedirs(args.output_dir)\n\n    # Start the Spark job\n    sc = SparkContext()\n    rdd = sc.parallelize(file_list, args.num_workers)\n    rdd.mapPartitions(\n        process_data(\n            model_module.feature_columns() + model_module.label_columns(),\n            model_module.prepare_data_for_a_single_file,\n            args.output_dir,\n            args.records_per_file,\n            args.codec_type,\n        )\n    ).collect()\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "elasticdl/python/data/recordio_gen/sample_pyspark_recordio_gen/spark_gen_recordio.py"}], "after_files": [{"content": "from elasticdl.python.data.codec.bytes_codec import BytesCodec\nfrom elasticdl.python.data.codec.tf_example_codec import TFExampleCodec\n\n__all__ = [\"BytesCodec\", \"TFExampleCodec\"]\n", "path": "elasticdl/python/data/codec/__init__.py"}, {"content": "import argparse\nimport os\n\nfrom pyspark import SparkContext\nfrom pyspark import TaskContext\n\nimport numpy as np\nfrom elasticdl.python.elasticdl.common.model_helper import load_user_model\nfrom elasticdl.python.data.recordio_gen.convert_numpy_to_recordio import (\n    convert_numpy_to_recordio,\n)\n\n\ndef process_data(\n    feature_label_columns,\n    single_file_preparation_func,\n    output_dir,\n    records_per_file,\n    codec_type,\n):\n    def _process_data(file_list):\n        ctx = TaskContext()\n        feature_list = []\n        label_list = []\n        for file in file_list:\n            feature_label_tuple = single_file_preparation_func(file)\n            assert len(feature_label_tuple) == 2\n            feature_list.append(feature_label_tuple[0])\n            label_list.append(feature_label_tuple[1])\n        convert_numpy_to_recordio(\n            output_dir,\n            np.array(feature_list),\n            np.array(label_list),\n            feature_label_columns,\n            records_per_file,\n            codec_type,\n            str(ctx.partitionId()),\n        )\n        return file_list\n\n    return _process_data\n\n\ndef main():\n    parser = argparse.ArgumentParser(\n        description=\"Spark job to convert training data to RecordIO format\"\n    )\n    parser.add_argument(\n        \"--training_data_dir\",\n        help=\"Directory that contains training data and will be traversed \\\n            recursively\",\n        required=True,\n    )\n    parser.add_argument(\n        \"--output_dir\", help=\"Directory of output RecordIO data\", required=True\n    )\n    parser.add_argument(\n        \"--model_file\",\n        required=True,\n        help=\"User-defined model file which data processing logic is in\",\n    )\n    parser.add_argument(\n        \"--records_per_file\", default=1024, type=int, help=\"Record per file\"\n    )\n    parser.add_argument(\n        \"--codec_type\",\n        default=\"tf_example\",\n        choices=[\"tf_example\", \"bytes\"],\n        help=\"Type of codec(tf_example or bytes)\",\n    )\n    parser.add_argument(\n        \"--num_workers\",\n        default=2,\n        type=int,\n        help=\"Number of workers of Spark job\",\n    )\n\n    args = parser.parse_args()\n\n    # Get training data files recursively from training_data_dir\n    file_list = []\n    for dir_name, subdir_list, files in os.walk(args.training_data_dir):\n        for fname in files:\n            if not fname.startswith(\".\"):\n                file_list.append(os.path.join(dir_name, fname))\n\n    # Load user-defined model\n    model_module = load_user_model(args.model_file)\n\n    if not os.path.exists(args.output_dir):\n        os.makedirs(args.output_dir)\n\n    # Start the Spark job\n    sc = SparkContext()\n    rdd = sc.parallelize(file_list, args.num_workers)\n    rdd.mapPartitions(\n        process_data(\n            model_module.feature_columns() + model_module.label_columns(),\n            model_module.prepare_data_for_a_single_file,\n            args.output_dir,\n            args.records_per_file,\n            args.codec_type,\n        )\n    ).collect()\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "elasticdl/python/data/recordio_gen/sample_pyspark_recordio_gen/spark_gen_recordio.py"}]}