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

refactor(utils): Remove unused download progress handling. #176

Merged
merged 7 commits into from
Feb 12, 2025

Conversation

junhaoliao
Copy link
Member

@junhaoliao junhaoliao commented Feb 7, 2025

Description

  1. Remove download progress handling.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

  1. Ran the application in development mode according to https://docs.yscope.com/yscope-log-viewer/main/dev-guide/building-getting-started.html
  2. Successfully loaded demo file by search parameter filePath=https://yscope.s3.us-east-2.amazonaws.com/sample-logs/yarn-ubuntu-resourcemanager-ip-172-31-17-135.log.1.clp.zst in the application URL.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Enhanced file data loading process for improved performance.

  • Refactor
    • Simplified the interface for file downloading by removing unnecessary progress reporting.
    • Streamlined file data handling processes for a smoother experience when accessing files.
    • Updated method signatures for clarity and improved usability.

Copy link

coderabbitai bot commented Feb 7, 2025

Walkthrough

This update modifies two modules. In the LogFileManager utility, the loadFile function no longer includes a callback in the getUint8ArrayFrom call when processing a string source. In the http utility, the progress reporting mechanism has been removed from the getUint8ArrayFrom function, simplifying its interface by eliminating the ProgressCallback type and related logic. No changes were made to any exported public entities.

Changes

File(s) Change Summary
src/services/LogFileManager/utils.ts Removed the callback from the getUint8ArrayFrom call within the loadFile function when the file source is a string.
src/utils/http.ts Removed the ProgressCallback type and the progressCallback parameter from getUint8ArrayFrom, eliminating inline progress handling logic.

Possibly related PRs

Suggested reviewers

  • davemarco

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f38cf5 and 99c0fd7.

📒 Files selected for processing (2)
  • src/services/LogFileManager/utils.ts (1 hunks)
  • src/utils/http.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/services/LogFileManager/utils.ts
  • src/utils/http.ts

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@junhaoliao junhaoliao requested a review from davemarco February 7, 2025 14:51
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 (2)
src/utils/http.ts (2)

38-54: LGTM! Consider adding parameter type to JSDoc.

The function is well-implemented and handles edge cases appropriately. Consider adding the ProgressCallback type to the @param JSDoc for better documentation.

 /**
  * Normalizes the total size of a download event, and calls the provided onProgress callback with
  * loaded and total sizes.
  *
- * @param onProgress
+ * @param {ProgressCallback} onProgress The progress callback to wrap
  * @return The handler that wraps `onProgress`.
  */

56-73: Update JSDoc to reflect optional parameter.

The changes look good, but the JSDoc should be updated to indicate that onProgress is optional.

 /**
  * Downloads (bypassing any caching) a file as a Uint8Array.
  *
  * @param fileUrl
- * @param [onProgress]
+ * @param {ProgressCallback} [onProgress] Optional callback to track download progress
  * @return The file's content.
  * @throws {Error} if the download fails.
  */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60c476b and 56c6f94.

📒 Files selected for processing (2)
  • src/services/LogFileManager/utils.ts (1 hunks)
  • src/utils/http.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,ts,tsx}`: - Prefer `false ==

**/*.{cpp,hpp,java,js,jsx,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

  • src/utils/http.ts
  • src/services/LogFileManager/utils.ts
🔇 Additional comments (2)
src/utils/http.ts (1)

1-4: LGTM!

The addition of AxiosProgressEvent type import is necessary for the new progress handling functionality.

src/services/LogFileManager/utils.ts (1)

142-142: LGTM!

The removal of the progress callback is appropriate since the function doesn't need to track progress when loading from a string source, and getUint8ArrayFrom now has a default value for onProgress.

loaded,
total,
}: AxiosProgressEvent) => {
if ("undefined" === typeof total || isNaN(total)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Note we also added the isNan(total) check here. The NaN value was discovered through new unit tests (to be reviewed at #177 )

const getUint8ArrayFrom = async (fileUrl: string, progressCallback: ProgressCallback)
const getUint8ArrayFrom = async (
fileUrl: string,
onProgress: ProgressCallback = () => null
Copy link
Member Author

Choose a reason for hiding this comment

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

Note now we provide a default value to onProgress if it's not provided by the caller.

@davemarco
Copy link
Contributor

davemarco commented Feb 10, 2025

I looked briefly at the changes. Does the old code have a purpose? LIke I am happy to approve this change, but perhaps we can just delete this callback feature entirely?

Also what is this PR for, is it related to the unit test you are adding?

Copy link
Contributor

@davemarco davemarco left a comment

Choose a reason for hiding this comment

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

See earlier comment

@junhaoliao
Copy link
Member Author

Does the old code have a purpose? LIke I am happy to approve this change, but perhaps we can just delete this callback feature entirely?

right, the old callback () => null was provided as a placeholder. We should add some progress display in the UI for any downloads from remote locations but we didn't do that in the new log viewer bring up PRs. We should add the UI in a future PR soon.

Also what is this PR for, is it related to the unit test you are adding?

Partially, it includes a bug fix at https://github.com/y-scope/yscope-log-viewer/pull/176/files#r1946668560 . Most importantly, that we are refining the onProgress callback and making it optional will allow us to align the interface of another utility getJsonObjectFrom, which is to be added in #178 .

@junhaoliao junhaoliao requested a review from davemarco February 12, 2025 14:48
@davemarco
Copy link
Contributor

davemarco commented Feb 12, 2025

After looking at the latest change, I now worry that now the logs will clutter the console making debugging more difficult. In addition, after thinking about more about UI feature, it is quite complicated to pass this data to the front-end, so I not sure we will have bandwidth to add this soon. Also the function normalizeTotalSize is a bit confusing. I think it would be better to change it to a utility, that is called in the original callback, instead of using a wrapper to wrap the provided callback.

For these reasons, I still think we should just remove onDownloadProgress from the axios request. I think it will also make reviewing the unit test PR faster.

@junhaoliao junhaoliao requested review from davemarco and removed request for davemarco February 12, 2025 17:27
@junhaoliao junhaoliao changed the title refactor(http-utils): Refactor download progress handling. refactor(http-utils): Remove download progress handling. Feb 12, 2025
Copy link
Contributor

@davemarco davemarco left a comment

Choose a reason for hiding this comment

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

for title refactor(utils): Remove unused download progress handling.

@junhaoliao junhaoliao changed the title refactor(http-utils): Remove download progress handling. refactor(utils): Remove unused download progress handling. Feb 12, 2025
@junhaoliao junhaoliao merged commit 10b7cf5 into y-scope:main Feb 12, 2025
7 checks passed
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