Skip to content

Commit

Permalink
case sensitive search, button label (#278)
Browse files Browse the repository at this point in the history
* case sensitive search, button label

* use ibridges v >=1.2.0 but < 1.3

* add python3.13
  • Loading branch information
chStaiger authored Nov 4, 2024
1 parent 12b675f commit c192d1f
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 31 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
include:
- os: windows-latest
python-version: "3.11"
python-version: "3.12"
- os: macos-latest
python-version: "3.11"
python-version: "3.12"
runs-on: ${{ matrix.os }}

steps:
Expand Down
16 changes: 12 additions & 4 deletions ibridgesgui/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,24 @@ def search(self):
self.error_label.clear()
self.current_batch_num = 0
self.results = None
case_sensitive = self.case_sensitive_box.isChecked()

msg, search_path, path_pattern, meta_searches, checksum = self._validate_search_params()
self.logger.debug(
"Search parameters %s, %s, %s, %s, %s",
"Search parameters %s, %s, %s, %s, %s, %s",
msg,
str(search_path),
path_pattern,
str(meta_searches),
checksum,
str(case_sensitive),
)
if msg is not None:
self.error_label.setText(msg)
self.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.ArrowCursor))
return

self._start_search(search_path, path_pattern, meta_searches, checksum)
self._start_search(search_path, path_pattern, meta_searches, checksum, case_sensitive)

def next_batch(self):
"""Load next batch of results."""
Expand Down Expand Up @@ -283,7 +285,7 @@ def _download_fetch_result(self, thread: dict):
self.error_label.setText("Errors occurred during download. Consult the logs.")
self.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.ArrowCursor))

def _start_search(self, search_path, path_pattern, meta_searches, checksum):
def _start_search(self, search_path, path_pattern, meta_searches, checksum, case_sensitive):
self.search_button.setEnabled(False)
# check if session comes from env file in ibridges config
if is_session_from_config(self.session):
Expand All @@ -296,7 +298,13 @@ def _start_search(self, search_path, path_pattern, meta_searches, checksum):
self.error_label.setText("Searching ...")
try:
self.search_thread = SearchThread(
self.logger, env_path, search_path, path_pattern, meta_searches, checksum
self.logger,
env_path,
search_path,
path_pattern,
meta_searches,
checksum,
case_sensitive,
)
except Exception:
self.error_label.setText(
Expand Down
39 changes: 24 additions & 15 deletions ibridgesgui/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ class SearchThread(QThread):

result = pyqtSignal(dict)

def __init__(self, logger, ienv_path: Path, search_path: IrodsPath, path_pattern: str,
meta_searches: list, checksum: str):
def __init__(
self,
logger,
ienv_path: Path,
search_path: IrodsPath,
path_pattern: str,
meta_searches: list,
checksum: str,
case_sensitive: bool,
):
"""Pass searh parameters."""
super().__init__()
self.logger = logger
Expand All @@ -24,6 +32,7 @@ def __init__(self, logger, ienv_path: Path, search_path: IrodsPath, path_pattern
self.search_path = search_path
self.path_pattern = path_pattern
self.checksum = checksum
self.case_sensitive = case_sensitive
self.ms = meta_searches

def _delete_session(self):
Expand All @@ -38,8 +47,12 @@ def run(self):
search_out = {}
try:
res = search_data(
self.thread_session, path=self.search_path, path_pattern = self.path_pattern,
checksum=self.checksum, metadata=self.ms
self.thread_session,
path=self.search_path,
path_pattern=self.path_pattern,
checksum=self.checksum,
metadata=self.ms,
case_sensitive=self.case_sensitive,
)
# convert IrodsPaths to strings, the session will be destroyed at the end of the thread
search_out["results"] = [str(ipath) for ipath in res]
Expand All @@ -49,6 +62,7 @@ def run(self):
search_out["error"] = "Search takes too long. Please provide more parameters."
self.result.emit(search_out)


class TransferDataThread(QThread):
"""Transfer data between local and iRODS."""

Expand Down Expand Up @@ -128,12 +142,9 @@ def run(self):
transfer_out["error"]
+ f"\nTransfer failed, cannot upload {str(local_path)}: {repr(error)}"
)
self.current_progress.emit([self.up_sizes,
transferred_size,
obj_count,
len(self.ops.upload),
obj_failed])

self.current_progress.emit(
[self.up_sizes, transferred_size, obj_count, len(self.ops.upload), obj_failed]
)

transferred_size = 0
for irods_path, local_path in self.ops.download:
Expand Down Expand Up @@ -166,11 +177,9 @@ def run(self):
transfer_out["error"]
+ f"\nTransfer failed, cannot download {str(irods_path)}: {repr(error)}"
)
self.current_progress.emit([self.down_sizes,
transferred_size,
file_count,
len(self.ops.download),
file_failed])
self.current_progress.emit(
[self.down_sizes, transferred_size, file_count, len(self.ops.download), file_failed]
)

