Skip to content

Commit

Permalink
Fix type issues in plugins package
Browse files Browse the repository at this point in the history
  • Loading branch information
rnv812 committed Jan 2, 2025
1 parent 9ecb6f3 commit 2f966e2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions eventum/plugins/input/merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ def _unminimize_batch(
shape=timestamps.size,
dtype=[('timestamp', 'datetime64[us]'), ('id', 'uint16')]
)
unminimized_batch['timestamp'] = timestamps
unminimized_batch['id'] = id
unminimized_batch['timestamp'][:] = timestamps
unminimized_batch['id'][:] = id

return unminimized_batch

Expand Down Expand Up @@ -427,7 +427,7 @@ def _generate_with_ordering(self) -> Iterator[TimestampIdBatch]:

if self._active_plugin_indices:
# finding latest timestamp that will be a cutoff point
latest_timestamp = np.datetime64(datetime.min)
latest_timestamp = np.datetime64(datetime.min.isoformat())
for batch in batches:
last_timestamp: np.datetime64 = batch['timestamp'][-1]

Expand Down
6 changes: 5 additions & 1 deletion eventum/plugins/input/plugins/http/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from ipaddress import IPv4Address
from pydantic import Field, IPvAnyAddress

from eventum.plugins.input.base.config import InputPluginConfig
Expand All @@ -17,5 +18,8 @@ class HttpInputPluginConfig(
port : int
Port to listen
"""
ip: IPvAnyAddress = Field(default='0.0.0.0', validate_default=True)
ip: IPvAnyAddress = Field(
default=IPv4Address('0.0.0.0'),
validate_default=True
)
port: int = Field(ge=1)
2 changes: 1 addition & 1 deletion eventum/plugins/input/plugins/linspace/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _generate(self) -> NDArray[datetime64]:
endpoint=self._config.endpoint,
)

first = datetime64(to_naive(start, self._timezone), 'us')
first = datetime64(to_naive(start, self._timezone).isoformat(), 'us')
timedelta = timedelta64((end - start), 'us')

timestamps = first + (timedelta * space)
Expand Down
4 changes: 2 additions & 2 deletions eventum/plugins/input/plugins/timer/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _generate_sample(self) -> None:
)

timestamps = deltas + datetime64(
to_naive(start, self._timezone), 'us'
to_naive(start, self._timezone).isoformat(), 'us'
)
timestamps = repeat(timestamps, repeats=self._config.count)
self._enqueue(timestamps)
Expand Down Expand Up @@ -126,7 +126,7 @@ def _generate_live(self) -> None:
full(
shape=self._config.count,
fill_value=datetime64(
to_naive(timestamp, self._timezone), 'us'
to_naive(timestamp, self._timezone).isoformat(), 'us'
),
dtype='datetime64[us]'
)
Expand Down
2 changes: 1 addition & 1 deletion eventum/plugins/input/utils/tests/test_time_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_now64():
tz = pytz.timezone('Europe/Moscow')
now = datetime.now().astimezone(tz).replace(tzinfo=None)

expected = datetime64(now, 'us')
expected = datetime64(now.isoformat(), 'us')
result = now64(timezone=tz)

assert 0 <= ((result - expected) / timedelta64(1000000, 'us')) < 0.5
Expand Down

0 comments on commit 2f966e2

Please sign in to comment.