Skip to content

Commit 53927a2

Browse files
committed
Format code with black
1 parent fe167ee commit 53927a2

File tree

7 files changed

+23
-13
lines changed

7 files changed

+23
-13
lines changed

python/mspasspy/algorithms/calib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def __init__(
100100
correction.
101101
"""
102102
db = fetch_dbhandle(dbname_or_handle)
103-
103+
104104
if query:
105105
cursor = db[collection].find(query)
106106
else:

python/mspasspy/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ def __init__(
246246
elif isinstance(url, str) and not url.startswith("mongodb://"):
247247
url = f"mongodb://{url}"
248248

249-
mongo_plugin = MongoDBWorker(dbname=dbname, url=url, dbclient_key="dbclient")
249+
mongo_plugin = MongoDBWorker(
250+
dbname=dbname, url=url, dbclient_key="dbclient"
251+
)
250252
self._dask_client.register_plugin(mongo_plugin, name="mongodb_worker")
251253

252254
def get_database_client(self):

python/mspasspy/db/database.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2160,7 +2160,12 @@ def _delete_attributes(self, collection, keylist, query=None, verbose=False):
21602160
val = doc.pop(k)
21612161
if verbose:
21622162
print(
2163-
"Deleted ", val, " with key=", k, " from doc with id=", id
2163+
"Deleted ",
2164+
val,
2165+
" with key=",
2166+
k,
2167+
" from doc with id=",
2168+
id,
21642169
)
21652170
counts[k] += 1
21662171
n += 1

python/mspasspy/io/distributed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def read_ensemble_parallel(
6969
read_distributed_data. See that function for parameter descriptions.
7070
"""
7171
db = fetch_dbhandle(dbname_or_handle)
72-
72+
7373
if sort_clause:
7474
cursor = db[collection].find(query).sort(sort_clause)
7575
else:

python/mspasspy/util/db_utils.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
def fetch_dbhandle(dbname_or_handle):
1515
"""
1616
Fetch a Database handle from dbname_or_handle.
17-
17+
1818
This function provides a unified way to get a Database instance. In parallel mode
1919
(Dask worker), it fetches the DBClient from the worker plugin to avoid serializing
2020
Database/DBClient objects. In serial mode, it returns the provided Database instance.
21-
21+
2222
:param dbname_or_handle: Either a string (database name) or a Database instance.
2323
If a string is provided, the function assumes it's being called in a Dask worker
2424
context and will get the DBClient from worker.data["dbclient"].
@@ -27,7 +27,7 @@ def fetch_dbhandle(dbname_or_handle):
2727
:raises: ValueError if dbname_or_handle is neither a string nor a Database instance,
2828
or if called with a string outside of a Dask worker context.
2929
"""
30-
30+
3131
if isinstance(dbname_or_handle, str):
3232
try:
3333
worker = get_worker()
@@ -49,7 +49,9 @@ def fetch_dbhandle(dbname_or_handle):
4949
elif isinstance(dbname_or_handle, Database):
5050
db = dbname_or_handle
5151
else:
52-
message = "fetch_dbhandle: illegal type for arg1={}\n".format(type(dbname_or_handle))
52+
message = "fetch_dbhandle: illegal type for arg1={}\n".format(
53+
type(dbname_or_handle)
54+
)
5355
message += "Must be str defining a db name or a Database object"
5456
raise ValueError(message)
5557
return db
@@ -64,7 +66,9 @@ class MongoDBWorker(WorkerPlugin):
6466
connection leaks when Database objects are serialized to workers.
6567
"""
6668

67-
def __init__(self, dbname, url="mongodb://localhost:27017/", dbclient_key="dbclient"):
69+
def __init__(
70+
self, dbname, url="mongodb://localhost:27017/", dbclient_key="dbclient"
71+
):
6872
self.dbname = dbname
6973
self.connection_url = url
7074
self.dbclient_key = dbclient_key
@@ -82,4 +86,3 @@ def teardown(self, worker):
8286
dbclient = worker.data.get(self.dbclient_key)
8387
if dbclient:
8488
dbclient.close()
85-

python/mspasspy/util/seispp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def index_data(filebase, dbname_or_handle, ext="d3C", verbose=False):
3434
"""
3535

3636
db = fetch_dbhandle(dbname_or_handle)
37-
37+
3838
# This loads default mspass schema
3939
mdef = MetadataDefinitions()
4040
yamlfile = filebase + ".yaml"

python/tests/io/test_distributed.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ def test_read_distributed_ensemble(
11951195
if wfid in wfl:
11961196
number_hits += 1
11971197
assert number_hits == 1
1198-
1198+
11991199
# Clean up: close dask client
12001200
if scheduler == "dask":
12011201
dask_client.close()
@@ -1614,7 +1614,7 @@ def test_write_distributed_ensemble(
16141614
assert d.is_defined("dir")
16151615
assert d.is_defined("dfile")
16161616
assert d["storage_mode"] == "file"
1617-
1617+
16181618
# Clean up: close dask client
16191619
if scheduler == "dask":
16201620
dask_client.close()

0 commit comments

Comments
 (0)