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

fix(anomaly-detection): Handle illegal padding amount #1136

Merged
merged 2 commits into from
Sep 9, 2024

Conversation

aayush-se
Copy link
Member

  • Util raises exception if requested length for padding is less than current mp_dist array

Note: is there a more graceful way to handle this?

@@ -42,6 +42,8 @@ def get_mp_dist_from_mp(
mp_dist = normalizer.normalize(mp_dist)

if pad_to_len is not None:
if pad_to_len - len(mp_dist) < 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: len(mp_dist) <= pad_to_len would be a little bit more readable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think it should be equal since that just means no padding is added

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right. So we should raise error if pad_to_len is less than or equal to len(mp_len).

@aayush-se aayush-se merged commit bdf389f into main Sep 9, 2024
11 checks passed
@aayush-se aayush-se deleted the anomaly-detection/fix-padding branch September 9, 2024 23:15
aayush-se added a commit that referenced this pull request Sep 13, 2024
- Generated Synthetic timeseries (cyclical, cyclical with anomaly,
noisy, noisy with anomaly) to use for unit and integration tests
  - Timeseries generated in`data-analysis` GitHub repo

- Wrote unit tests for the following modules in anomaly_detection:
  - Detectors
    - `anomaly_detectors.py`
    - `mp_config.py`
    - `mp_scorers.py`
    - `mp_utils.py`
    - `normalizers.py`
    - `window_size_selctors.py`
  - Models
    - `converters.py`
    - `timeseries_anomalies.py`
    - `timeseries.py`

Wrote integration tests for the `store` and `detect` endpoints for
batch, stream, and combo pipelines

**NOTE:** Wanted to submit this PR to start getting some feedback as
there are a lot of changes. As of submitting this PR, the following
unit/integration tests do not work and I wanted to get some feedback:
- `test_detect_anomalies_online` in `test_anomaly_detection.py`: Was
unsure how to handle database changes during integration test
- `test_detect` in `test_anomaly_detectors.py`: was running into shape
errors with the matrix profile
- `test_incorrect_padding` in `test_mp_utils.py`: this one is fixed as
of [this PR](#1136) so needs to be
merged into main to reflect changes

---------

Co-authored-by: sentry-autofix-experimental[bot] <157164994+sentry-autofix-experimental[bot]@users.noreply.github.com>
Co-authored-by: jenn.muengtaweepongsa <jenn.muengtaweepongsa@sentry.io>
Co-authored-by: Rohan Agarwal <47861399+roaga@users.noreply.github.com>
Co-authored-by: Jenn Mueng <30991498+jennmueng@users.noreply.github.com>
Co-authored-by: Rohan Agarwal <rohan.agarwal@sentry.io>
Co-authored-by: Ram Senthamarai <ram-senth@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants