app.__init__
trouver.
For developers
The design for the GUI is developed in the file nbs\pyqt6_UI\app.ui (relative to the trouver root directory). - The command line command pyqt6-tools designer can be used to open the PyQt6 Designer (assuming that pyqt6 and pyqt6-tools are installed into the Python environment). - Go to the nbs\pyqt6_UI folder in a command line and use the command line command pyuic6 -o app.py app.ui to generate the code from the designed UI into the file app.py.
During development, one can simply use the import statement from_pyqt6_UI.app import Ui_MainWindow (see below) in this Jupyter notebook. However, before using nbdev_export to compile the code for trouver, the code within app.py should be copied into an #| export cell.
To build the GUI as a standalone executable/application, one can use PyInstaller (which needs to be installed in the Python environment). To do so, do the following:
- Copy the file generated by
nbdev_exportfor this module (which should be outputted as the filetrouver\app\__init__.pyrelative to thetrouverroot directory) into some (preferably empty) folder. - Optionally, rename the copied file as
trouver_gui.py. - Open a command line in the folder containing the file.
- Use the command
pyinstaller --onefile [--windowed] <name_of_copied_file>.py.
The application should build, which shoud take several minutes, and should end up in a folder named dist as an .exe file.
UI code
Ui_MainWindow
Ui_MainWindow ()
Initialize self. See help(type(self)) for accurate signature.
ScrollableMessageBox
ScrollableMessageBox (*args, **kwargs)
The TrouverGUI class
The TrouverGUI class serves as the GUI for trouver functonalities.
TrouverGUI
TrouverGUI ()
*Attributes
- download_thread: DownloadThread
- A QThread that manages the source-file-download.
- downloaded_folder: Path
- The folder in which the source file is downloaded.
- authors - str
- Roughly, the family names of the authors. This is determined during the invocation of
self.download_thread.run.
- Roughly, the family names of the authors. This is determined during the invocation of
- create_obsidian_thread: CreateObsidianVaultThread
- A QThread that manages the Obsidian.md (sub)vault creation.
- created_obsidian_vault: Path
- The folder in which the Obsidian.md (sub)vault is created.
- prediction_thread: PredictionThread
- A QThread that manages ML predictions
- current_predicted_note: VaultNote
- The VaultNote that is currently being predicted.
- compile_to_tex_thread: CompileObsidianSubvaultAsTexThread
- A QThead that manages compiling an Obisidian.md (sub)vault into a single .tex file.*
UI initialization
initUI
initUI ()
Error message
simple_instructional_message
simple_instructional_message (window_title:str, window_text:str)
Display a simple error message for when specifications by the user do not fulfill requirements.
Download arxiv source file
DownloadThread
DownloadThread (url:str, folder:os.PathLike, trouver_gui)
choose_source_download_folder
choose_source_download_folder ()
choose_file_or_folder
choose_file_or_folder (set_text_method:Callable[[os.PathLike],NoneType], default_folder:os.PathLike|None, for_folder:bool)
| Type | Details | |
|---|---|---|
| set_text_method | Callable | The method of self that is supposed to be used after the folder is chosen to change the text of a label. |
| default_folder | os.PathLike | None | The default folder to open in the QFileDialog, if available. This should be an absolute path. |
| for_folder | bool | If True, then the dialog is for choosing a folder. Otherwise, the dialog is for choosing a file. |
| Returns | None |
get_download_folder
get_download_folder ()
Get the indicated folder in which to download the source code.
get_folder
get_folder (text)
*Get a folder path from some text.
For example, “Selected Folder:
download_arxiv_source
download_arxiv_source ()
open_downloaded_folder
open_downloaded_folder ()
Setup Obsidian.md vault from tex file.
choose_obsidian_subvault_location
choose_obsidian_subvault_location ()
choose_source_code_file
choose_source_code_file ()
CreateObsidianVaultThread
CreateObsidianVaultThread (source_file:os.PathLike, subvault_folder:os.PathLike, subvault_name:str, authors:list[str])
create_obsidian_subvault
create_obsidian_subvault ()
open_created_obsidian_subvault
open_created_obsidian_subvault ()
Predict on notes
show_confirmation_dialog
show_confirmation_dialog (models_exist:bool, packages_installed:bool)
Confirm whether packages should be installed and/or models should be downloaded before making predictions.
predict_on_notes
predict_on_notes ()
choose_prediction_folder
choose_prediction_folder ()
get_prediction_folder
get_prediction_folder ()
PredictionThread
PredictionThread (trouver_gui, vault:os.PathLike)
from_pretrained_fastai_without_checking_fastai_fastcore_version
from_pretrained_fastai_without_checking_fastai_fastcore_version (repo_id :str, re vision:O ptional[ str]=Non e)
*This is a copy of the from_pretrained_fastai funtion from the huggingface_hub.fastai_utils module, except that it does not check the fastai and fastcore versions as that function does.
It may be the case that the fastai/fastcore version checking functions do not work as intended when the app is built.
Args: repo_id (str): The location where the pickled fastai.Learner is. It can be either of the two: - Hosted on the Hugging Face Hub. E.g.: ‘espejelomar/fatai-pet-breeds-classification’ or ‘distilgpt2’. You can add a revision by appending @ at the end of repo_id. E.g.: dbmdz/bert-base-german-cased@main. Revision is the specific model version to use. Since we use a git-based system for storing models and other artifacts on the Hugging Face Hub, it can be a branch name, a tag name, or a commit id. - Hosted locally. repo_id would be a directory containing the pickle and a pyproject.toml indicating the fastai and fastcore versions used to build the fastai.Learner. E.g.: ./my_model_directory/. revision (str, optional): Revision at which the repo’s files are downloaded. See documentation of snapshot_download.
Returns: The fastai.Learner model in the repo_id repo.*
open_prediction_folder
open_prediction_folder ()
Compile predicted notes into single .tex file
choose_compiled_tex_output_folder
choose_compiled_tex_output_folder ()
get_compiled_tex_output_folder
get_compiled_tex_output_folder ()
choose_original_tex_file
choose_original_tex_file ()
get_original_tex_file
get_original_tex_file ()
choose_obsidian_subvault_to_compile_notes
choose_obsidian_subvault_to_compile_notes ()
get_obsidian_subvault_to_compile
get_obsidian_subvault_to_compile ()
compile_obsidian_subvault_as_tex_file
compile_obsidian_subvault_as_tex_file ()
CompileObsidianSubvaultAsTexThread
CompileObsidianSubvaultAsTexThread (subvault:os.PathLike, index_file:os.PathLike, original_tex_file:os.PathLike, output_folder:os.PathLike)