We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
remove unused dependenices


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/flyswot/models.py`
Content:
```
1 """Model Commands."""
2 import fnmatch
3 from dataclasses import dataclass
4 from pathlib import Path
5 from typing import List
6 from typing import Optional
7 from typing import Tuple
8 from typing import Union
9 
10 import requests
11 import typer
12 import validators  # type: ignore
13 from huggingface_hub import hf_hub_url
14 from huggingface_hub import snapshot_download
15 from huggingface_hub.hf_api import ModelInfo
16 from rich.markdown import Markdown
17 from rich.table import Table
18 from toolz import itertoolz
19 from toolz import recipes
20 
21 from flyswot.config import APP_NAME
22 from flyswot.config import MODEL_REPO_ID
23 from flyswot.console import console
24 
25 app = typer.Typer()
26 
27 
28 @dataclass
29 class LocalModel:
30     """A local model container"""
31 
32     hf_cache: Path
33 
34     def __post_init__(self):
35         """Returns model parts contained under hf_cache"""
36         self._get_model_parts(self.hf_cache)
37 
38     def _get_model_parts(self, hf_cache: Path):
39         """Returns model path, vocab and metadata for a model"""
40         model_files = Path(hf_cache).iterdir()
41         for file in model_files:
42             if fnmatch.fnmatch(file.name, "vocab.txt"):
43                 self.vocab = file
44             if fnmatch.fnmatch(file.name, "README.md"):
45                 self.modelcard = file
46             if fnmatch.fnmatch(file.name, "*.onnx") or fnmatch.fnmatch(
47                 file.name, "*.pkl"
48             ):
49                 self.model = file
50 
51 
52 def _url_callback(url: str) -> Union[str, None]:
53     """Checks url is valid"""
54     if url == "latest":
55         return url
56     if validators.url(url):
57         return url
58     else:
59         raise typer.BadParameter(f"Please check {url} is a valid url")
60 
61 
62 def ensure_model_dir(model_dir_path: Union[Path, None] = None) -> Path:
63     """Checks for a local model dir and creates one if not found"""
64     if not model_dir_path:
65         app_dir = typer.get_app_dir(APP_NAME)
66         model_dir: Path = Path(app_dir) / "models"
67     else:
68         model_dir = Path(model_dir_path) / "models"
69     if not (model_dir.exists() and model_dir.is_dir()):
70         typer.echo(f"Creating directory for storing models in {model_dir}...")
71         try:
72             model_dir.mkdir(parents=True)
73         except PermissionError as e:  # pragma: no cover
74             typer.echo(f"{model_dir} is not writeable: {e}")
75             raise typer.Exit(code=1) from None
76     typer.echo(f"Models stored in {model_dir}")
77     return model_dir
78 
79 
80 @app.command()
81 def show_model_dir() -> None:
82     """Print out the directory where models are stored"""
83     ensure_model_dir()
84 
85 
86 @app.command(name="download")
87 def get_model(
88     revision: Optional[str] = typer.Argument(None, callback=_url_callback),
89     model_dir: Path = typer.Argument(
90         None,
91         envvar="MODEL_DIR",
92         help="Optionally specify a directory to store model files in",
93     ),
94     local_only=False,
95 ) -> Path:  # pragma: no cover
96     """Downloads models, defaults to the latest available model"""
97     repo_id = MODEL_REPO_ID
98     with console.status("Getting model", spinner="dots"):
99         model = snapshot_download(
100             repo_id, cache_dir=model_dir, revision=None, local_files_only=local_only
101         )
102     return Path(model)
103 
104 
105 def ensure_model(model_dir: Path) -> LocalModel:  # pragma: no cover
106     """Checks for a local model and if not found downloads the latest available remote model"""
107     if model := get_model(model_dir=model_dir):
108         return LocalModel(model)
109     typer.echo("Not able to find a model")
110     raise typer.Exit()
111 
112 
113 def is_pipe(c: Tuple) -> bool:
114     """Checks if | in c"""
115     return "|" in c
116 
117 
118 def load_vocab(vocab: Path) -> List[List[str]]:
119     """loads vocab from `vocab` and returns as list contaning lists of vocab"""
120     with open(vocab, "r") as f:
121         raw_vocab = [line.strip("\n") for line in f.readlines()]
122         return list(
123             map(
124                 list,
125                 (itertoolz.remove(is_pipe, (recipes.partitionby(is_pipe, raw_vocab)))),
126             )
127         )
128 
129 
130 @app.command()
131 def vocab(model: str = typer.Argument("latest"), show: bool = typer.Option(True)):
132     """Prints out vocab for latest model"""
133     if model != "latest":
134         raise NotImplementedError
135     model_dir = ensure_model_dir()
136     if model_path := get_model(model_dir=model_dir):
137         local_model = LocalModel(model_path)
138         if local_model.vocab:
139             vocab = load_vocab(local_model.vocab)
140             if show:
141                 console.print(Markdown("# Model Vocab"))
142                 console.print(vocab)
143             return vocab
144 
145 
146 def show_model_card(localmodel: LocalModel):
147     """Shows model card for model"""
148     with open(localmodel.modelcard, "r") as f:
149         md = Markdown(f.read())
150     console.print(md)
151 
152 
153 def hub_model_link(model_id: str):
154     """Creates rich link for model card"""
155     url = f"https://huggingface.co/{model_id}"
156     return f"View [link={url}]model card[/link]!"
157 
158 
159 def create_markdown_model_card(model_id: str):
160     """Creates rich Markdown wrapper for hub readme"""
161     readme_url = hf_hub_url(model_id, filename="README.md")
162     r = requests.get(readme_url)
163     r.raise_for_status()
164     return Markdown(r.text)
165 
166 
167 def create_metrics_tables(model_info: ModelInfo) -> List[Table]:
168     """Creates a list of rich tables for metrics contained in `model_info`"""
169     model_indexes = list(model_info.cardData["model-index"])
170     metrics = []
171     for model in model_indexes:
172         for result in model["results"]:
173             for metric in result["metrics"]:
174                 metrics.append(metric)
175     tables = []
176     for metric in metrics:
177         table = Table()
178         for name in metric.keys():
179             table.add_column(name.title())
180     metric_values = list(metric.values())
181     rounded_metric_values = [
182         round(item, ndigits=3) if isinstance(item, float) else item
183         for item in metric_values
184     ]
185     table.add_row(*list(map(str, rounded_metric_values)))
186     tables.append(table)
187     return tables
188 
189 
190 if __name__ == "__main__":  # pragma: no cover
191     app()
192
```
--- 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/src/flyswot/models.py b/src/flyswot/models.py
--- a/src/flyswot/models.py
+++ b/src/flyswot/models.py
@@ -9,7 +9,6 @@
 
 import requests
 import typer
-import validators  # type: ignore
 from huggingface_hub import hf_hub_url
 from huggingface_hub import snapshot_download
 from huggingface_hub.hf_api import ModelInfo
@@ -49,14 +48,14 @@
                 self.model = file
 
 
-def _url_callback(url: str) -> Union[str, None]:
-    """Checks url is valid"""
-    if url == "latest":
-        return url
-    if validators.url(url):
-        return url
-    else:
-        raise typer.BadParameter(f"Please check {url} is a valid url")
+# def _url_callback(url: str) -> Union[str, None]:
+#     """Checks url is valid"""
+#     if url == "latest":
+#         return url
+#     if validators.url(url):
+#         return url
+#     else:
+#         raise typer.BadParameter(f"Please check {url} is a valid url")
 
 
 def ensure_model_dir(model_dir_path: Union[Path, None] = None) -> Path:
@@ -85,7 +84,7 @@
 
 @app.command(name="download")
 def get_model(
-    revision: Optional[str] = typer.Argument(None, callback=_url_callback),
+    revision: Optional[str] = typer.Argument(None),
     model_dir: Path = typer.Argument(
         None,
         envvar="MODEL_DIR",

{"golden_diff": "diff --git a/src/flyswot/models.py b/src/flyswot/models.py\n--- a/src/flyswot/models.py\n+++ b/src/flyswot/models.py\n@@ -9,7 +9,6 @@\n \n import requests\n import typer\n-import validators  # type: ignore\n from huggingface_hub import hf_hub_url\n from huggingface_hub import snapshot_download\n from huggingface_hub.hf_api import ModelInfo\n@@ -49,14 +48,14 @@\n                 self.model = file\n \n \n-def _url_callback(url: str) -> Union[str, None]:\n-    \"\"\"Checks url is valid\"\"\"\n-    if url == \"latest\":\n-        return url\n-    if validators.url(url):\n-        return url\n-    else:\n-        raise typer.BadParameter(f\"Please check {url} is a valid url\")\n+# def _url_callback(url: str) -> Union[str, None]:\n+#     \"\"\"Checks url is valid\"\"\"\n+#     if url == \"latest\":\n+#         return url\n+#     if validators.url(url):\n+#         return url\n+#     else:\n+#         raise typer.BadParameter(f\"Please check {url} is a valid url\")\n \n \n def ensure_model_dir(model_dir_path: Union[Path, None] = None) -> Path:\n@@ -85,7 +84,7 @@\n \n @app.command(name=\"download\")\n def get_model(\n-    revision: Optional[str] = typer.Argument(None, callback=_url_callback),\n+    revision: Optional[str] = typer.Argument(None),\n     model_dir: Path = typer.Argument(\n         None,\n         envvar=\"MODEL_DIR\",\n", "issue": "remove unused dependenices\n\n", "before_files": [{"content": "\"\"\"Model Commands.\"\"\"\nimport fnmatch\nfrom dataclasses import dataclass\nfrom pathlib import Path\nfrom typing import List\nfrom typing import Optional\nfrom typing import Tuple\nfrom typing import Union\n\nimport requests\nimport typer\nimport validators  # type: ignore\nfrom huggingface_hub import hf_hub_url\nfrom huggingface_hub import snapshot_download\nfrom huggingface_hub.hf_api import ModelInfo\nfrom rich.markdown import Markdown\nfrom rich.table import Table\nfrom toolz import itertoolz\nfrom toolz import recipes\n\nfrom flyswot.config import APP_NAME\nfrom flyswot.config import MODEL_REPO_ID\nfrom flyswot.console import console\n\napp = typer.Typer()\n\n\n@dataclass\nclass LocalModel:\n    \"\"\"A local model container\"\"\"\n\n    hf_cache: Path\n\n    def __post_init__(self):\n        \"\"\"Returns model parts contained under hf_cache\"\"\"\n        self._get_model_parts(self.hf_cache)\n\n    def _get_model_parts(self, hf_cache: Path):\n        \"\"\"Returns model path, vocab and metadata for a model\"\"\"\n        model_files = Path(hf_cache).iterdir()\n        for file in model_files:\n            if fnmatch.fnmatch(file.name, \"vocab.txt\"):\n                self.vocab = file\n            if fnmatch.fnmatch(file.name, \"README.md\"):\n                self.modelcard = file\n            if fnmatch.fnmatch(file.name, \"*.onnx\") or fnmatch.fnmatch(\n                file.name, \"*.pkl\"\n            ):\n                self.model = file\n\n\ndef _url_callback(url: str) -> Union[str, None]:\n    \"\"\"Checks url is valid\"\"\"\n    if url == \"latest\":\n        return url\n    if validators.url(url):\n        return url\n    else:\n        raise typer.BadParameter(f\"Please check {url} is a valid url\")\n\n\ndef ensure_model_dir(model_dir_path: Union[Path, None] = None) -> Path:\n    \"\"\"Checks for a local model dir and creates one if not found\"\"\"\n    if not model_dir_path:\n        app_dir = typer.get_app_dir(APP_NAME)\n        model_dir: Path = Path(app_dir) / \"models\"\n    else:\n        model_dir = Path(model_dir_path) / \"models\"\n    if not (model_dir.exists() and model_dir.is_dir()):\n        typer.echo(f\"Creating directory for storing models in {model_dir}...\")\n        try:\n            model_dir.mkdir(parents=True)\n        except PermissionError as e:  # pragma: no cover\n            typer.echo(f\"{model_dir} is not writeable: {e}\")\n            raise typer.Exit(code=1) from None\n    typer.echo(f\"Models stored in {model_dir}\")\n    return model_dir\n\n\n@app.command()\ndef show_model_dir() -> None:\n    \"\"\"Print out the directory where models are stored\"\"\"\n    ensure_model_dir()\n\n\n@app.command(name=\"download\")\ndef get_model(\n    revision: Optional[str] = typer.Argument(None, callback=_url_callback),\n    model_dir: Path = typer.Argument(\n        None,\n        envvar=\"MODEL_DIR\",\n        help=\"Optionally specify a directory to store model files in\",\n    ),\n    local_only=False,\n) -> Path:  # pragma: no cover\n    \"\"\"Downloads models, defaults to the latest available model\"\"\"\n    repo_id = MODEL_REPO_ID\n    with console.status(\"Getting model\", spinner=\"dots\"):\n        model = snapshot_download(\n            repo_id, cache_dir=model_dir, revision=None, local_files_only=local_only\n        )\n    return Path(model)\n\n\ndef ensure_model(model_dir: Path) -> LocalModel:  # pragma: no cover\n    \"\"\"Checks for a local model and if not found downloads the latest available remote model\"\"\"\n    if model := get_model(model_dir=model_dir):\n        return LocalModel(model)\n    typer.echo(\"Not able to find a model\")\n    raise typer.Exit()\n\n\ndef is_pipe(c: Tuple) -> bool:\n    \"\"\"Checks if | in c\"\"\"\n    return \"|\" in c\n\n\ndef load_vocab(vocab: Path) -> List[List[str]]:\n    \"\"\"loads vocab from `vocab` and returns as list contaning lists of vocab\"\"\"\n    with open(vocab, \"r\") as f:\n        raw_vocab = [line.strip(\"\\n\") for line in f.readlines()]\n        return list(\n            map(\n                list,\n                (itertoolz.remove(is_pipe, (recipes.partitionby(is_pipe, raw_vocab)))),\n            )\n        )\n\n\n@app.command()\ndef vocab(model: str = typer.Argument(\"latest\"), show: bool = typer.Option(True)):\n    \"\"\"Prints out vocab for latest model\"\"\"\n    if model != \"latest\":\n        raise NotImplementedError\n    model_dir = ensure_model_dir()\n    if model_path := get_model(model_dir=model_dir):\n        local_model = LocalModel(model_path)\n        if local_model.vocab:\n            vocab = load_vocab(local_model.vocab)\n            if show:\n                console.print(Markdown(\"# Model Vocab\"))\n                console.print(vocab)\n            return vocab\n\n\ndef show_model_card(localmodel: LocalModel):\n    \"\"\"Shows model card for model\"\"\"\n    with open(localmodel.modelcard, \"r\") as f:\n        md = Markdown(f.read())\n    console.print(md)\n\n\ndef hub_model_link(model_id: str):\n    \"\"\"Creates rich link for model card\"\"\"\n    url = f\"https://huggingface.co/{model_id}\"\n    return f\"View [link={url}]model card[/link]!\"\n\n\ndef create_markdown_model_card(model_id: str):\n    \"\"\"Creates rich Markdown wrapper for hub readme\"\"\"\n    readme_url = hf_hub_url(model_id, filename=\"README.md\")\n    r = requests.get(readme_url)\n    r.raise_for_status()\n    return Markdown(r.text)\n\n\ndef create_metrics_tables(model_info: ModelInfo) -> List[Table]:\n    \"\"\"Creates a list of rich tables for metrics contained in `model_info`\"\"\"\n    model_indexes = list(model_info.cardData[\"model-index\"])\n    metrics = []\n    for model in model_indexes:\n        for result in model[\"results\"]:\n            for metric in result[\"metrics\"]:\n                metrics.append(metric)\n    tables = []\n    for metric in metrics:\n        table = Table()\n        for name in metric.keys():\n            table.add_column(name.title())\n    metric_values = list(metric.values())\n    rounded_metric_values = [\n        round(item, ndigits=3) if isinstance(item, float) else item\n        for item in metric_values\n    ]\n    table.add_row(*list(map(str, rounded_metric_values)))\n    tables.append(table)\n    return tables\n\n\nif __name__ == \"__main__\":  # pragma: no cover\n    app()\n", "path": "src/flyswot/models.py"}], "after_files": [{"content": "\"\"\"Model Commands.\"\"\"\nimport fnmatch\nfrom dataclasses import dataclass\nfrom pathlib import Path\nfrom typing import List\nfrom typing import Optional\nfrom typing import Tuple\nfrom typing import Union\n\nimport requests\nimport typer\nfrom huggingface_hub import hf_hub_url\nfrom huggingface_hub import snapshot_download\nfrom huggingface_hub.hf_api import ModelInfo\nfrom rich.markdown import Markdown\nfrom rich.table import Table\nfrom toolz import itertoolz\nfrom toolz import recipes\n\nfrom flyswot.config import APP_NAME\nfrom flyswot.config import MODEL_REPO_ID\nfrom flyswot.console import console\n\napp = typer.Typer()\n\n\n@dataclass\nclass LocalModel:\n    \"\"\"A local model container\"\"\"\n\n    hf_cache: Path\n\n    def __post_init__(self):\n        \"\"\"Returns model parts contained under hf_cache\"\"\"\n        self._get_model_parts(self.hf_cache)\n\n    def _get_model_parts(self, hf_cache: Path):\n        \"\"\"Returns model path, vocab and metadata for a model\"\"\"\n        model_files = Path(hf_cache).iterdir()\n        for file in model_files:\n            if fnmatch.fnmatch(file.name, \"vocab.txt\"):\n                self.vocab = file\n            if fnmatch.fnmatch(file.name, \"README.md\"):\n                self.modelcard = file\n            if fnmatch.fnmatch(file.name, \"*.onnx\") or fnmatch.fnmatch(\n                file.name, \"*.pkl\"\n            ):\n                self.model = file\n\n\n# def _url_callback(url: str) -> Union[str, None]:\n#     \"\"\"Checks url is valid\"\"\"\n#     if url == \"latest\":\n#         return url\n#     if validators.url(url):\n#         return url\n#     else:\n#         raise typer.BadParameter(f\"Please check {url} is a valid url\")\n\n\ndef ensure_model_dir(model_dir_path: Union[Path, None] = None) -> Path:\n    \"\"\"Checks for a local model dir and creates one if not found\"\"\"\n    if not model_dir_path:\n        app_dir = typer.get_app_dir(APP_NAME)\n        model_dir: Path = Path(app_dir) / \"models\"\n    else:\n        model_dir = Path(model_dir_path) / \"models\"\n    if not (model_dir.exists() and model_dir.is_dir()):\n        typer.echo(f\"Creating directory for storing models in {model_dir}...\")\n        try:\n            model_dir.mkdir(parents=True)\n        except PermissionError as e:  # pragma: no cover\n            typer.echo(f\"{model_dir} is not writeable: {e}\")\n            raise typer.Exit(code=1) from None\n    typer.echo(f\"Models stored in {model_dir}\")\n    return model_dir\n\n\n@app.command()\ndef show_model_dir() -> None:\n    \"\"\"Print out the directory where models are stored\"\"\"\n    ensure_model_dir()\n\n\n@app.command(name=\"download\")\ndef get_model(\n    revision: Optional[str] = typer.Argument(None),\n    model_dir: Path = typer.Argument(\n        None,\n        envvar=\"MODEL_DIR\",\n        help=\"Optionally specify a directory to store model files in\",\n    ),\n    local_only=False,\n) -> Path:  # pragma: no cover\n    \"\"\"Downloads models, defaults to the latest available model\"\"\"\n    repo_id = MODEL_REPO_ID\n    with console.status(\"Getting model\", spinner=\"dots\"):\n        model = snapshot_download(\n            repo_id, cache_dir=model_dir, revision=None, local_files_only=local_only\n        )\n    return Path(model)\n\n\ndef ensure_model(model_dir: Path) -> LocalModel:  # pragma: no cover\n    \"\"\"Checks for a local model and if not found downloads the latest available remote model\"\"\"\n    if model := get_model(model_dir=model_dir):\n        return LocalModel(model)\n    typer.echo(\"Not able to find a model\")\n    raise typer.Exit()\n\n\ndef is_pipe(c: Tuple) -> bool:\n    \"\"\"Checks if | in c\"\"\"\n    return \"|\" in c\n\n\ndef load_vocab(vocab: Path) -> List[List[str]]:\n    \"\"\"loads vocab from `vocab` and returns as list contaning lists of vocab\"\"\"\n    with open(vocab, \"r\") as f:\n        raw_vocab = [line.strip(\"\\n\") for line in f.readlines()]\n        return list(\n            map(\n                list,\n                (itertoolz.remove(is_pipe, (recipes.partitionby(is_pipe, raw_vocab)))),\n            )\n        )\n\n\n@app.command()\ndef vocab(model: str = typer.Argument(\"latest\"), show: bool = typer.Option(True)):\n    \"\"\"Prints out vocab for latest model\"\"\"\n    if model != \"latest\":\n        raise NotImplementedError\n    model_dir = ensure_model_dir()\n    if model_path := get_model(model_dir=model_dir):\n        local_model = LocalModel(model_path)\n        if local_model.vocab:\n            vocab = load_vocab(local_model.vocab)\n            if show:\n                console.print(Markdown(\"# Model Vocab\"))\n                console.print(vocab)\n            return vocab\n\n\ndef show_model_card(localmodel: LocalModel):\n    \"\"\"Shows model card for model\"\"\"\n    with open(localmodel.modelcard, \"r\") as f:\n        md = Markdown(f.read())\n    console.print(md)\n\n\ndef hub_model_link(model_id: str):\n    \"\"\"Creates rich link for model card\"\"\"\n    url = f\"https://huggingface.co/{model_id}\"\n    return f\"View [link={url}]model card[/link]!\"\n\n\ndef create_markdown_model_card(model_id: str):\n    \"\"\"Creates rich Markdown wrapper for hub readme\"\"\"\n    readme_url = hf_hub_url(model_id, filename=\"README.md\")\n    r = requests.get(readme_url)\n    r.raise_for_status()\n    return Markdown(r.text)\n\n\ndef create_metrics_tables(model_info: ModelInfo) -> List[Table]:\n    \"\"\"Creates a list of rich tables for metrics contained in `model_info`\"\"\"\n    model_indexes = list(model_info.cardData[\"model-index\"])\n    metrics = []\n    for model in model_indexes:\n        for result in model[\"results\"]:\n            for metric in result[\"metrics\"]:\n                metrics.append(metric)\n    tables = []\n    for metric in metrics:\n        table = Table()\n        for name in metric.keys():\n            table.add_column(name.title())\n    metric_values = list(metric.values())\n    rounded_metric_values = [\n        round(item, ndigits=3) if isinstance(item, float) else item\n        for item in metric_values\n    ]\n    table.add_row(*list(map(str, rounded_metric_values)))\n    tables.append(table)\n    return tables\n\n\nif __name__ == \"__main__\":  # pragma: no cover\n    app()\n", "path": "src/flyswot/models.py"}]}