Skip to content

Commit

Permalink
Merge pull request #89 from airalab/dev
Browse files Browse the repository at this point in the history
fix datalog feeder to work with higher frequency
  • Loading branch information
tubleronchik authored Jul 17, 2024
2 parents f456228 + 3cfc5b2 commit 682d98d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions connectivity/src/feeders/datalog_feeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,13 @@ def feed(self, data: tp.List[dict]) -> None:

if (time.time() - self.last_time) >= self.interval:
if self.buffer:
self.last_time = time.time()
logger.debug("Datalog Feeder: About to publish collected data...")
logger.debug(f"Datalog Feeder: Buffer is {self.buffer}")
ipfs_hash, file_path, file_size = _get_multihash(self.buffer, self.db, self.ipfs_endpoint)
self._pin_to_temporal(file_path)
_pin_to_pinata(file_path, self.config)
self.buffer = set()
_upload_to_crust(ipfs_hash, int(file_size), self.config["datalog"]["suri"])
os.unlink(file_path)
self.to_datalog(ipfs_hash)
Expand Down Expand Up @@ -240,9 +242,6 @@ def to_datalog(self, ipfs_hash: str) -> None:
:param ipfs_hash: Ipfs hash of the file.
"""

logger.info(ipfs_hash)
self.last_time = time.time()
self.buffer = set()
account = Account(seed=self.config["datalog"]["suri"])
rws = RWS(account)
try:
Expand Down
2 changes: 1 addition & 1 deletion connectivity/src/stations/httpstation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def do_HEAD(self) -> None:
def do_GET(self) -> None:
"""Callback for get requests."""

logger.info("GET request,\nPath: %s\nHeaders:\n%s\n", str(self.path), str(self.headers))
# logger.info("GET request,\nPath: %s\nHeaders:\n%s\n", str(self.path), str(self.headers))
id = self.headers["Sensor-id"]
self._set_headers(id)
logger.info(f"HTTP Station session length: {len(sessions)}")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sensors_connectivity"
version = "1.6.2"
version = "1.6.3"
description = "Robonomics package to read data from sensors and publish to different output channels"
authors = [
"Vadim Manaenko <[email protected]>",
Expand Down
1 change: 1 addition & 0 deletions tests/environmental_box_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def main():
"sensordatavalues": [
{"value_type": "SDS_P1", "value": pm10},
{"value_type": "SDS_P2", "value": pm25},
{"value_type":"DB_Meter","value": 58.00},
{"value_type": "temperature", "value": temperature},
{"value_type": "humidity", "value": humidity},
{"value_type": "samples", "value": "890618"},
Expand Down

0 comments on commit 682d98d

Please sign in to comment.