Skip to content

Commit db83c6f

Browse files
committed
Ruff.
1 parent 151e663 commit db83c6f

4 files changed

Lines changed: 26 additions & 21 deletions

File tree

src/tomato/daemon/cmd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def pipeline(msg: dict, daemon: Daemon) -> Reply:
226226
logger.debug("%s", msg)
227227
pip = msg["params"]
228228
if pip["name"] is None:
229-
logger.error()
229+
logger.error("no pipeline name supplied")
230230
return Reply(success=False, msg="no pipeline name supplied", data=msg)
231231
if pip["name"] not in daemon.pips:
232232
dest = Pipeline(**pip)

src/tomato/daemon/driver.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ def tomato_driver_bootstrap(
4848
comp.name,
4949
)
5050
continue
51-
elif interface.retries.get(key, 0) == MAX_REGISTER_RETRIES:
51+
elif (
52+
hasattr(interface, "retries")
53+
and interface.retries.get(key, 0) == MAX_REGISTER_RETRIES
54+
):
5255
logger.warning(
5356
"component %s has exceeded MAX_REGISTER_RETRIES, skipping",
5457
comp.name,
@@ -266,7 +269,6 @@ def tomato_driver() -> None:
266269
)
267270
elif msg["cmd"] == "settings":
268271
interface.settings = msg["params"]
269-
params["settings"] = interface.settings
270272
ret = Reply(
271273
success=True,
272274
msg="settings received",
@@ -350,7 +352,7 @@ def manager(port: int, timeout: int = 1000):
350352
while getattr(thread, "do_run"):
351353
spawned_drivers = []
352354
msg = dict(cmd="status", sender=sender)
353-
ret, req = lpp.comm(req, msg, **lppargs)
355+
ret, req = lpp.comm(req, msg, **lppargs) # ty: ignore[invalid-argument-type]
354356
if req.closed:
355357
setattr(thread, "do_run", False)
356358
break

src/tomato/daemon/jobdb.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,27 @@
66
77
"""
88

9-
import sqlite3
109
import logging
1110
import os
1211
import pickle
12+
import sqlite3
13+
from pathlib import Path
1314
from tomato.models import Job
1415

1516
logger = logging.getLogger(__name__)
1617

1718

18-
def connect_jobdb(dbpath: str):
19-
head, tail = os.path.split(dbpath)
20-
if head != "" and not os.path.exists(head):
19+
def connect_jobdb(dbpath: str | Path):
20+
head = Path(dbpath).parent
21+
if not head.exists():
2122
logger.warning("making local data folder '%s'", head)
2223
os.makedirs(head)
2324
conn = sqlite3.connect(dbpath)
2425
cur = conn.cursor()
2526
return conn, cur
2627

2728

28-
def jobdb_setup(dbpath: str) -> None:
29+
def jobdb_setup(dbpath: str | Path) -> None:
2930
user_version = 2
3031
conn, cur = connect_jobdb(dbpath)
3132
logger.debug("attempting to find table 'queue' in '%s'", dbpath)

src/tomato/tomato/__init__.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,10 @@ def status(
256256
msg=format_msg(msg=msg, objs=stgrp, yml=yaml, keys=keys, data=rets),
257257
data=rets,
258258
)
259-
260-
return _status_helper(daemon=rep.data, yaml=yaml, stgrp=stgrp)
259+
elif rep.data is not None:
260+
return _status_helper(daemon=rep.data, yaml=yaml, stgrp=stgrp)
261+
else:
262+
return rep
261263
else:
262264
req.setsockopt(zmq.LINGER, 0)
263265
req.close()
@@ -272,7 +274,7 @@ def start(
272274
port: int,
273275
timeout: int,
274276
context: zmq.Context,
275-
appdir: str,
277+
appdir: str | Path,
276278
verbosity: int,
277279
**_: dict,
278280
) -> Reply:
@@ -385,9 +387,9 @@ def stop(
385387

386388
def init(
387389
*,
388-
appdir: str,
389-
datadir: str,
390-
logdir: str,
390+
appdir: str | Path,
391+
datadir: str | Path,
392+
logdir: str | Path,
391393
**_: dict,
392394
) -> Reply:
393395
"""
@@ -474,7 +476,7 @@ def reload(
474476
port: int,
475477
timeout: int,
476478
context: zmq.Context,
477-
appdir: str,
479+
appdir: str | Path,
478480
**_: dict,
479481
) -> Reply:
480482
"""
@@ -491,33 +493,33 @@ def reload(
491493
kwargs = dict(port=port, timeout=timeout, context=context)
492494
logger.debug("Loading settings.toml file from %s.", appdir)
493495
try:
494-
settings = toml.load(Path(appdir) / "settings.toml")
496+
toml.load(Path(appdir) / "settings.toml")
495497
except FileNotFoundError:
496498
return Reply(
497499
success=False,
498500
msg=f"settings file not found in {appdir}, run 'tomato init' to create one",
499501
)
500502

501-
logger.debug(f"status")
503+
logger.debug("status")
502504
ret = status(**kwargs)
503505
if not ret.success:
504506
return ret
505507

506508
req = context.socket(zmq.REQ)
507509
req.connect(f"tcp://127.0.0.1:{port}")
508510

509-
logger.debug(f"reload")
511+
logger.debug("reload")
510512
req.send_pyobj(dict(cmd="reload", sender=f"{__name__}.reload"))
511513
ret = req.recv_pyobj()
512514
if ret.success is False:
513515
return ret
514516

515-
logger.debug(f"setup")
517+
logger.debug("setup")
516518
req.send_pyobj(dict(cmd="setup", sender=f"{__name__}.reload"))
517519
ret = req.recv_pyobj()
518520
if ret.success is False:
519521
return ret
520-
logger.debug(f"done")
522+
logger.debug("done")
521523

522524
return Reply(
523525
success=True,

0 commit comments

Comments
 (0)