arbtt: feed data to influxdb

This commit is contained in:
Dima Gerasimov 2021-02-22 22:10:12 +00:00 committed by karlicoss
parent ca4d58e4e7
commit 0585cc4a89
3 changed files with 26 additions and 4 deletions

View file

@ -1,6 +1,8 @@
'''
TODO doesn't really belong to 'core' morally, but can think of moving out later
'''
from .common import assert_subpackage; assert_subpackage(__name__)
from typing import Iterable, Any, Optional, Dict
from .common import LazyLogger, asdict, Json
@ -84,13 +86,17 @@ def fill(it: Iterable[Any], *, measurement: str, reset: bool=False, dt_col: str=
# todo "Specify timestamp precision when writing to InfluxDB."?
def magic_fill(it) -> None:
assert callable(it)
name = f'{it.__module__}:{it.__name__}'
def magic_fill(it, *, name: Optional[str]=None) -> None:
if name is None:
assert callable(it) # generators have no name/module
name = f'{it.__module__}:{it.__name__}'
assert name is not None
if callable(it):
it = it()
from itertools import tee
from more_itertools import first, one
it = it()
it, x = tee(it)
f = first(x, default=None)
if f is None:

View file

@ -66,6 +66,8 @@ def test_freezer() -> None:
###
# TODO shit. what to do with exceptions?
# e.g. good testcase is date parsing issue. should def yield Exception in this case
# fundamentally it should just be Exception aware, dunno
#
# TODO not entirely sure if best to use Frozen as the schema, or actually convert objects..
# guess need to experiment and see