If you run the app from the CLI, and specify the --help option, then it loads a bunch of stuff first, before it eventually returns with the usage help. Loading all of that other stuff is not necessary. We should argparse first and only after, continue loading the app.
e.g.:
(venv) PS C:\Users\jabaa\Documents\devel\aish3> python aish3.py --help
BEFORE load_dotenv()
AFTER load_dotenv()
app_path: C:\Users\jabaa\Documents\devel\aish3
Importing sentence_transformers...
Imported sentence_transformers. Took 1.9710934162139893 seconds.
2024-05-11 10:40:31,193 [INFO]: Load pretrained SentenceTransformer: all-MiniLM-L6-v2
2024-05-11 10:40:31,208 [DEBUG]: Starting new HTTPS connection (1): huggingface.co:443
2024-05-11 10:40:31,842 [DEBUG]: https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/modules.json HTTP/1.1" 200 0
2024-05-11 10:40:31,983 [DEBUG]: https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/config_sentence_transformers.json HTTP/1.1" 200 0
2024-05-11 10:40:32,126 [DEBUG]: https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/README.md HTTP/1.1" 200 0
2024-05-11 10:40:32,270 [DEBUG]: https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/modules.json HTTP/1.1" 200 0
2024-05-11 10:40:32,413 [DEBUG]: https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/sentence_bert_config.json HTTP/1.1" 200 0
C:\Users\jabaa\Documents\devel\aish3\venv\Lib\site-packages\huggingface_hub\file_download.py:1132: FutureWarning: resume_download is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use force_download=True.
warnings.warn(
2024-05-11 10:40:32,570 [DEBUG]: https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/config.json HTTP/1.1" 200 0
C:\Users\jabaa\Documents\devel\aish3\venv\Lib\site-packages\huggingface_hub\file_download.py:1132: FutureWarning: resume_download is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use force_download=True.
warnings.warn(
2024-05-11 10:40:33,305 [DEBUG]: https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/tokenizer_config.json HTTP/1.1" 200 0
2024-05-11 10:40:33,502 [DEBUG]: https://huggingface.co:443 "GET /api/models/sentence-transformers/all-MiniLM-L6-v2/revision/main HTTP/1.1" 200 6107
2024-05-11 10:40:33,512 [INFO]: Use pytorch device_name: cpu
C:\Users\jabaa\Documents\devel\aish3\venv\Lib\site-packages\pydub\utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
2024-05-11 10:40:34,039 [DEBUG]: matplotlib data path: C:\Users\jabaa\Documents\devel\aish3\venv\Lib\site-packages\matplotlib\mpl-data
2024-05-11 10:40:34,046 [DEBUG]: CONFIGDIR=C:\Users\jabaa.matplotlib
2024-05-11 10:40:34,046 [DEBUG]: interactive is False
2024-05-11 10:40:34,046 [DEBUG]: platform is win32
usage: aish3.py [-h] [--fullscreen] [--width WIDTH] [--height HEIGHT] [--voice-in] [--workspace WORKSPACE]
AISH window application.
options:
-h, --help show this help message and exit
--fullscreen run in fullscreen mode
--width WIDTH window width (default: 1450)
--height HEIGHT window height (default: 800)
--voice-in Enable voice input.
--workspace WORKSPACE
workspace file (default: aish_workspace.json)
If you run the app from the CLI, and specify the --help option, then it loads a bunch of stuff first, before it eventually returns with the usage help. Loading all of that other stuff is not necessary. We should argparse first and only after, continue loading the app.
e.g.:
(venv) PS C:\Users\jabaa\Documents\devel\aish3> python aish3.py --help BEFORE load_dotenv() AFTER load_dotenv() app_path: C:\Users\jabaa\Documents\devel\aish3 Importing sentence_transformers... Imported sentence_transformers. Took 1.9710934162139893 seconds. 2024-05-11 10:40:31,193 [INFO]: Load pretrained SentenceTransformer: all-MiniLM-L6-v2 2024-05-11 10:40:31,208 [DEBUG]: Starting new HTTPS connection (1): huggingface.co:443 2024-05-11 10:40:31,842 [DEBUG]: https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/modules.json HTTP/1.1" 200 0 2024-05-11 10:40:31,983 [DEBUG]: https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/config_sentence_transformers.json HTTP/1.1" 200 0 2024-05-11 10:40:32,126 [DEBUG]: https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/README.md HTTP/1.1" 200 0 2024-05-11 10:40:32,270 [DEBUG]: https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/modules.json HTTP/1.1" 200 0 2024-05-11 10:40:32,413 [DEBUG]: https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/sentence_bert_config.json HTTP/1.1" 200 0 C:\Users\jabaa\Documents\devel\aish3\venv\Lib\site-packages\huggingface_hub\file_download.py:1132: FutureWarning:
resume_download
is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, useforce_download=True
. warnings.warn( 2024-05-11 10:40:32,570 [DEBUG]: https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/config.json HTTP/1.1" 200 0 C:\Users\jabaa\Documents\devel\aish3\venv\Lib\site-packages\huggingface_hub\file_download.py:1132: FutureWarning:resume_download
is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, useforce_download=True
. warnings.warn( 2024-05-11 10:40:33,305 [DEBUG]: https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/tokenizer_config.json HTTP/1.1" 200 0 2024-05-11 10:40:33,502 [DEBUG]: https://huggingface.co:443 "GET /api/models/sentence-transformers/all-MiniLM-L6-v2/revision/main HTTP/1.1" 200 6107 2024-05-11 10:40:33,512 [INFO]: Use pytorch device_name: cpu C:\Users\jabaa\Documents\devel\aish3\venv\Lib\site-packages\pydub\utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning) 2024-05-11 10:40:34,039 [DEBUG]: matplotlib data path: C:\Users\jabaa\Documents\devel\aish3\venv\Lib\site-packages\matplotlib\mpl-data 2024-05-11 10:40:34,046 [DEBUG]: CONFIGDIR=C:\Users\jabaa.matplotlib 2024-05-11 10:40:34,046 [DEBUG]: interactive is False 2024-05-11 10:40:34,046 [DEBUG]: platform is win32 usage: aish3.py [-h] [--fullscreen] [--width WIDTH] [--height HEIGHT] [--voice-in] [--workspace WORKSPACE]AISH window application.
options: -h, --help show this help message and exit --fullscreen run in fullscreen mode --width WIDTH window width (default: 1450) --height HEIGHT window height (default: 800) --voice-in Enable voice input. --workspace WORKSPACE workspace file (default: aish_workspace.json)