From 0c4130bc6cba7121266d3267bd75c95315255717 Mon Sep 17 00:00:00 2001 From: Philip Krauss Date: Thu, 14 Dec 2023 12:31:02 +0100 Subject: [PATCH] one more lint --- .../helpers_bulkprocessor_test.py | 54 +++++++++++-------- xata/helpers.py | 8 +-- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/tests/integration-tests/helpers_bulkprocessor_test.py b/tests/integration-tests/helpers_bulkprocessor_test.py index 5de9337..e0319ef 100644 --- a/tests/integration-tests/helpers_bulkprocessor_test.py +++ b/tests/integration-tests/helpers_bulkprocessor_test.py @@ -38,27 +38,35 @@ def setup_class(self): assert self.client.table().create("Users").is_success() # create schema - assert self.client.table().set_schema( - "Posts", - { - "columns": [ - {"name": "title", "type": "string"}, - {"name": "text", "type": "text"}, - ] - }, - ).is_success() - assert self.client.table().set_schema( - "Users", - { - "columns": [ - {"name": "username", "type": "string"}, - {"name": "email", "type": "string"}, - ] - }, - ).is_success() + assert ( + self.client.table() + .set_schema( + "Posts", + { + "columns": [ + {"name": "title", "type": "string"}, + {"name": "text", "type": "text"}, + ] + }, + ) + .is_success() + ) + assert ( + self.client.table() + .set_schema( + "Users", + { + "columns": [ + {"name": "username", "type": "string"}, + {"name": "email", "type": "string"}, + ] + }, + ) + .is_success() + ) def teardown_class(self): - #assert self.client.databases().delete(self.db_name).is_success() + # assert self.client.databases().delete(self.db_name).is_success() pass @pytest.fixture @@ -70,7 +78,7 @@ def _get_record(self) -> dict: "title": self.fake.company(), "text": self.fake.text(), } - + def _get_user(self) -> dict: return { "username": self.fake.name(), @@ -113,7 +121,7 @@ def test_flush_queue(self): assert r.is_success() assert "summaries" in r assert r["summaries"][0]["proof"] == 1000 - + stats = bp.get_stats() assert stats["total"] == 1000 assert stats["queue"] == 0 @@ -136,7 +144,7 @@ def test_flush_queue_many_threads(self): assert r.is_success() assert "summaries" in r assert r["summaries"][0]["proof"] == 750 - + stats = bp.get_stats() assert stats["total"] == 750 assert stats["queue"] == 0 @@ -167,7 +175,7 @@ def test_multiple_tables(self): assert r.is_success() assert "summaries" in r assert r["summaries"][0]["proof"] == 33 * 7 - + stats = bp.get_stats() assert stats["queue"] == 0 assert stats["failed_batches"] == 0 diff --git a/xata/helpers.py b/xata/helpers.py index de4e3fc..71f71ed 100644 --- a/xata/helpers.py +++ b/xata/helpers.py @@ -182,7 +182,7 @@ def get_stats(self): :returns dict """ return self.stats - + def get_queue_size(self) -> int: with self.stats_lock: return self.stats["queue"] @@ -196,8 +196,8 @@ def flush_queue(self): # force flush the records queue and shorten the processing times self.records.force_queue_flush() - #self.processing_timeout = 1 / len(self.thread_workers) - #time.sleep(self.processing_timeout) + # self.processing_timeout = 1 / len(self.thread_workers) + # time.sleep(self.processing_timeout) # ensure the full records queue is flushed first while self.records.size() > 0: @@ -305,7 +305,7 @@ def size(self) -> int: Get total size of stored records """ with self.lock: - #return sum([len(self.store[n]["records"]) for n in self.store.keys()]) + # return sum([len(self.store[n]["records"]) for n in self.store.keys()]) return sum([self.length(n) for n in self.store.keys()])