self.ops.execute_meta_download()
self._delete_session()
Expand Down
2 changes: 1 addition & 1 deletion ibridgesgui/ui_files/tabBrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def retranslateUi(self, tabBrowser):
self.delete_meta_button.setText(_translate("tabBrowser", "Delete"))
self.label_4.setText(_translate("tabBrowser", "Key"))
self.label_3.setText(_translate("tabBrowser", "Edit"))
self.update_meta_button.setText(_translate("tabBrowser", "Set"))
self.update_meta_button.setText(_translate("tabBrowser", "Set all keys .."))
self.label_6.setText(_translate("tabBrowser", "Value"))
self.info_tabs.setTabText(self.info_tabs.indexOf(self.metadata), _translate("tabBrowser", "Metadata"))
self.info_tabs.setTabText(self.info_tabs.indexOf(self.preview), _translate("tabBrowser", "Preview"))
Expand Down
2 changes: 1 addition & 1 deletion ibridgesgui/ui_files/tabBrowser.ui
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ QTabWidget#info_tabs
</font>
</property>
<property name="text">
<string>Set</string>
<string>Set all keys ..</string>
</property>
</widget>
</item>
Expand Down
18 changes: 12 additions & 6 deletions ibridgesgui/ui_files/tabSearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ def setupUi(self, tabSearch):
self.verticalLayout.addLayout(self.gridLayout)
spacerItem3 = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed)
self.verticalLayout.addItem(spacerItem3)
self.case_sensitive_box = QtWidgets.QCheckBox(parent=tabSearch)
self.case_sensitive_box.setObjectName("case_sensitive_box")
self.verticalLayout.addWidget(self.case_sensitive_box)
spacerItem4 = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed)
self.verticalLayout.addItem(spacerItem4)
self.horizontalLayout_5 = QtWidgets.QHBoxLayout()
self.horizontalLayout_5.setObjectName("horizontalLayout_5")
self.search_button = QtWidgets.QPushButton(parent=tabSearch)
Expand All @@ -162,8 +167,8 @@ def setupUi(self, tabSearch):
self.load_more_button = QtWidgets.QPushButton(parent=tabSearch)
self.load_more_button.setObjectName("load_more_button")
self.horizontalLayout_5.addWidget(self.load_more_button)
spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
self.horizontalLayout_5.addItem(spacerItem4)
spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
self.horizontalLayout_5.addItem(spacerItem5)
self.download_button = QtWidgets.QPushButton(parent=tabSearch)
font = QtGui.QFont()
font.setPointSize(16)
Expand Down Expand Up @@ -203,11 +208,11 @@ def setupUi(self, tabSearch):
self.search_table.setHorizontalHeaderItem(4, item)
self.search_table.horizontalHeader().setStretchLastSection(True)
self.verticalLayout.addWidget(self.search_table)
spacerItem5 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding)
self.verticalLayout.addItem(spacerItem5)
self.verticalLayout_3.addLayout(self.verticalLayout)
spacerItem6 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding)
self.verticalLayout_3.addItem(spacerItem6)
self.verticalLayout.addItem(spacerItem6)
self.verticalLayout_3.addLayout(self.verticalLayout)
spacerItem7 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding)
self.verticalLayout_3.addItem(spacerItem7)

self.retranslateUi(tabSearch)
QtCore.QMetaObject.connectSlotsByName(tabSearch)
Expand All @@ -223,6 +228,7 @@ def retranslateUi(self, tabSearch):
self.label1.setText(_translate("tabSearch", "Search by Metadata"))
self.label_7.setText(_translate("tabSearch", "Units"))
self.label_4.setText(_translate("tabSearch", "Key"))
self.case_sensitive_box.setText(_translate("tabSearch", "Case sensitive"))
self.search_button.setText(_translate("tabSearch", "Search"))
self.clear_button.setText(_translate("tabSearch", "Clear Results"))
self.load_more_button.setText(_translate("tabSearch", "Next 25"))
Expand Down
23 changes: 23 additions & 0 deletions ibridgesgui/ui_files/tabSearch.ui
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,29 @@ QTabWidget#info_tabs
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="case_sensitive_box">
<property name="text">
<string>Case sensitive</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Development Status :: 3 - Alpha",
]

dependencies = [
"PyQt6>=6.4.2",
"ibridges==1.1.1",
"ibridges>=1.2.0, < 1.3",
"setproctitle==1.3.3",
"importlib-resources;python_version<='3.10'",
]
Expand Down

0 comments on commit c192d1f

Please sign in to comment.