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

[Model Monitoring] Add MySQL support for saving and querying metrics #5641

Merged

Conversation

jond01
Copy link
Member

@jond01 jond01 commented May 27, 2024

Implements ML-6268.

I tested the /metrics endpoint on a system configured to use MySQL in model monitoring, and it works:

Example
[
  {
    "project": "test-app-flow-sql-3",
    "app": "evidently-app-test-v2",
    "type": "result",
    "name": "data_drift_test",
    "full_name": "test-app-flow-sql-3.evidently-app-test-v2.result.data_drift_test"
  },
  {
    "project": "test-app-flow-sql-3",
    "app": "histogram-data-drift",
    "type": "result",
    "name": "general_drift",
    "full_name": "test-app-flow-sql-3.histogram-data-drift.result.general_drift"
  },
  {
    "project": "test-app-flow-sql-3",
    "app": "monitoring-test-v2",
    "type": "result",
    "name": "data_drift_test",
    "full_name": "test-app-flow-sql-3.monitoring-test-v2.result.data_drift_test"
  },
  {
    "project": "test-app-flow-sql-3",
    "app": "monitoring-test-v2",
    "type": "result",
    "name": "model_perf",
    "full_name": "test-app-flow-sql-3.monitoring-test-v2.result.model_perf"
  },
  {
    "project": "test-app-flow-sql-3",
    "app": "histogram-data-drift",
    "type": "metric",
    "name": "hellinger_mean",
    "full_name": "test-app-flow-sql-3.histogram-data-drift.metric.hellinger_mean"
  },
  {
    "project": "test-app-flow-sql-3",
    "app": "histogram-data-drift",
    "type": "metric",
    "name": "kld_mean",
    "full_name": "test-app-flow-sql-3.histogram-data-drift.metric.kld_mean"
  },
  {
    "project": "test-app-flow-sql-3",
    "app": "histogram-data-drift",
    "type": "metric",
    "name": "tvd_mean",
    "full_name": "test-app-flow-sql-3.histogram-data-drift.metric.tvd_mean"
  },
  {
    "project": "test-app-flow-sql-3",
    "app": "mlrun-infra",
    "type": "metric",
    "name": "invocations",
    "full_name": "test-app-flow-sql-3.mlrun-infra.metric.invocations"
  }
]

jond01 added 30 commits May 26, 2024 13:56
Remove the previous dummy test
Use a shared function and substitute the cases
The last analyzed should not be empty
It doesn't work otherwise (I did many tries):
```
NotImplementedError: This backend does not support multiple-table criteria within DELETE
```
This removal unnecessitates the type casting
…-metrics-and-query

# Conflicts:
#	mlrun/model_monitoring/db/stores/sqldb/sql_store.py
…-metrics-and-query

# Conflicts:
#	mlrun/model_monitoring/db/stores/sqldb/sql_store.py
…-query

# Conflicts:
#	mlrun/model_monitoring/db/stores/sqldb/models/__init__.py
#	mlrun/model_monitoring/db/stores/sqldb/sql_store.py
#	tests/model_monitoring/test_stores/test_sql.py
@jond01 jond01 marked this pull request as ready for review May 27, 2024 14:26
@jond01 jond01 changed the title [Model Monitoring] Add MySQL support for saving metrics and in the /metrics endpoint [Model Monitoring] Add MySQL support for saving and querying metrics May 27, 2024
@assaf758 assaf758 requested a review from davesh0812 May 28, 2024 07:00
Copy link
Contributor

@davesh0812 davesh0812 left a comment

Choose a reason for hiding this comment

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

Overall looks good.
I have few comments.

Just saying we will have a lot of BC fun in 1.8.0 :)

mlrun/model_monitoring/db/stores/sqldb/sql_store.py Outdated Show resolved Hide resolved
)

return [
mm_schemas.ModelEndpointMonitoringMetric(
Copy link
Contributor

@davesh0812 davesh0812 May 29, 2024

Choose a reason for hiding this comment

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

I’m not sure if this is the right PR, but yesterday you mentioned that the result kind is being returned to the UI. I don't see it here. I noticed it’s being returned from the TSDB, but it seems more appropriate to return it from the /metrics endpoint since it’s metadata.

Copy link
Member Author

Choose a reason for hiding this comment

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

"kind" isn't designed to be in this response, see section 2-c in the description of ML-6119.

Copy link
Contributor

Choose a reason for hiding this comment

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

The design can be changed. Don't you think it's more accurate the way I mentioned?

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 think that's a valid point. I would also like to send the latest status in case of a result, to indicate which results should be inspected.
However, we discussed showing the status in the dropdown, and we deferred it (to >=1.8), so I think we shouldn't reopen now the API.

@jond01
Copy link
Member Author

jond01 commented May 29, 2024

Just saying we will have a lot of BC fun in 1.8.0 :)

I believe it might not be that big here 😉
Once we support retention, we may dismiss these metrics/results tables in MySQL/V3IO altogether and instead read from the TSDB.

@assaf758 assaf758 merged commit 47024a4 into mlrun:development May 30, 2024
11 checks passed
@jond01 jond01 deleted the task/add-mysql-support-to-metrics-and-query branch May 30, 2024 10:26
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.

None yet

3 participants