We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
data task error
*   Operating System:ubuntu22
*   Python Version Used:3.9
*   When you install doccano:2022-12-04
*   How did you install doccano (Heroku button etc):pip install doccano

<img width="732" alt="image" src="https://user-images.githubusercontent.com/43643599/205482588-64111fa6-23bc-4c19-ade7-a7fb4532b177.png">



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `backend/cli.py`
Content:
```
1 import argparse
2 import multiprocessing
3 import os
4 import platform
5 import sys
6 from pathlib import Path
7 
8 import django
9 from django.core import management
10 from environs import Env
11 
12 from .config.celery import app
13 
14 env = Env()
15 DOCCANO_HOME = os.path.expanduser(os.environ.get("DOCCANO_HOME", "~/doccano"))
16 Path(DOCCANO_HOME).mkdir(parents=True, exist_ok=True)
17 env.bool("DEBUG", False)
18 os.environ["STANDALONE"] = "True"
19 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
20 os.environ.setdefault("DATABASE_URL", os.path.join(f"sqlite:///{DOCCANO_HOME}", "db.sqlite3"))
21 os.environ.setdefault("MEDIA_ROOT", os.path.join(DOCCANO_HOME, "media"))
22 base = os.path.abspath(os.path.dirname(__file__))
23 sys.path.append(base)
24 parser = argparse.ArgumentParser(description="doccano, text annotation for machine learning practitioners.")
25 
26 
27 def number_of_workers():
28     return (multiprocessing.cpu_count() * 2) + 1
29 
30 
31 def is_windows():
32     return platform.system() == "Windows"
33 
34 
35 def run_on_nix(args):
36     import gunicorn.app.base
37     import gunicorn.util
38 
39     class StandaloneApplication(gunicorn.app.base.BaseApplication):
40         def __init__(self, options=None):
41             self.options = options or {}
42             super().__init__()
43 
44         def load_config(self):
45             config = {
46                 key: value for key, value in self.options.items() if key in self.cfg.settings and value is not None
47             }
48             for key, value in config.items():
49                 self.cfg.set(key.lower(), value)
50 
51         def load(self):
52             return gunicorn.util.import_app("config.wsgi")
53 
54     options = {
55         "bind": "%s:%s" % ("0.0.0.0", args.port),
56         "workers": args.workers,
57         "chdir": base,
58         "capture_output": True,
59         "loglevel": "info",
60     }
61     StandaloneApplication(options).run()
62 
63 
64 def run_on_windows(args):
65     from waitress import serve
66 
67     from config.wsgi import application
68 
69     serve(application, port=args.port, threads=args.workers)
70 
71 
72 def command_db_init(args):
73     print("Setup Database.")
74     management.call_command("wait_for_db")
75     management.call_command("migrate")
76     management.call_command("create_roles")
77 
78 
79 def command_user_create(args):
80     print("Create admin user.")
81     management.call_command(
82         "create_admin", "--noinput", username=args.username, password=args.password, email=args.email
83     )
84 
85 
86 def command_migrate(args):
87     print("Start migration.")
88     management.call_command("migrate")
89 
90 
91 def command_run_webserver(args):
92     print(f"Starting server with port {args.port}.")
93     if is_windows():
94         run_on_windows(args)
95     else:
96         run_on_nix(args)
97 
98 
99 def command_run_task_queue(args):
100     print("Starting task queue.")
101     argv = [
102         "--app=config",
103         "--workdir={}".format(base),
104         "worker",
105         "--loglevel=info",
106         "--concurrency={}".format(args.concurrency),
107     ]
108     if is_windows():
109         argv.append("--pool=solo")
110     app.worker_main(argv=argv)
111 
112 
113 def command_run_flower(args):
114     print("Starting flower.")
115     argv = [
116         "--app=config",
117         "--workdir={}".format(base),
118         "flower",
119     ]
120     if args.basic_auth:
121         argv.append("--basic_auth={}".format(args.basic_auth))
122     app.worker_main(argv=argv)
123 
124 
125 def command_help(args):
126     print(parser.parse_args([args.command, "--help"]))
127 
128 
129 def main():
130     # Create a command line parser.
131     subparsers = parser.add_subparsers()
132 
133     # Create a parser for db initialization.
134     parser_init = subparsers.add_parser("init", help="see `init -h`")
135     parser_init.set_defaults(handler=command_db_init)
136 
137     # Create a parser for migration.
138     parser_migration = subparsers.add_parser("migrate", help="Updates database schema.")
139     parser_migration.set_defaults(handler=command_migrate)
140 
141     # Create a parser for user creation.
142     parser_create_user = subparsers.add_parser("createuser", help="see `createuser -h`")
143     parser_create_user.add_argument("--username", type=str, default="admin", help="admin username")
144     parser_create_user.add_argument("--password", type=str, default="password", help="admin password")
145     parser_create_user.add_argument("--email", type=str, default="example@example.com", help="admin email")
146     parser_create_user.set_defaults(handler=command_user_create)
147 
148     # Create a parser for web server.
149     parser_server = subparsers.add_parser("webserver", help="see `webserver -h`")
150     parser_server.add_argument("--port", type=int, default=8000, help="port number")
151     parser_server.add_argument("--workers", type=int, default=number_of_workers(), help="the number of workers")
152     parser_server.add_argument("--env_file", type=str, help="read in a file of environment variables")
153     parser_server.set_defaults(handler=command_run_webserver)
154 
155     # Create a parser for task queue.
156     parser_queue = subparsers.add_parser("task", help="see `task -h`")
157     parser_queue.add_argument("--concurrency", type=int, default=2, help="concurrency")
158     parser_queue.add_argument("--env_file", type=str, default="", help="read in a file of environment variables")
159     parser_queue.set_defaults(handler=command_run_task_queue)
160 
161     parser_flower = subparsers.add_parser("flower", help="see `flower -h`")
162     parser_flower.add_argument("--env_file", type=str, help="read in a file of environment variables")
163     parser_flower.add_argument("--basic_auth", type=str, help="username and password for basic authentication")
164     parser_flower.set_defaults(handler=command_run_flower)
165 
166     # Create a parser for help.
167     parser_help = subparsers.add_parser("help", help="see `help -h`")
168     parser_help.add_argument("command", help="command name which help is shown")
169     parser_help.set_defaults(handler=command_help)
170 
171     # Dispatch handler.
172     args = parser.parse_args()
173     if hasattr(args, "env_file"):
174         env.read_env(args.env_file, recurse=False, override=True)
175     if hasattr(args, "handler"):
176         django.setup()
177         args.handler(args)
178     else:
179         # If specified unknown command, show help.
180         parser.print_help()
181 
182 
183 if __name__ == "__main__":
184     main()
185
```
--- 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()

