Skip to content

Commit

Permalink
fix: training only when model loading from registry source (#159)
Browse files Browse the repository at this point in the history
Signed-off-by: s0nicboOm <[email protected]>
  • Loading branch information
s0nicboOm committed Jul 7, 2023
1 parent 3e2a40a commit 620d1f3
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 31 deletions.
2 changes: 2 additions & 0 deletions numaprom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def emit(self, record):

def __get_logger() -> logger:
# Collect logs from logging library
logging.getLogger("pytorch_lightning.utilities.rank_zero").setLevel(logging.WARNING)
logging.getLogger("pytorch_lightning.accelerators.cuda").setLevel(logging.WARNING)
logging.basicConfig(handlers=[InterceptHandler()], level=0)
logger.remove()

Expand Down
2 changes: 2 additions & 0 deletions numaprom/default-configs/numalogic_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ preprocess:
- name: "StandardScaler"
threshold:
name: "StdDevThreshold"
conf:
min_threshold: 0.01
postprocess:
name: "TanhNorm"
stateful: false
13 changes: 11 additions & 2 deletions numaprom/udf/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,17 @@ def inference(_: list[str], datum: Datum) -> bytes:
payload.set_status(Status.ARTIFACT_NOT_FOUND)
return orjson.dumps(payload, option=orjson.OPT_SERIALIZE_NUMPY)

# Check if current model is stale
if RedisRegistry.is_artifact_stale(artifact_data, int(metric_config.retrain_freq_hr)):
LOGGER.info(
"{uuid} - Loaded artifact data from {source} ",
uuid=payload.uuid,
source=artifact_data.extras.get("source"),
)

# Check if current model is stale and source is 'registry'
if (
RedisRegistry.is_artifact_stale(artifact_data, int(metric_config.retrain_freq_hr))
and artifact_data.extras.get("source") == "registry"
):
payload.set_header(Header.MODEL_STALE)

# Generate predictions
Expand Down
Loading

0 comments on commit 620d1f3

Please sign in to comment.