FileReader #5

Merged
bacant150 merged 15 commits from lab1_huranets into lab1 2026-02-26 10:04:10 +02:00
bacant150 commented 2026-02-24 15:21:43 +02:00 (Migrated from github.com)
  • Прибрав зайве перетворення через float для значень акселерометра (дані — signed int16).
  • Додав перевірку діапазону signed 16-bit.
  • Додав gitignore для mosquitto runtime папок
- Прибрав зайве перетворення через float для значень акселерометра (дані — signed int16). - Додав перевірку діапазону signed 16-bit. - Додав gitignore для mosquitto runtime папок
VladiusVostokus (Migrated from github.com) reviewed 2026-02-24 15:21:43 +02:00
hasslesstech (Migrated from github.com) requested changes 2026-02-24 15:30:38 +02:00
hasslesstech (Migrated from github.com) left a comment

One check may cause troubles in the future and should be removed

One check may cause troubles in the future and should be removed
hasslesstech (Migrated from github.com) commented 2026-02-24 15:25:56 +02:00

This value range check might break future integration with higher precision accelerometer data, hence should be removed

This value range check might break future integration with higher precision accelerometer data, hence should be removed
hasslesstech (Migrated from github.com) approved these changes 2026-02-24 15:44:51 +02:00
hasslesstech (Migrated from github.com) left a comment

The code passes essential CI/CD and looks ready to be merged

The code passes essential CI/CD and looks ready to be merged
hasslesstech (Migrated from github.com) reviewed 2026-02-24 19:38:41 +02:00
hasslesstech (Migrated from github.com) left a comment

Misleading naming and unused variables inside of FileDatasource class

Misleading naming and unused variables inside of FileDatasource class
@@ -1,5 +1,9 @@
from csv import reader
import csv
hasslesstech (Migrated from github.com) commented 2026-02-24 19:37:02 +02:00

Naming convention is misleading, suggests parser specifically takes 16-bit integers. This parser should read any integer value and should just be int(row[0]), not a separate function call

Several identical issues occur in the next few lines

Naming convention is misleading, suggests parser specifically takes 16-bit integers. This parser should read any integer value and should just be `int(row[0])`, not a separate function call Several identical issues occur in the next few lines
hasslesstech (Migrated from github.com) commented 2026-02-24 19:37:45 +02:00

Unused variables, seem to be leftovers from previously removed INT16 boundary checking

Unused variables, seem to be leftovers from previously removed INT16 boundary checking
bacant150 (Migrated from github.com) reviewed 2026-02-24 20:01:55 +02:00
@@ -1,5 +1,9 @@
from csv import reader
import csv
bacant150 (Migrated from github.com) commented 2026-02-24 20:01:55 +02:00

removed unnecessary variables

removed unnecessary variables
hasslesstech (Migrated from github.com) requested changes 2026-02-24 20:12:51 +02:00
@@ -1,5 +1,9 @@
from csv import reader
import csv
hasslesstech (Migrated from github.com) commented 2026-02-24 20:04:13 +02:00

Method is not used and does not provide additional functionality compared to default int() function, so should be removed

Method is not used and does not provide additional functionality compared to default `int()` function, so should be removed
hasslesstech (Migrated from github.com) approved these changes 2026-02-24 20:18:38 +02:00
hasslesstech (Migrated from github.com) left a comment

Unneccesary check removal but is technically correct, should be fine to merge as is

Unneccesary check removal but is technically correct, should be fine to merge as is
hasslesstech (Migrated from github.com) commented 2026-02-24 20:17:50 +02:00

Removal of checks is not neccesary, but is plausible since the source file should only contain correct data

Removal of checks is not neccesary, but is plausible since the source file *should* only contain correct data
bacant150 (Migrated from github.com) reviewed 2026-02-24 20:23:35 +02:00
@@ -1,5 +1,9 @@
from csv import reader
import csv
bacant150 (Migrated from github.com) commented 2026-02-24 20:23:35 +02:00

Fixed: removed int16-specific naming/helpers and now parse accelerometer values directly using int(row[i]) without any bit-width assumptions. Pushed the update to the PR.

Fixed: removed int16-specific naming/helpers and now parse accelerometer values directly using int(row[i]) without any bit-width assumptions. Pushed the update to the PR.
bacant150 (Migrated from github.com) reviewed 2026-02-24 20:24:06 +02:00
@@ -1,5 +1,9 @@
from csv import reader
import csv
bacant150 (Migrated from github.com) commented 2026-02-24 20:24:06 +02:00

Removed the unused _parse_int helper (it didn’t add any functionality over built-in int()). Pushed the update to the PR.

Removed the unused _parse_int helper (it didn’t add any functionality over built-in int()). Pushed the update to the PR.
bacant150 (Migrated from github.com) reviewed 2026-02-24 20:50:52 +02:00
bacant150 (Migrated from github.com) commented 2026-02-24 20:50:52 +02:00

Resumed checks

Resumed checks
hasslesstech (Migrated from github.com) approved these changes 2026-02-24 20:52:50 +02:00
hasslesstech (Migrated from github.com) left a comment

