Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

library version updates #174

Merged
merged 4 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,021 changes: 815 additions & 206 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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", "druid"]}
s0nicboOm marked this conversation as resolved.
Show resolved Hide resolved
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
Loading