Skip to content

Commit 80c5a70

Browse files
committed
formatting, fix tests
1 parent c18fcd4 commit 80c5a70

File tree

8 files changed

+18
-20
lines changed

8 files changed

+18
-20
lines changed

countess/core/pipeline.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from enum import Enum
21
import logging
32
import re
43
import secrets
4+
import threading
55
import time
6+
from enum import Enum
67
from typing import Any, Iterable, Optional
7-
import threading
88

99
import duckdb
1010

@@ -15,13 +15,15 @@
1515

1616
logger = logging.getLogger(__name__)
1717

18+
1819
class PipelineNodeStatus(Enum):
1920
INIT = 0
2021
WAIT = 1
2122
WORK = 2
2223
DONE = 3
2324
STOP = 4
2425

26+
2527
class PipelineNode:
2628
name: str
2729
uuid: str
@@ -87,7 +89,7 @@ def load_config(self):
8789

8890
cursor = None
8991
thread = None
90-
status : PipelineNodeStatus = PipelineNodeStatus.INIT
92+
status: PipelineNodeStatus = PipelineNodeStatus.INIT
9193
table_name = None
9294

9395
def start(self, ddbc, row_limit: Optional[int] = None):
@@ -122,7 +124,6 @@ def _run():
122124
self.status = PipelineNodeStatus.WORK
123125
logger.debug("PipelineNode.start _run work %s", self.name)
124126

125-
126127
sources = {pn.name: self.cursor.table(pn.table_name) for pn in self.parent_nodes if pn.table_name}
127128
logger.debug("PipelineNode.start _run sources %s", sources.keys())
128129
self.plugin.prepare_multi(ddbc, sources)

countess/core/plugins.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class DuckdbLoadFilePlugin(DuckdbInputPlugin):
219219
files = FileArrayParam("Files", LoadFileMultiParam("File"))
220220
file_types: Sequence[tuple[str, Union[str, list[str]]]] = [("Any", "*")]
221221

222-
progress : float = 0
222+
progress: float = 0
223223

