Skip to content

Commit

Permalink
library version updates (#174)
Browse files Browse the repository at this point in the history
Signed-off-by: s0nicboOm <[email protected]>
  • Loading branch information
s0nicboOm authored Dec 4, 2023
1 parent d762753 commit 091deb0
Show file tree
Hide file tree
Showing 8 changed files with 813 additions and 222 deletions.
3 changes: 2 additions & 1 deletion numaprom/default-configs/numalogic_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ model:
- 16
dropout_p: 0.25
trainer:
max_epochs: 30
pltrainer_conf:
max_epochs: 30
preprocess:
- name: "StandardScaler"
threshold:
Expand Down
4 changes: 2 additions & 2 deletions numaprom/udf/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from typing import Final

from numalogic.config import NumalogicConf
from numalogic.models.autoencoder import AutoencoderTrainer
from numalogic.registry import ArtifactData, RedisRegistry, LocalLRUCache
from numalogic.tools.data import StreamingDataset
from numalogic.tools.exceptions import RedisRegistryError
from numalogic.tools.trainer import TimeseriesTrainer
from orjson import orjson
from pynumaflow.mapper import Datum
from torch.utils.data import DataLoader
Expand All @@ -32,7 +32,7 @@ def _run_inference(
stream_data = payload.get_stream_array()
stream_loader = DataLoader(StreamingDataset(stream_data, numalogic_conf.model.conf["seq_len"]))

trainer = AutoencoderTrainer()
trainer = TimeseriesTrainer()
try:
recon_err = trainer.predict(model, dataloaders=stream_loader)
except Exception as err:
Expand Down
6 changes: 3 additions & 3 deletions numaprom/udsink/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
import pandas as pd
from numalogic.config import PreprocessFactory, ModelInfo, ThresholdFactory, ModelFactory
from numalogic.models.autoencoder import AutoencoderTrainer
from numalogic.models.autoencoder import TimeseriesTrainer
from numalogic.registry import RedisRegistry
from numalogic.tools.data import StreamingDataset
from numalogic.tools.exceptions import RedisRegistryError
Expand Down Expand Up @@ -43,7 +43,7 @@ def _train_model(uuid, x, model_cfg, trainer_cfg):
model = model_factory.get_instance(model_cfg)
dataset = StreamingDataset(x, model.seq_len)

trainer = AutoencoderTrainer(**trainer_cfg)
trainer = TimeseriesTrainer(**trainer_cfg.pltrainer_conf)
trainer.fit(model, train_dataloaders=DataLoader(dataset, batch_size=64))

LOGGER.debug(
Expand Down Expand Up @@ -121,7 +121,7 @@ def train(datums: list[Datum]) -> Responses:
payload,
metric_config,
{"namespace": payload.composite_keys["namespace"]},
hours=metric_config.train_hours,
hours=metric_config.numalogic_conf.trainer.train_hours,
)
train_df = clean_data(train_df)

Expand Down
6 changes: 3 additions & 3 deletions numaprom/udsink/train_rollout.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from numalogic.tools.exceptions import InvalidDataShapeError
import pandas as pd
from numalogic.config import PreprocessFactory, ModelInfo, ThresholdFactory, ModelFactory
from numalogic.models.autoencoder import AutoencoderTrainer
from numalogic.models.autoencoder import TimeseriesTrainer
from numalogic.registry import RedisRegistry
from numalogic.tools.data import StreamingDataset
from numalogic.tools.exceptions import RedisRegistryError
Expand Down Expand Up @@ -57,7 +57,7 @@ def _train_model(uuid, x, model_cfg, trainer_cfg):
model = model_factory.get_instance(model_cfg)
dataset = StreamingDataset(x, model.seq_len)

trainer = AutoencoderTrainer(**trainer_cfg)
trainer = TimeseriesTrainer(**trainer_cfg.pltrainer_conf)
trainer.fit(model, train_dataloaders=DataLoader(dataset, batch_size=64))

LOGGER.debug(
Expand Down Expand Up @@ -145,7 +145,7 @@ def train_rollout(datums: Iterator[Datum]) -> Responses:
metric_config,
{"namespace": payload.composite_keys["namespace"]},
return_labels=[hash_label],
hours=metric_config.train_hours,
hours=metric_config.numalogic_conf.trainer.train_hours,
)
try:
train_df = clean_data(train_df, hash_label)
Expand Down
1,001 changes: 795 additions & 206 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "numalogic-prometheus"
version = "0.6.0"
version = "0.6.1dev0"
description = "ML inference on numaflow using numalogic on Prometheus metrics"
authors = ["Numalogic developers"]
packages = [{ include = "numaprom" }]
Expand All @@ -19,14 +19,14 @@ repository = "https://github.com/numaproj/numalogic-prometheus"

[tool.poetry.dependencies]
python = "~3.10"
redis = {extras = ["hiredis"], version = "^4.5" }
redis = {extras = ["hiredis"], version = "^5.0.1" }
pynumaflow = "~0.5"
numalogic = {version = "~0.5", extras = ["redis"]}
numalogic = {version = "0.6.1.dev5", extras = ["redis"]}
orjson = "^3.8.4"
omegaconf = "^2.3.0"
watchdog = "^3.0.0"
loguru = "^0.7.0"
prometheus-client = "^0.17"
prometheus-client = "^0.19"

[tool.poetry.group.dev]
optional = true
Expand Down
3 changes: 2 additions & 1 deletion tests/resources/configs/numalogic_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ model:
- 16
dropout_p: 0.25
trainer:
max_epochs: 5
pltrainer_conf:
max_epochs: 5
preprocess:
- name: "LogTransformer"
stateful: false
Expand Down
4 changes: 2 additions & 2 deletions tests/udf/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from unittest.mock import patch, Mock

from freezegun import freeze_time
from numalogic.models.autoencoder import AutoencoderTrainer
from numalogic.models.autoencoder import TimeseriesTrainer
from numalogic.registry import RedisRegistry
from orjson import orjson
from pynumaflow.mapper import Messages
Expand Down Expand Up @@ -52,7 +52,7 @@ def test_inference(self):

@freeze_time("2022-02-20 12:00:00")
@patch.object(RedisRegistry, "load", Mock(return_value=return_mock_lstmae()))
@patch.object(AutoencoderTrainer, "predict", Mock(side_effect=RuntimeError))
@patch.object(TimeseriesTrainer, "predict", Mock(side_effect=RuntimeError))
def test_inference_err(self):
for msg in self.inference_input:
_out = inference([""], get_datum(msg.value))
Expand Down

0 comments on commit 091deb0

Please sign in to comment.