All immediately visible issues have been resolved

All immediately visible issues have been resolved
bacant150 commented 2026-02-24 20:58:30 +02:00 (Migrated from github.com)

Many thanks to Oleg 'hasslesstech', for his guidance and tips during the work.

Many thanks to Oleg 'hasslesstech', for his guidance and tips during the work.
VladiusVostokus (Migrated from github.com) reviewed 2026-02-25 11:10:28 +02:00
@@ -31,0 +127,4 @@
continue
return row
VladiusVostokus (Migrated from github.com) commented 2026-02-25 11:10:29 +02:00

This looks a bit comlex
Why itarate though loop to get 1 row?

This looks a bit comlex Why itarate though loop to get 1 row?
VladiusVostokus (Migrated from github.com) reviewed 2026-02-25 11:14:51 +02:00
@@ -31,0 +108,4 @@
def _get_next_row(self, reader, source: str) -> List[str]:
"""Get the next valid row from the reader."""
if reader is None:
VladiusVostokus (Migrated from github.com) commented 2026-02-25 11:14:51 +02:00

you can just skip first row after seek(0) knowing that this is a header, not actual value,
so you can write like
self._acc_f.seek(0)
self._acc_reader = csv.reader(self._acc_f)
next(self._acc_reader)
row = next(self.acc_reader)

you can just skip first row after seek(0) knowing that this is a header, not actual value, so you can write like self._acc_f.seek(0) self._acc_reader = csv.reader(self._acc_f) next(self._acc_reader) row = next(self.acc_reader)
VladiusVostokus (Migrated from github.com) reviewed 2026-02-25 11:15:57 +02:00
@@ -31,0 +108,4 @@
def _get_next_row(self, reader, source: str) -> List[str]:
"""Get the next valid row from the reader."""
if reader is None:
VladiusVostokus (Migrated from github.com) commented 2026-02-25 11:15:57 +02:00

And do the same for other rewinders

And do the same for other rewinders
VladiusVostokus (Migrated from github.com) reviewed 2026-02-25 11:17:41 +02:00
@@ -1,5 +1,9 @@
from csv import reader
import csv
VladiusVostokus (Migrated from github.com) commented 2026-02-25 11:17:41 +02:00

And after chage of rewinders, you can remove _acc_buf to hold first row

And after chage of rewinders, you can remove _acc_buf to hold first row
VladiusVostokus (Migrated from github.com) reviewed 2026-02-25 11:18:02 +02:00
VladiusVostokus (Migrated from github.com) left a comment

Some changes to simplify code

Some changes to simplify code
VladiusVostokus (Migrated from github.com) reviewed 2026-02-25 11:20:05 +02:00
@@ -31,0 +72,4 @@
self._gps_f = open(self.gps_filename, "r", newline="", encoding="utf-8")
self._acc_reader = csv.reader(self._acc_f, skipinitialspace=True)
self._gps_reader = csv.reader(self._gps_f, skipinitialspace=True)
VladiusVostokus (Migrated from github.com) commented 2026-02-25 11:20:05 +02:00

You just can not return this variable from _detect_header_and_buffer() if it is not used

You just can not return this variable from _detect_header_and_buffer() if it is not used
VladiusVostokus (Migrated from github.com) requested changes 2026-02-25 11:20:16 +02:00
VladiusVostokus (Migrated from github.com) left a comment

Change function

Change function
VladiusVostokus (Migrated from github.com) reviewed 2026-02-25 11:24:42 +02:00
@@ -1,5 +1,9 @@
from csv import reader
import csv
VladiusVostokus (Migrated from github.com) commented 2026-02-25 11:24:43 +02:00

What does this means?
if assuming this is a header with indexies of domain objects maybe make sense.

What does this means? if assuming this is a header with indexies of domain objects maybe make sense.
VladiusVostokus (Migrated from github.com) reviewed 2026-02-25 11:25:18 +02:00
VladiusVostokus (Migrated from github.com) left a comment

question about buffer and lowering

question about buffer and lowering
bacant150 (Migrated from github.com) reviewed 2026-02-25 11:53:08 +02:00
@@ -31,0 +127,4 @@
continue
return row
bacant150 (Migrated from github.com) commented 2026-02-25 11:53:08 +02:00

"Simplified the line reading logic by replacing the while True loop with a clearer check

"Simplified the line reading logic by replacing the while True loop with a clearer check
bacant150 (Migrated from github.com) reviewed 2026-02-25 12:02:35 +02:00
@@ -31,0 +108,4 @@
def _get_next_row(self, reader, source: str) -> List[str]:
"""Get the next valid row from the reader."""
if reader is None:
bacant150 (Migrated from github.com) commented 2026-02-25 12:02:34 +02:00

Refactoring file rewind logic to skip header line after seek(0) and for other rewinders

Refactoring file rewind logic to skip header line after seek(0) and for other rewinders
bacant150 (Migrated from github.com) reviewed 2026-02-25 12:14:42 +02:00
@@ -1,5 +1,9 @@
from csv import reader
import csv
bacant150 (Migrated from github.com) commented 2026-02-25 12:14:42 +02:00