224224
def __init__(self, *a, **k):
225225
super().__init__(*a, **k)
@@ -307,8 +307,6 @@ def load_file(
307307

308308

309309
class DuckdbParallelLoadFilePlugin(DuckdbLoadFilePlugin):
310-
311-
312310
def execute(
313311
self, ddbc: DuckDBPyConnection, source: None, row_limit: Optional[int] = None
314312
) -> Optional[DuckDBPyRelation]:
@@ -362,7 +360,6 @@ def load_file(
362360
raise NotImplementedError(f"{self.__class__}.load_file")
363361

364362

365-
366363
class DuckdbLoadFileWithTheLotPlugin(LoadFileDeGlobMixin, LoadFileWithFilenameMixin, DuckdbParallelLoadFilePlugin):
367364
"""This recombines the various parts which got broken out into mixins back into
368365
the original one-with-the-lot load file plugin base"""

countess/gui/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ def show_preview_subframe(self):
211211
if not self.node.plugin.show_preview:
212212
return
213213

214-
215214
if isinstance(self.node.result, DuckDBPyRelation):
216215
self.preview_subframe = TabularDataFrame(self.frame, cursor="arrow")
217216
self.preview_subframe.set_table(self.ddbc, self.node.result)
@@ -254,7 +253,6 @@ def config_change_task_callback(self):
254253
"""Called when the user makes a change and had paused for a bit"""
255254
self.config_change_task = None
256255
logger.debug("config_change_task_callback")
257-
#pos1, pos2 = self.config_scrollbar.get()
258256

259257
self.node.stop()
260258
self.node.start(self.ddbc, preview_row_limit)
@@ -287,7 +285,6 @@ def config_change_poll_done(self):
287285
self.config_canvas.yview_moveto(pos1)
288286
self.config_scrollbar.set(pos1, pos2)
289287

290-
291288
def choose_plugin(self, plugin_class):
292289
self.node.plugin = plugin_class()
293290
# self.node.prerun()
@@ -663,6 +660,8 @@ def main() -> None:
663660
args = sys.argv[1:]
664661
global preview_row_limit # pylint: disable=global-statement
665662

663+
logging.getLogger().setLevel('INFO')
664+
666665
try:
667666
options, args = getopt.getopt(args, "", ["help", "version", "preview=", "log="])
668667
except getopt.GetoptError as exc:

countess/gui/tabular.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import io
22
import logging
3+
import threading
34
import tkinter as tk
45
from functools import partial
56
from math import ceil, floor, isinf, isnan
6-
import threading
77
from tkinter import ttk
88
from typing import Callable, Optional, Union
99

@@ -301,7 +301,6 @@ def _create_index_monitor():
301301
else:
302302
_create_index_continue()
303303

304-
305304
def _label_button_1(self, num, event):
306305
"""Click on column labels to set sort order"""
307306
self.set_sort_order(num)
@@ -390,5 +389,5 @@ def _column_copy(self, _):
390389

391390
# Dump TSV into a StringIO and push it onto the clipboard
392391
buf = io.StringIO()
393-
table.to_csv(buf, sep="\t", index=False)
392+
table.to_df().to_csv(buf, sep="\t", index=False)
394393
copy_to_clipboard(buf.getvalue())

countess/plugins/csv.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from countess.core.plugins import (
2828
DuckdbLoadFilePlugin,
2929
DuckdbSaveFilePlugin,
30-
DuckdbParallelLoadFilePlugin,
3130
LoadFileDeGlobMixin,
3231
LoadFileWithFilenameMixin,
3332
)

countess/plugins/variant.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def transform(self, data: dict[str, Any]) -> Optional[dict[str, Any]]:
112112
minus_strand=self.variant.minus_strand.value,
113113
)
114114
except TooManyVariationsException:
115-
return None
115+
pass
116116
except (ValueError, TypeError, KeyError, IndexError) as exc:
117117
logger.warning("Exception", exc_info=exc)
118118

@@ -128,7 +128,7 @@ def transform(self, data: dict[str, Any]) -> Optional[dict[str, Any]]:
128128
offset=int(self.protein.offset.get_value_from_dict(data) or 0),
129129
)
130130
except TooManyVariationsException:
131-
return None
131+
pass
132132
except (ValueError, TypeError, KeyError, IndexError) as exc:
133133
logger.warning("Exception", exc_info=exc)
134134

@@ -171,7 +171,7 @@ def sql(self, table_name: str, columns: Iterable[str]) -> Optional[str]:
171171
"""
172172

173173

174-
def _translate_aa(expr: str, expr1: str = None) -> str:
174+
def _translate_aa(expr: str, expr1: str = '') -> str:
175175
# This looks ludicrous but it pushes all the work down into SQL so that
176176
# duckdb can run it without translating rows into Python etc.
177177
return (

tests/gui/test_tabular.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,8 @@ def test_tabular_copy():
4343

4444
x = root.selection_get(selection="CLIPBOARD")
4545
assert (
46-
x == "x\ty\tz\n30\t6255274016445075936\t1382406602978853548\n31\t13285076694688170502\t14198994021025867918\n\n"
46+
x == """x\ty\tz
47+
29\t687214525942812148\t13438185942843147596
48+
30\t6255274016445075936\t1382406602978853548
49+
31\t13285076694688170502\t14198994021025867918\n\n"""
4750
)

tests/plugins/test_csv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_filename_column():
5858
plugin.set_parameter("filename_column", True)
5959
output = plugin.execute(ddbc, None)
6060
assert "filename" in output.columns
61-
assert output.df()["filename"].iloc[1] == "input1"
61+
assert output.df()["filename"].iloc[1] == "tests/input1.csv"
6262

6363

6464
df = pd.DataFrame([[1, 2.01, "three"], [4, 5.5, "six"], [7, 8.8, "nine"]], columns=["a", "b", "c"])

0 commit comments

Comments
 (0)