Skip to content

Commit

Permalink
one more lint
Browse files Browse the repository at this point in the history
  • Loading branch information
philkra committed Dec 14, 2023
1 parent 82848e8 commit 0c4130b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 27 deletions.
54 changes: 31 additions & 23 deletions tests/integration-tests/helpers_bulkprocessor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(),
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions xata/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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:
Expand Down Expand Up @@ -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()])


Expand Down

0 comments on commit 0c4130b

Please sign in to comment.