Removed unnecessary buffers like _acc_buf and _gps_buf.

Removed unnecessary buffers like _acc_buf and _gps_buf.
bacant150 (Migrated from github.com) reviewed 2026-02-25 12:36:29 +02:00
@@ -31,0 +72,4 @@
self._gps_f = open(self.gps_filename, "r", newline="", encoding="utf-8")
self._acc_reader = csv.reader(self._acc_f, skipinitialspace=True)
self._gps_reader = csv.reader(self._gps_f, skipinitialspace=True)
bacant150 (Migrated from github.com) commented 2026-02-25 12:36:28 +02:00

removed unnecessary variables from _detect_header_and_buffer() and fixed the _rewind_acc() and _rewind_gps() methods

removed unnecessary variables from _detect_header_and_buffer() and fixed the _rewind_acc() and _rewind_gps() methods
bacant150 (Migrated from github.com) reviewed 2026-02-25 12:53:57 +02:00
@@ -1,5 +1,9 @@
from csv import reader
import csv
bacant150 (Migrated from github.com) commented 2026-02-25 12:53:57 +02:00

I initially tried removing this part, but the testing failed without it

I initially tried removing this part, but the testing failed without it
VladiusVostokus (Migrated from github.com) reviewed 2026-02-25 15:52:46 +02:00
@@ -31,0 +111,4 @@
if reader is None:
raise RuntimeError("Reader is not initialized.")
while True:
VladiusVostokus (Migrated from github.com) commented 2026-02-25 15:52:46 +02:00

Why leave _ here if it's not used?
Maybe dont return anything from this method?

Why leave _ here if it's not used? Maybe dont return anything from this method?
VladiusVostokus (Migrated from github.com) reviewed 2026-02-25 16:00:51 +02:00
@@ -31,0 +111,4 @@
if reader is None:
raise RuntimeError("Reader is not initialized.")
while True:
VladiusVostokus (Migrated from github.com) commented 2026-02-25 16:00:51 +02:00

As I see this method doesn't modify any class fiels, so maybe just remove this method?

As I see this method doesn't modify any class fiels, so maybe just remove this method?
VladiusVostokus (Migrated from github.com) reviewed 2026-02-25 16:05:28 +02:00
@@ -31,0 +75,4 @@
self._gps_reader = csv.reader(self._gps_f, skipinitialspace=True)
# File pointer is already at 0 right after open(), so no need to rewind here.
# Skip header row once.
VladiusVostokus (Migrated from github.com) commented 2026-02-25 16:05:28 +02:00

if you open file, your read pointer is already 0, why to set it to 0 again?

if you open file, your read pointer is already 0, why to set it to 0 again?
VladiusVostokus (Migrated from github.com) reviewed 2026-02-25 16:06:38 +02:00
@@ -31,0 +101,4 @@
def _rewind_gps(self) -> None:
if self._gps_f is None:
raise RuntimeError("GPS file is not open.")
VladiusVostokus (Migrated from github.com) commented 2026-02-25 16:06:38 +02:00

Why leave _ here if it's not used?

Why leave _ here if it's not used?
VladiusVostokus (Migrated from github.com) reviewed 2026-02-25 16:07:10 +02:00
VladiusVostokus (Migrated from github.com) left a comment

Some questions about refactoring

Some questions about refactoring
bacant150 (Migrated from github.com) reviewed 2026-02-25 20:57:58 +02:00
@@ -31,0 +111,4 @@
if reader is None:
raise RuntimeError("Reader is not initialized.")
while True:
bacant150 (Migrated from github.com) commented 2026-02-25 20:57:57 +02:00

The _detect_header_and_buffer method was not modifying any class state and its return value was unused.
I removed the method and simplified the logic.

The _detect_header_and_buffer method was not modifying any class state and its return value was unused. I removed the method and simplified the logic.
bacant150 (Migrated from github.com) reviewed 2026-02-25 21:09:55 +02:00
@@ -31,0 +75,4 @@
self._gps_reader = csv.reader(self._gps_f, skipinitialspace=True)
# File pointer is already at 0 right after open(), so no need to rewind here.
# Skip header row once.
bacant150 (Migrated from github.com) commented 2026-02-25 21:09:54 +02:00

I removed the unnecessary rewind from _open_files().

I removed the unnecessary rewind from _open_files().
bacant150 (Migrated from github.com) reviewed 2026-02-25 21:13:00 +02:00
@@ -31,0 +101,4 @@
def _rewind_gps(self) -> None:
if self._gps_f is None:
raise RuntimeError("GPS file is not open.")
bacant150 (Migrated from github.com) commented 2026-02-25 21:13:00 +02:00

Good catch. The _detect_header_and_buffer helper wasn’t used and didn’t modify class state, so I removed it.

Good catch. The _detect_header_and_buffer helper wasn’t used and didn’t modify class state, so I removed it.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: hasslesstech/IoT-Systems#5