Skip to content

modify functions to allow frontend to pass percentiles #434

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

Merged
merged 14 commits into from
Feb 26, 2025

Conversation

ken-zlai
Copy link
Contributor

@ken-zlai ken-zlai commented Feb 25, 2025

Summary

This PR allows the frontend to specify which percentiles it retrieves from the backend. The percentiles can be passed as a query parameter:

percentiles=p0,p10,p90

If omitted, the default percentiles are used:

percentiles=p5,p50,p95

Example Requests (App must be running)

Default (uses p5,p50,p95)

curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000"

Equivalent Explicit Default

curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000&percentiles=p5,p50,p95"

Custom Percentiles (p0,p10,p90)

curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000&percentiles=p0,p10,p90"

Notes

  • Omitting the percentiles parameter is the same as explicitly setting percentiles=p5,p50,p95.
  • You can test using curl or Postman.
  • We need to let users change these percentiles via checkboxes or another UI control.

Checklist

  • Added Unit Tests
  • Covered by existing CI
  • Integration tested
  • Documentation update

Summary by CodeRabbit

  • New Features

    • Added support for customizable percentile parameters in summary data requests, with a default setting of "p5, p50, p95".
    • Enhanced the ability to retrieve detailed statistical summaries by allowing users to specify percentile values when querying data.
    • Introduced two new optional dependencies for improved functionality.
  • Bug Fixes

    • Adjusted method signatures to ensure compatibility with the new percentile parameters in various components.

Copy link

coderabbitai bot commented Feb 25, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • frontend/package-lock.json is excluded by !**/package-lock.json

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This change introduces support for customizable percentile values across multiple components. A new constant DefaultPercentiles defined as Seq("p5", "p50", "p95") is added. The Thrift struct for join summary requests now includes an optional percentiles field. The frontend API method getColumnSummary has been updated to accept a percentiles parameter. In the backend, the DriftHandler and DriftStore components are modified to derive, pass, and process percentile values with fallback to the new default when necessary.

Changes

File(s) Change Summary
api/src/.../Constants.scala
api/thrift/observability.thrift
Added DefaultPercentiles constant (Seq("p5", "p50", "p95")) and an optional percentiles field in the JoinSummaryRequest struct.
frontend/src/lib/api/api.ts Updated the getColumnSummary method to accept an optional percentiles parameter that defaults to "p5,p50,p95".
hub/src/.../DriftHandler.scala
online/src/.../DriftStore.scala
Modified methods to extract and forward percentile values. Specifically, getColumnSummary in DriftHandler now derives percentiles and passes it to summary methods, and toSeries/getSummarySeries in DriftStore now accept a percentiles parameter with a default value.

Sequence Diagram(s)

sequenceDiagram
    participant FE as Frontend API
    participant DH as DriftHandler
    participant DS as DriftStore
    participant CT as Constants
    FE->>DH: Call getColumnSummary({ ..., percentiles })
    DH->>DH: Extract percentiles (use Default if empty)
    DH->>DS: getSummarySeries(..., percentiles)
    alt Percentiles missing
      DS->>CT: Retrieve DefaultPercentiles
    end
Loading

Possibly related PRs

Suggested reviewers

  • sean-zlai
  • nikhil-zlai

Poem

In the code, new paths we tread,
Default percentiles now widespread.
From API to backend beat,
Percentile values flow so neat.
Code refined and bugs outspread!
🚀 Happy coding!


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ken-zlai ken-zlai requested a review from sean-zlai February 25, 2025 22:23
…frontend

# Conflicts:
#	api/src/main/scala/ai/chronon/api/Constants.scala
Copy link
Contributor

@sean-zlai sean-zlai left a comment

Choose a reason for hiding this comment

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

Looks good, thanks! Ran locally without any issues. See 2 questions/comments.

@sean-zlai
Copy link
Contributor

@ken-zlai I see there is a failing test for testGetSummary(ai.chronon.hub.handlers.DriftHandlerTest)

image

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
hub/src/test/scala/ai/chronon/hub/handlers/DriftHandlerTest.scala (1)

128-151: Consider enhancing test coverage for percentiles functionality.

The test doesn't verify actual percentiles behavior. Add test cases that check:

  1. Default percentiles used when not specified
  2. Custom percentiles correctly passed to the store

This would align with the PR objectives of allowing frontend to pass percentiles.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between f7b9bd2 and b4f1045.

⛔ Files ignored due to path filters (1)
  • frontend/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • hub/src/test/scala/ai/chronon/hub/handlers/DriftHandlerTest.scala (1 hunks)
