Add option setting for number of threads to use for fpcalc

This commit is contained in:
Bob Swift
2023-01-03 13:11:11 -07:00
committed by Philipp Wolfer
parent 37637acbde
commit 7c4fb2d64d
4 changed files with 76 additions and 4 deletions

View File

@@ -7,6 +7,7 @@
# Copyright (C) 2018 Vishal Choudhary
# Copyright (C) 2018-2021 Laurent Monin
# Copyright (C) 2018-2022 Philipp Wolfer
# Copyright (C) 2023 Bob Swift
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -73,7 +74,6 @@ class AcoustIDClient(QtCore.QObject):
super().__init__()
self._queue = deque()
self._running = 0
self._max_processes = 2
self._acoustid_api = acoustid_api
def init(self):
@@ -82,6 +82,10 @@ class AcoustIDClient(QtCore.QObject):
def done(self):
pass
def get_max_processes(self):
config = get_config()
return config.setting['fpcalc_threads'] or 2
def _on_lookup_finished(self, task, document, http, error):
doc = {}
if error:
@@ -286,7 +290,7 @@ class AcoustIDClient(QtCore.QObject):
return
self._queue.append(task)
self._fpcalc = get_fpcalc()
if self._running < self._max_processes:
if self._running < self.get_max_processes():
self._run_next_task()
def fingerprint(self, file, next_func):

View File

@@ -7,6 +7,7 @@
# Copyright (C) 2013, 2018, 2020-2021 Laurent Monin
# Copyright (C) 2015, 2020-2022 Philipp Wolfer
# Copyright (C) 2016-2017 Sambhav Kothari
# Copyright (C) 2023 Bob Swift
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -34,6 +35,7 @@ from PyQt5 import (
from picard.acoustid import find_fpcalc
from picard.config import (
BoolOption,
IntOption,
TextOption,
get_config,
)
@@ -69,6 +71,7 @@ class FingerprintingOptionsPage(OptionsPage):
TextOption("setting", "fingerprinting_system", "acoustid"),
TextOption("setting", "acoustid_fpcalc", ""),
TextOption("setting", "acoustid_apikey", ""),
IntOption("setting", "fpcalc_threads", 2),
]
def __init__(self, parent=None):
@@ -95,6 +98,7 @@ class FingerprintingOptionsPage(OptionsPage):
self.ui.acoustid_apikey.setText(config.setting["acoustid_apikey"])
self.ui.ignore_existing_acoustid_fingerprints.setChecked(config.setting["ignore_existing_acoustid_fingerprints"])
self.ui.save_acoustid_fingerprints.setChecked(config.setting["save_acoustid_fingerprints"])
self.ui.fpcalc_threads.setValue(config.setting["fpcalc_threads"])
self.update_groupboxes()
def save(self):
@@ -107,6 +111,7 @@ class FingerprintingOptionsPage(OptionsPage):
config.setting["acoustid_apikey"] = self.ui.acoustid_apikey.text()
config.setting["ignore_existing_acoustid_fingerprints"] = self.ui.ignore_existing_acoustid_fingerprints.isChecked()
config.setting["save_acoustid_fingerprints"] = self.ui.save_acoustid_fingerprints.isChecked()
config.setting["fpcalc_threads"] = self.ui.fpcalc_threads.value()
def update_groupboxes(self):
if self.ui.use_acoustid.isChecked():

View File

@@ -35,6 +35,25 @@ class Ui_FingerprintingOptionsPage(object):
self.save_acoustid_fingerprints = QtWidgets.QCheckBox(self.acoustid_settings)
self.save_acoustid_fingerprints.setObjectName("save_acoustid_fingerprints")
self.verticalLayout_2.addWidget(self.save_acoustid_fingerprints)
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.horizontalLayout_3.setContentsMargins(-1, 0, -1, -1)
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.label_3 = QtWidgets.QLabel(self.acoustid_settings)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth())
self.label_3.setSizePolicy(sizePolicy)
self.label_3.setObjectName("label_3")
self.horizontalLayout_3.addWidget(self.label_3)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_3.addItem(spacerItem)
self.fpcalc_threads = QtWidgets.QSpinBox(self.acoustid_settings)
self.fpcalc_threads.setMinimum(1)
self.fpcalc_threads.setMaximum(9)
self.fpcalc_threads.setObjectName("fpcalc_threads")
self.horizontalLayout_3.addWidget(self.fpcalc_threads)
self.verticalLayout_2.addLayout(self.horizontalLayout_3)
self.label = QtWidgets.QLabel(self.acoustid_settings)
self.label.setObjectName("label")
self.verticalLayout_2.addWidget(self.label)
@@ -67,8 +86,8 @@ class Ui_FingerprintingOptionsPage(object):
self.horizontalLayout.addWidget(self.acoustid_apikey_get)
self.verticalLayout_2.addLayout(self.horizontalLayout)
self.verticalLayout.addWidget(self.acoustid_settings)
spacerItem = QtWidgets.QSpacerItem(181, 21, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.verticalLayout.addItem(spacerItem)
spacerItem1 = QtWidgets.QSpacerItem(181, 21, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.verticalLayout.addItem(spacerItem1)
self.retranslateUi(FingerprintingOptionsPage)
QtCore.QMetaObject.connectSlotsByName(FingerprintingOptionsPage)
@@ -81,6 +100,7 @@ class Ui_FingerprintingOptionsPage(object):
self.acoustid_settings.setTitle(_("AcoustID Settings"))
self.ignore_existing_acoustid_fingerprints.setText(_("Ignore existing AcoustID fingerprints"))
self.save_acoustid_fingerprints.setText(_("Save AcoustID fingerprints to file tags"))
self.label_3.setText(_("Maximum threads to use for calculator:"))
self.label.setText(_("Fingerprint calculator:"))
self.acoustid_fpcalc_browse.setText(_("Browse..."))
self.acoustid_fpcalc_download.setText(_("Download..."))

View File

@@ -57,6 +57,49 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Maximum threads to use for calculator:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="fpcalc_threads">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>9</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">