```

diff --git a/backend/cli.py b/backend/cli.py
--- a/backend/cli.py
+++ b/backend/cli.py
@@ -155,7 +155,7 @@
     # Create a parser for task queue.
     parser_queue = subparsers.add_parser("task", help="see `task -h`")
     parser_queue.add_argument("--concurrency", type=int, default=2, help="concurrency")
-    parser_queue.add_argument("--env_file", type=str, default="", help="read in a file of environment variables")
+    parser_queue.add_argument("--env_file", type=str, help="read in a file of environment variables")
     parser_queue.set_defaults(handler=command_run_task_queue)
 
     parser_flower = subparsers.add_parser("flower", help="see `flower -h`")

{"golden_diff": "diff --git a/backend/cli.py b/backend/cli.py\n--- a/backend/cli.py\n+++ b/backend/cli.py\n@@ -155,7 +155,7 @@\n     # Create a parser for task queue.\n     parser_queue = subparsers.add_parser(\"task\", help=\"see `task -h`\")\n     parser_queue.add_argument(\"--concurrency\", type=int, default=2, help=\"concurrency\")\n-    parser_queue.add_argument(\"--env_file\", type=str, default=\"\", help=\"read in a file of environment variables\")\n+    parser_queue.add_argument(\"--env_file\", type=str, help=\"read in a file of environment variables\")\n     parser_queue.set_defaults(handler=command_run_task_queue)\n \n     parser_flower = subparsers.add_parser(\"flower\", help=\"see `flower -h`\")\n", "issue": "data task error\n*   Operating System:ubuntu22\r\n*   Python Version Used:3.9\r\n*   When you install doccano:2022-12-04\r\n*   How did you install doccano (Heroku button etc):pip install doccano\r\n\r\n<img width=\"732\" alt=\"image\" src=\"https://user-images.githubusercontent.com/43643599/205482588-64111fa6-23bc-4c19-ade7-a7fb4532b177.png\">\r\n\r\n\n", "before_files": [{"content": "import argparse\nimport multiprocessing\nimport os\nimport platform\nimport sys\nfrom pathlib import Path\n\nimport django\nfrom django.core import management\nfrom environs import Env\n\nfrom .config.celery import app\n\nenv = Env()\nDOCCANO_HOME = os.path.expanduser(os.environ.get(\"DOCCANO_HOME\", \"~/doccano\"))\nPath(DOCCANO_HOME).mkdir(parents=True, exist_ok=True)\nenv.bool(\"DEBUG\", False)\nos.environ[\"STANDALONE\"] = \"True\"\nos.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"config.settings.production\")\nos.environ.setdefault(\"DATABASE_URL\", os.path.join(f\"sqlite:///{DOCCANO_HOME}\", \"db.sqlite3\"))\nos.environ.setdefault(\"MEDIA_ROOT\", os.path.join(DOCCANO_HOME, \"media\"))\nbase = os.path.abspath(os.path.dirname(__file__))\nsys.path.append(base)\nparser = argparse.ArgumentParser(description=\"doccano, text annotation for machine learning practitioners.\")\n\n\ndef number_of_workers():\n    return (multiprocessing.cpu_count() * 2) + 1\n\n\ndef is_windows():\n    return platform.system() == \"Windows\"\n\n\ndef run_on_nix(args):\n    import gunicorn.app.base\n    import gunicorn.util\n\n    class StandaloneApplication(gunicorn.app.base.BaseApplication):\n        def __init__(self, options=None):\n            self.options = options or {}\n            super().__init__()\n\n        def load_config(self):\n            config = {\n                key: value for key, value in self.options.items() if key in self.cfg.settings and value is not None\n            }\n            for key, value in config.items():\n                self.cfg.set(key.lower(), value)\n\n        def load(self):\n            return gunicorn.util.import_app(\"config.wsgi\")\n\n    options = {\n        \"bind\": \"%s:%s\" % (\"0.0.0.0\", args.port),\n        \"workers\": args.workers,\n        \"chdir\": base,\n        \"capture_output\": True,\n        \"loglevel\": \"info\",\n    }\n    StandaloneApplication(options).run()\n\n\ndef run_on_windows(args):\n    from waitress import serve\n\n    from config.wsgi import application\n\n    serve(application, port=args.port, threads=args.workers)\n\n\ndef command_db_init(args):\n    print(\"Setup Database.\")\n    management.call_command(\"wait_for_db\")\n    management.call_command(\"migrate\")\n    management.call_command(\"create_roles\")\n\n\ndef command_user_create(args):\n    print(\"Create admin user.\")\n    management.call_command(\n        \"create_admin\", \"--noinput\", username=args.username, password=args.password, email=args.email\n    )\n\n\ndef command_migrate(args):\n    print(\"Start migration.\")\n    management.call_command(\"migrate\")\n\n\ndef command_run_webserver(args):\n    print(f\"Starting server with port {args.port}.\")\n    if is_windows():\n        run_on_windows(args)\n    else:\n        run_on_nix(args)\n\n\ndef command_run_task_queue(args):\n    print(\"Starting task queue.\")\n    argv = [\n        \"--app=config\",\n        \"--workdir={}\".format(base),\n        \"worker\",\n        \"--loglevel=info\",\n        \"--concurrency={}\".format(args.concurrency),\n    ]\n    if is_windows():\n        argv.append(\"--pool=solo\")\n    app.worker_main(argv=argv)\n\n\ndef command_run_flower(args):\n    print(\"Starting flower.\")\n    argv = [\n        \"--app=config\",\n        \"--workdir={}\".format(base),\n        \"flower\",\n    ]\n    if args.basic_auth:\n        argv.append(\"--basic_auth={}\".format(args.basic_auth))\n    app.worker_main(argv=argv)\n\n\ndef command_help(args):\n    print(parser.parse_args([args.command, \"--help\"]))\n\n\ndef main():\n    # Create a command line parser.\n    subparsers = parser.add_subparsers()\n\n    # Create a parser for db initialization.\n    parser_init = subparsers.add_parser(\"init\", help=\"see `init -h`\")\n    parser_init.set_defaults(handler=command_db_init)\n\n    # Create a parser for migration.\n    parser_migration = subparsers.add_parser(\"migrate\", help=\"Updates database schema.\")\n    parser_migration.set_defaults(handler=command_migrate)\n\n    # Create a parser for user creation.\n    parser_create_user = subparsers.add_parser(\"createuser\", help=\"see `createuser -h`\")\n    parser_create_user.add_argument(\"--username\", type=str, default=\"admin\", help=\"admin username\")\n    parser_create_user.add_argument(\"--password\", type=str, default=\"password\", help=\"admin password\")\n    parser_create_user.add_argument(\"--email\", type=str, default=\"example@example.com\", help=\"admin email\")\n    parser_create_user.set_defaults(handler=command_user_create)\n\n    # Create a parser for web server.\n    parser_server = subparsers.add_parser(\"webserver\", help=\"see `webserver -h`\")\n    parser_server.add_argument(\"--port\", type=int, default=8000, help=\"port number\")\n    parser_server.add_argument(\"--workers\", type=int, default=number_of_workers(), help=\"the number of workers\")\n    parser_server.add_argument(\"--env_file\", type=str, help=\"read in a file of environment variables\")\n    parser_server.set_defaults(handler=command_run_webserver)\n\n    # Create a parser for task queue.\n    parser_queue = subparsers.add_parser(\"task\", help=\"see `task -h`\")\n    parser_queue.add_argument(\"--concurrency\", type=int, default=2, help=\"concurrency\")\n    parser_queue.add_argument(\"--env_file\", type=str, default=\"\", help=\"read in a file of environment variables\")\n    parser_queue.set_defaults(handler=command_run_task_queue)\n\n    parser_flower = subparsers.add_parser(\"flower\", help=\"see `flower -h`\")\n    parser_flower.add_argument(\"--env_file\", type=str, help=\"read in a file of environment variables\")\n    parser_flower.add_argument(\"--basic_auth\", type=str, help=\"username and password for basic authentication\")\n    parser_flower.set_defaults(handler=command_run_flower)\n\n    # Create a parser for help.\n    parser_help = subparsers.add_parser(\"help\", help=\"see `help -h`\")\n    parser_help.add_argument(\"command\", help=\"command name which help is shown\")\n    parser_help.set_defaults(handler=command_help)\n\n    # Dispatch handler.\n    args = parser.parse_args()\n    if hasattr(args, \"env_file\"):\n        env.read_env(args.env_file, recurse=False, override=True)\n    if hasattr(args, \"handler\"):\n        django.setup()\n        args.handler(args)\n    else:\n        # If specified unknown command, show help.\n        parser.print_help()\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "backend/cli.py"}], "after_files": [{"content": "import argparse\nimport multiprocessing\nimport os\nimport platform\nimport sys\nfrom pathlib import Path\n\nimport django\nfrom django.core import management\nfrom environs import Env\n\nfrom .config.celery import app\n\nenv = Env()\nDOCCANO_HOME = os.path.expanduser(os.environ.get(\"DOCCANO_HOME\", \"~/doccano\"))\nPath(DOCCANO_HOME).mkdir(parents=True, exist_ok=True)\nenv.bool(\"DEBUG\", False)\nos.environ[\"STANDALONE\"] = \"True\"\nos.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"config.settings.production\")\nos.environ.setdefault(\"DATABASE_URL\", os.path.join(f\"sqlite:///{DOCCANO_HOME}\", \"db.sqlite3\"))\nos.environ.setdefault(\"MEDIA_ROOT\", os.path.join(DOCCANO_HOME, \"media\"))\nbase = os.path.abspath(os.path.dirname(__file__))\nsys.path.append(base)\nparser = argparse.ArgumentParser(description=\"doccano, text annotation for machine learning practitioners.\")\n\n\ndef number_of_workers():\n    return (multiprocessing.cpu_count() * 2) + 1\n\n\ndef is_windows():\n    return platform.system() == \"Windows\"\n\n\ndef run_on_nix(args):\n    import gunicorn.app.base\n    import gunicorn.util\n\n    class StandaloneApplication(gunicorn.app.base.BaseApplication):\n        def __init__(self, options=None):\n            self.options = options or {}\n            super().__init__()\n\n        def load_config(self):\n            config = {\n                key: value for key, value in self.options.items() if key in self.cfg.settings and value is not None\n            }\n            for key, value in config.items():\n                self.cfg.set(key.lower(), value)\n\n        def load(self):\n            return gunicorn.util.import_app(\"config.wsgi\")\n\n    options = {\n        \"bind\": \"%s:%s\" % (\"0.0.0.0\", args.port),\n        \"workers\": args.workers,\n        \"chdir\": base,\n        \"capture_output\": True,\n        \"loglevel\": \"info\",\n    }\n    StandaloneApplication(options).run()\n\n\ndef run_on_windows(args):\n    from waitress import serve\n\n    from config.wsgi import application\n\n    serve(application, port=args.port, threads=args.workers)\n\n\ndef command_db_init(args):\n    print(\"Setup Database.\")\n    management.call_command(\"wait_for_db\")\n    management.call_command(\"migrate\")\n    management.call_command(\"create_roles\")\n\n\ndef command_user_create(args):\n    print(\"Create admin user.\")\n    management.call_command(\n        \"create_admin\", \"--noinput\", username=args.username, password=args.password, email=args.email\n    )\n\n\ndef command_migrate(args):\n    print(\"Start migration.\")\n    management.call_command(\"migrate\")\n\n\ndef command_run_webserver(args):\n    print(f\"Starting server with port {args.port}.\")\n    if is_windows():\n        run_on_windows(args)\n    else:\n        run_on_nix(args)\n\n\ndef command_run_task_queue(args):\n    print(\"Starting task queue.\")\n    argv = [\n        \"--app=config\",\n        \"--workdir={}\".format(base),\n        \"worker\",\n        \"--loglevel=info\",\n        \"--concurrency={}\".format(args.concurrency),\n    ]\n    if is_windows():\n        argv.append(\"--pool=solo\")\n    app.worker_main(argv=argv)\n\n\ndef command_run_flower(args):\n    print(\"Starting flower.\")\n    argv = [\n        \"--app=config\",\n        \"--workdir={}\".format(base),\n        \"flower\",\n    ]\n    if args.basic_auth:\n        argv.append(\"--basic_auth={}\".format(args.basic_auth))\n    app.worker_main(argv=argv)\n\n\ndef command_help(args):\n    print(parser.parse_args([args.command, \"--help\"]))\n\n\ndef main():\n    # Create a command line parser.\n    subparsers = parser.add_subparsers()\n\n    # Create a parser for db initialization.\n    parser_init = subparsers.add_parser(\"init\", help=\"see `init -h`\")\n    parser_init.set_defaults(handler=command_db_init)\n\n    # Create a parser for migration.\n    parser_migration = subparsers.add_parser(\"migrate\", help=\"Updates database schema.\")\n    parser_migration.set_defaults(handler=command_migrate)\n\n    # Create a parser for user creation.\n    parser_create_user = subparsers.add_parser(\"createuser\", help=\"see `createuser -h`\")\n    parser_create_user.add_argument(\"--username\", type=str, default=\"admin\", help=\"admin username\")\n    parser_create_user.add_argument(\"--password\", type=str, default=\"password\", help=\"admin password\")\n    parser_create_user.add_argument(\"--email\", type=str, default=\"example@example.com\", help=\"admin email\")\n    parser_create_user.set_defaults(handler=command_user_create)\n\n    # Create a parser for web server.\n    parser_server = subparsers.add_parser(\"webserver\", help=\"see `webserver -h`\")\n    parser_server.add_argument(\"--port\", type=int, default=8000, help=\"port number\")\n    parser_server.add_argument(\"--workers\", type=int, default=number_of_workers(), help=\"the number of workers\")\n    parser_server.add_argument(\"--env_file\", type=str, help=\"read in a file of environment variables\")\n    parser_server.set_defaults(handler=command_run_webserver)\n\n    # Create a parser for task queue.\n    parser_queue = subparsers.add_parser(\"task\", help=\"see `task -h`\")\n    parser_queue.add_argument(\"--concurrency\", type=int, default=2, help=\"concurrency\")\n    parser_queue.add_argument(\"--env_file\", type=str, help=\"read in a file of environment variables\")\n    parser_queue.set_defaults(handler=command_run_task_queue)\n\n    parser_flower = subparsers.add_parser(\"flower\", help=\"see `flower -h`\")\n    parser_flower.add_argument(\"--env_file\", type=str, help=\"read in a file of environment variables\")\n    parser_flower.add_argument(\"--basic_auth\", type=str, help=\"username and password for basic authentication\")\n    parser_flower.set_defaults(handler=command_run_flower)\n\n    # Create a parser for help.\n    parser_help = subparsers.add_parser(\"help\", help=\"see `help -h`\")\n    parser_help.add_argument(\"command\", help=\"command name which help is shown\")\n    parser_help.set_defaults(handler=command_help)\n\n    # Dispatch handler.\n    args = parser.parse_args()\n    if hasattr(args, \"env_file\"):\n        env.read_env(args.env_file, recurse=False, override=True)\n    if hasattr(args, \"handler\"):\n        django.setup()\n        args.handler(args)\n    else:\n        # If specified unknown command, show help.\n        parser.print_help()\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "backend/cli.py"}]}