🔇 Additional comments (2)
hub/src/test/scala/ai/chronon/hub/handlers/DriftHandlerTest.scala (2)

142-143: Mock updated for new method signature.

Mock now properly accommodates the new percentiles parameter in getSummarySeries.


52-62: Ensure mock data aligns with supported percentiles.

createMockSummarySeries creates fixed percentiles [0.1, 0.5, 0.9] but PR supports configurable values. Consider parameterizing this method to test various percentile configurations.

# Conflicts:
#	frontend/package-lock.json
Adds @tailwindcss/oxide-linux-x64-gnu as optional dependency to fix build
failures in GitHub Actions. Required for Tailwind CSS 4.x Oxide engine when
building on Linux environments.
Adds lightningcss-linux-x64-gnu as optional dependency to fix build
failures in GitHub Actions. Required by Tailwind CSS 4.x's LightningCSS
dependency when building on Linux environments.
Temporarily disables npm caching in GitHub Actions to ensure proper
installation of Tailwind CSS 4.x native dependencies. This avoids adding
optional dependencies with security vulnerabilities.
@ken-zlai ken-zlai merged commit 018899e into main Feb 26, 2025
9 checks passed
@ken-zlai ken-zlai deleted the ken/percentiles-from-frontend branch February 26, 2025 16:28
kumar-zlai pushed a commit that referenced this pull request Feb 26, 2025
## Summary
This PR allows the frontend to specify which percentiles it retrieves
from the backend. The percentiles can be passed as a query parameter:

```
percentiles=p0,p10,p90
```
If omitted, the default percentiles are used:  
```
percentiles=p5,p50,p95
```

### Example Requests *(App must be running)*  

#### Default (uses `p5,p50,p95`)  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000"
```

#### Equivalent Explicit Default  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000&percentiles=p5,p50,p95"
```

#### Custom Percentiles (`p0,p10,p90`)  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000&percentiles=p0,p10,p90"
```

### Notes  
- Omitting the `percentiles` parameter is the same as explicitly setting
`percentiles=p5,p50,p95`.
- You can test using `curl` or Postman.  
- We need to let users change these percentiles via checkboxes or
another UI control.

## Checklist
- [ ] Added Unit Tests
- [ ] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added support for customizable percentile parameters in summary data
requests, with a default setting of "p5, p50, p95".
- Enhanced the ability to retrieve detailed statistical summaries by
allowing users to specify percentile values when querying data.
  - Introduced two new optional dependencies for improved functionality.

- **Bug Fixes**
- Adjusted method signatures to ensure compatibility with the new
percentile parameters in various components.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
kumar-zlai pushed a commit that referenced this pull request Apr 25, 2025
## Summary
This PR allows the frontend to specify which percentiles it retrieves
from the backend. The percentiles can be passed as a query parameter:

```
percentiles=p0,p10,p90
```
If omitted, the default percentiles are used:  
```
percentiles=p5,p50,p95
```

### Example Requests *(App must be running)*  

#### Default (uses `p5,p50,p95`)  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000"
```

#### Equivalent Explicit Default  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000&percentiles=p5,p50,p95"
```

#### Custom Percentiles (`p0,p10,p90`)  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000&percentiles=p0,p10,p90"
```

### Notes  
- Omitting the `percentiles` parameter is the same as explicitly setting
`percentiles=p5,p50,p95`.
- You can test using `curl` or Postman.  
- We need to let users change these percentiles via checkboxes or
another UI control.

## Checklist
- [ ] Added Unit Tests
- [ ] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added support for customizable percentile parameters in summary data
requests, with a default setting of "p5, p50, p95".
- Enhanced the ability to retrieve detailed statistical summaries by
allowing users to specify percentile values when querying data.
  - Introduced two new optional dependencies for improved functionality.

- **Bug Fixes**
- Adjusted method signatures to ensure compatibility with the new
percentile parameters in various components.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
kumar-zlai pushed a commit that referenced this pull request Apr 29, 2025
## Summary
This PR allows the frontend to specify which percentiles it retrieves
from the backend. The percentiles can be passed as a query parameter:

```
percentiles=p0,p10,p90
```
If omitted, the default percentiles are used:  
```
percentiles=p5,p50,p95
```

### Example Requests *(App must be running)*  

#### Default (uses `p5,p50,p95`)  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000"
```

#### Equivalent Explicit Default  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000&percentiles=p5,p50,p95"
```

#### Custom Percentiles (`p0,p10,p90`)  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000&percentiles=p0,p10,p90"
```

### Notes  
- Omitting the `percentiles` parameter is the same as explicitly setting
`percentiles=p5,p50,p95`.
- You can test using `curl` or Postman.  
- We need to let users change these percentiles via checkboxes or
another UI control.

## Checklist
- [ ] Added Unit Tests
- [ ] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added support for customizable percentile parameters in summary data
requests, with a default setting of "p5, p50, p95".
- Enhanced the ability to retrieve detailed statistical summaries by
allowing users to specify percentile values when querying data.
  - Introduced two new optional dependencies for improved functionality.

- **Bug Fixes**
- Adjusted method signatures to ensure compatibility with the new
percentile parameters in various components.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
chewy-zlai pushed a commit that referenced this pull request May 15, 2025
## Summary
This PR allows the frontend to specify which percentiles it retrieves
from the backend. The percentiles can be passed as a query parameter:

```
percentiles=p0,p10,p90
```
If omitted, the default percentiles are used:  
```
percentiles=p5,p50,p95
```

### Example Requests *(App must be running)*  

#### Default (uses `p5,p50,p95`)  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000"
```

#### Equivalent Explicit Default  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000&percentiles=p5,p50,p95"
```

#### Custom Percentiles (`p0,p10,p90`)  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000&percentiles=p0,p10,p90"
```

### Notes  
- Omitting the `percentiles` parameter is the same as explicitly setting
`percentiles=p5,p50,p95`.
- You can test using `curl` or Postman.  
- We need to let users change these percentiles via checkboxes or
another UI control.

## Checklist
- [ ] Added Unit Tests
- [ ] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added support for customizable percentile parameters in summary data
requests, with a default setting of "p5, p50, p95".
- Enhanced the ability to retrieve detailed statistical summaries by
allowing users to specify percentile values when querying data.
  - Introduced two new optional dependencies for improved functionality.

- **Bug Fixes**
- Adjusted method signatures to ensure compatibility with the new
percentile parameters in various components.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
chewy-zlai pushed a commit that referenced this pull request May 15, 2025
## Summary
This PR allows the frontend to specify which percentiles it retrieves
from the backend. The percentiles can be passed as a query parameter:

```
percentiles=p0,p10,p90
```
If omitted, the default percentiles are used:  
```
percentiles=p5,p50,p95
```

### Example Requests *(App must be running)*  

#### Default (uses `p5,p50,p95`)  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000"
```

#### Equivalent Explicit Default  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000&percentiles=p5,p50,p95"
```

#### Custom Percentiles (`p0,p10,p90`)  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000&percentiles=p0,p10,p90"
```

### Notes  
- Omitting the `percentiles` parameter is the same as explicitly setting
`percentiles=p5,p50,p95`.
- You can test using `curl` or Postman.  
- We need to let users change these percentiles via checkboxes or
another UI control.

## Checklist
- [ ] Added Unit Tests
- [ ] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added support for customizable percentile parameters in summary data
requests, with a default setting of "p5, p50, p95".
- Enhanced the ability to retrieve detailed statistical summaries by
allowing users to specify percentile values when querying data.
  - Introduced two new optional dependencies for improved functionality.

- **Bug Fixes**
- Adjusted method signatures to ensure compatibility with the new
percentile parameters in various components.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
chewy-zlai pushed a commit that referenced this pull request May 16, 2025
## Summary
This PR allows the frontend to specify which percentiles it retrieves
from the baour clientsend. The percentiles can be passed as a query parameter:

```
percentiles=p0,p10,p90
```
If omitted, the default percentiles are used:  
```
percentiles=p5,p50,p95
```

### Example Requests *(App must be running)*  

#### Default (uses `p5,p50,p95`)  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000"
```

#### Equivalent Explicit Default  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000&percentiles=p5,p50,p95"
```

#### Custom Percentiles (`p0,p10,p90`)  
```sh
curl "http://localhost:5173/api/v1/join/risk.user_transactions.txn_join/column/txn_by_user_transaction_amount_count_1h/summary?startTs=1672531200000&endTs=1677628800000&percentiles=p0,p10,p90"
```

### Notes  
- Omitting the `percentiles` parameter is the same as explicitly setting
`percentiles=p5,p50,p95`.
- You can test using `curl` or Postman.  
- We need to let users change these percentiles via cheour clientsboxes or
another UI control.

## Cheour clientslist
- [ ] Added Unit Tests
- [ ] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added support for customizable percentile parameters in summary data
requests, with a default setting of "p5, p50, p95".
- Enhanced the ability to retrieve detailed statistical summaries by
allowing users to specify percentile values when querying data.
  - Introduced two new optional dependencies for improved functionality.

- **Bug Fixes**
- Adjusted method signatures to ensure compatibility with the new
percentile parameters in various components.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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