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

chore: bump dependencies #226

Merged
merged 2 commits into from
Nov 20, 2024
Merged

chore: bump dependencies #226

merged 2 commits into from
Nov 20, 2024

Conversation

holtgrewe
Copy link
Collaborator

@holtgrewe holtgrewe commented Nov 20, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced API responses now return data in JSON format for better clarity and structured output.
    • Improved handling of query parameters for gene and disease searches, ensuring more accurate results.
    • Updated OpenAPI specification to version 3.1.0, allowing for nullable types in parameters.
  • Bug Fixes

    • Corrected mapping for ScoreCombiner::Bma to ensure accurate functionality.
  • Refactor

    • Simplified logging level checks for improved readability.
    • Reordered derive attributes in several structs for consistency and clarity.
  • Documentation

    • Updated comments to clarify the purpose and parameters of functions, enhancing overall code documentation.

Copy link

coderabbitai bot commented Nov 20, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces multiple updates across several files, primarily focusing on dependency version upgrades in Cargo.toml, modifications to function signatures and return types in various server-related modules, and refinements in enum display attributes and struct definitions. Changes include enhancements to query handling, error management, and the overall clarity of the codebase, while maintaining existing functionalities. Notably, the response types in several HTTP handler functions have shifted to JSON formats, aligning with RESTful practices.

Changes

File Change Summary
Cargo.toml Updated dependency versions: derive_more (0.99 to 1.0 with full feature), env_logger (0.10 to 0.11), hpo (0.8 to 0.11), tantivy (0.21.1 to 0.22), tempdir (0.3.7 to 0.3), utoipa-swagger-ui (7.1.0 to 8.0), utoipa (4.2 to 5.2).
src/algos/phenomizer.rs Updated import statement for annotations module; changed expected score in phenomizer_score_gene test from 1.757_194 to 1.756_347.
src/common.rs Simplified display attributes for enums IcBasedOn, SimilarityMethod, and ScoreCombiner; corrected mapping in From implementation for ScoreCombiner::Bma.
src/convert/mod.rs Simplified logging level check in run function from match statement to if let statement.
src/index.rs Changed doc variable type in write_hpo_index from tantivy::Document to tantivy::TantivyDocument.
src/query/mod.rs Reordered derive attributes in structs Gene, Query, Result, ResultEntry, and TermDetails; simplified logging level check in run function.
src/server/run/hpo_genes.rs Updated handle function return type to actix_web::Result<Json<Result>, CustomError>; refined logic for processing query parameters.
src/server/run/hpo_omims.rs Updated handle function return type to actix_web::Result<Json<Result>, CustomError>; added new alias for Disease in Query struct; refined omim_id processing logic.
src/server/run/hpo_sim/term_gene.rs Updated handle function return type to actix_web::Result<Json<query_result::Result>, CustomError>; altered response schema in utoipa::path macro.
src/server/run/hpo_sim/term_term.rs Updated handle function return type to actix_web::Result<Json<Result>, CustomError>; utilized web::Query<RequestQuery> for query parameters.
src/server/run/hpo_terms.rs Changed doc parameter type in from_term_with_ontology from Option<&tantivy::Document> to Option<&tantivy::TantivyDocument>; updated handle function return type to actix_web::Result<Json<Result_>, CustomError>; modified response body schema.
src/server/run/mod.rs Simplified logging level check in run function from match statement to if let statement.
openapi.yaml Updated from OpenAPI version 3.0.3 to 3.1.0; modified parameter schemas to allow nullable types; renamed Result schema to Result_; added new Gene schema and updated existing schemas for clarity and type safety.

Possibly related PRs

  • chore: bump dependencies #226: The changes in this PR involve updates to the Cargo.toml file, specifically the same dependencies and their versions as in the main PR, indicating a direct relationship in dependency management.

Poem

In the code where rabbits play,
Dependencies hop and sway.
With JSON now, our queries gleam,
Clarity reigns, a coder's dream.
Bugs are chased, and errors flee,
Hooray for changes, let’s code with glee! 🐇✨


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 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.

@holtgrewe holtgrewe changed the title chore: bump dependency chore: bump dependencies Nov 20, 2024
Copy link

codecov bot commented Nov 20, 2024

Codecov Report

Attention: Patch coverage is 30.00000% with 14 lines in your changes missing coverage. Please review.

Project coverage is 68.60%. Comparing base (32f478e) to head (a8e3e3a).
Report is 39 commits behind head on main.

Files with missing lines Patch % Lines
src/convert/mod.rs 0.00% 3 Missing ⚠️
src/query/mod.rs 0.00% 3 Missing ⚠️
src/server/run/hpo_terms.rs 57.14% 3 Missing ⚠️
src/server/run/mod.rs 0.00% 3 Missing ⚠️
src/common.rs 0.00% 1 Missing ⚠️
src/server/run/hpo_sim/term_gene.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #226      +/-   ##
==========================================
- Coverage   68.92%   68.60%   -0.33%     
==========================================
  Files          13       13              
  Lines         943      946       +3     
==========================================
- Hits          650      649       -1     
- Misses        293      297       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

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: 3

🧹 Outside diff range and nitpick comments (4)
src/algos/phenomizer.rs (1)

50-54: Consider being more explicit with Disease trait import

The wildcard import Disease as _ is typically discouraged as it can make the code less maintainable. Consider being explicit about which trait methods are needed.

src/index.rs (1)

101-101: Consider pinning to a specific tantivy version range

Given that this is a critical indexing component handling medical ontology data, consider using a specific version range in your dependency specification (e.g., tantivy = "~0.x.y") to prevent unexpected breaking changes in patch updates.

src/server/run/hpo_sim/term_term.rs (2)

Line range hint 171-171: Remove debug print statement.

The dbg!(&result) statement appears to be a development artifact. Consider removing it before deploying to production to avoid unnecessary logging and potential performance impact.

-    dbg!(&result);

Line range hint 122-139: Consider enhancing error handling.

The current implementation has several areas where error handling could be improved:

  1. Invalid HPO terms are silently filtered out
  2. The sorting operation uses expect() which could panic
  3. No validation ensures non-empty input vectors

Consider:

  • Returning an error if no valid terms are found
  • Using proper error handling for sorting
  • Validating input vectors are non-empty

Example improvement:

// Validate and convert terms with proper error handling
let lhs = query
    .lhs
    .iter()
    .map(|lhs| {
        ontology
            .hpo(HpoTermId::from(lhs.clone()))
            .ok_or_else(|| CustomError::InvalidInput(format!("Invalid HPO term: {}", lhs)))
    })
    .collect::<Result<Vec<_>, _>>()?;

if lhs.is_empty() || rhs.is_empty() {
    return Err(CustomError::InvalidInput("Empty term sets provided".into()));
}

// Use proper error handling for sorting
result.sort_by(|lhs, rhs| {
    rhs.score
        .partial_cmp(&lhs.score)
        .ok_or_else(|| CustomError::Internal("Failed to compare scores".into()))
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f7b07f6 and d10d344.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (12)
  • Cargo.toml (2 hunks)
  • src/algos/phenomizer.rs (2 hunks)
  • src/common.rs (4 hunks)
  • src/convert/mod.rs (1 hunks)
  • src/index.rs (1 hunks)
  • src/query/mod.rs (6 hunks)
  • src/server/run/hpo_genes.rs (1 hunks)
  • src/server/run/hpo_omims.rs (2 hunks)
  • src/server/run/hpo_sim/term_gene.rs (2 hunks)
  • src/server/run/hpo_sim/term_term.rs (1 hunks)
  • src/server/run/hpo_terms.rs (6 hunks)
  • src/server/run/mod.rs (1 hunks)
🔇 Additional comments (20)
Cargo.toml (2)

18-18: Consider compile time impact of "full" feature

The addition of the "full" feature to derive_more could increase compile times. Consider using only the specific features needed instead of the full feature set if possible.


23-23: Verify compatibility with major version upgrades

Several dependencies have undergone major version updates which could introduce breaking changes:

  • hpo: 0.8 -> 0.11 (3 major versions)
  • utoipa-swagger-ui: 7.x -> 8.x
  • utoipa: 4.x -> 5.x

Please ensure:

  1. All breaking changes have been addressed
  2. The application has been thoroughly tested with these new versions
  3. The changelog/release notes for these dependencies have been reviewed

Also applies to: 44-45

src/algos/phenomizer.rs (1)

91-91: Verify the change in expected test value

The test assertion value has changed from 1.757_194 to 1.756_347. Since this PR is about dependency updates, please verify if this change is:

  1. An expected result of the dependency updates
  2. A precision improvement
  3. A potential regression

Consider adding a comment explaining the reason for this specific value to help future maintenance.

src/server/run/hpo_sim/term_gene.rs (3)

14-17: LGTM! Import changes are well-structured.

The imports are properly organized and include the necessary modules for the new JSON response type.


57-57: LGTM! API documentation accurately reflects the response type.

The OpenAPI/Swagger documentation has been properly updated to match the new response type structure.


65-65: LGTM! Return type change improves API consistency.

The modification to return Json<query_result::Result> aligns with RESTful practices and maintains type safety while standardizing the API response format.

src/index.rs (1)

101-101: Type change looks correct but warrants testing verification

The update from tantivy::Document to tantivy::TantivyDocument appears to be part of a breaking change in the tantivy library. The change is implemented correctly, and the rest of the code continues to work with the new type, suggesting API compatibility is maintained.

Please ensure that:

  1. All tests pass with the new dependency version
  2. The search functionality works as expected, particularly the document indexing and retrieval
src/server/run/hpo_sim/term_term.rs (1)

118-118: LGTM! Good improvement to response type clarity.

The change from impl Responder to actix_web::Result<Json<Result>, CustomError> is a positive improvement that:

  • Makes the API contract more explicit
  • Ensures consistent JSON responses
  • Maintains proper error handling
  • Aligns with RESTful API best practices
src/common.rs (4)

69-69: LGTM: Display attribute syntax updated correctly for IcBasedOn enum

The display attribute syntax has been updated from #[display(fmt = "...")] to #[display("...")] consistently for both variants, maintaining the same string values.

Also applies to: 72-72


108-108: LGTM: Display attribute syntax updated correctly for SimilarityMethod enum

The display attribute syntax has been updated consistently across all variants of the SimilarityMethod enum, preserving the original string representations.

Also applies to: 111-111, 114-114, 117-117, 120-120, 123-123, 126-126, 130-130


185-185: LGTM: Display attribute syntax updated correctly for ScoreCombiner enum

The display attribute syntax has been updated consistently for all variants of the ScoreCombiner enum, maintaining the same string values.

Also applies to: 188-188, 191-191


200-200: LGTM: Fixed incorrect mapping in From implementation

The mapping for ScoreCombiner::Bma has been correctly updated to map to StandardCombiner::Bma instead of the previous incorrect StandardCombiner::Bwa.

src/query/mod.rs (2)

55-63: LGTM! Clean reordering of derive attributes

The reordering of derive attributes improves code organization by grouping similar traits together. This is a good practice in Rust and aligns with the dependency update objectives.


269-271: LGTM! Improved logging level check

The simplified pattern matching for log levels is more idiomatic Rust code and improves readability while maintaining the same functionality.

src/server/run/hpo_genes.rs (1)

145-145: LGTM: Return type standardization aligns with RESTful practices

The change from impl Responder to Json<Result> is a good improvement that makes the API response type more explicit and consistent with RESTful practices.

src/server/run/hpo_omims.rs (1)

180-180: LGTM! Return type change improves API contract clarity.

The change from impl Responder to Json<Result> makes the API contract more explicit and aligns with RESTful best practices. This change is consistent with similar modifications across other endpoints, improving the overall API consistency.

src/server/run/hpo_terms.rs (4)

10-10: LGTM: Import needed for tantivy 0.22 compatibility

The explicit import of the Value trait is required for the tantivy 0.22 upgrade to support the as_value() method calls.


108-108: LGTM: Correct tantivy 0.22 API usage

The changes properly adapt to tantivy 0.22's API:

  • Updated document type from Document to TantivyDocument
  • Updated value access patterns using as_value()

Also applies to: 150-150, 155-155, 164-164


218-218: LGTM: Consistent JSON response type

The changes properly standardize the API response to use JSON format, which:

  • Improves API consistency
  • Follows RESTful best practices

Also applies to: 226-226


329-340: LGTM: Proper tantivy 0.22 document retrieval

The changes correctly implement tantivy 0.22's document retrieval:

  • Uses explicit TantivyDocument type
  • Maintains comprehensive error handling
  • Properly accesses document values

tantivy = "0.21.1"
tempdir = "0.3.7"
tantivy = "0.22"
tempdir = "0.3"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Verify tempdir version change

The tempdir version change from 0.3.7 to 0.3 appears to be a downgrade. Please verify if this is intentional or if it should be 0.3.x where x ≥ 7.

Comment on lines +32 to +34
if let Some(log::Level::Trace | log::Level::Debug) = args_common.verbose.log_level() {
std::env::set_var("RUST_LOG", "debug");
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider revising the logging configuration approach

The current implementation has potential issues:

  1. There's a conflict between setting RUST_LOG=debug and using "info" as the default filter
  2. Setting environment variables at runtime could lead to race conditions in concurrent contexts

Consider this more idiomatic approach:

-    if let Some(log::Level::Trace | log::Level::Debug) = args_common.verbose.log_level() {
-        std::env::set_var("RUST_LOG", "debug");
-        env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
+    if let Some(level) = args_common.verbose.log_level() {
+        env_logger::Builder::new()
+            .filter_level(level.to_level_filter())
+            .init();

This approach:

  • Directly uses the log level from args without environment variables
  • Maintains consistency between the requested and applied log levels
  • Is more thread-safe
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if let Some(log::Level::Trace | log::Level::Debug) = args_common.verbose.log_level() {
std::env::set_var("RUST_LOG", "debug");
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
if let Some(level) = args_common.verbose.log_level() {
env_logger::Builder::new()
.filter_level(level.to_level_filter())
.init();

Comment on lines +248 to +250
if let Some(log::Level::Trace | log::Level::Debug) = args_common.verbose.log_level() {
std::env::set_var("RUST_LOG", "debug");
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider adjusting log level consistency

The pattern matching improvement is good, but there are potential issues with log level consistency:

  1. When verbosity is set to Trace, RUST_LOG is set to "debug" which might be too restrictive
  2. The default filter of "info" in default_filter_or("info") might override the "debug" setting

Consider this adjustment to maintain log level consistency:

-    if let Some(log::Level::Trace | log::Level::Debug) = args_common.verbose.log_level() {
-        std::env::set_var("RUST_LOG", "debug");
-        env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
+    if let Some(level) = args_common.verbose.log_level() {
+        match level {
+            log::Level::Trace => std::env::set_var("RUST_LOG", "trace"),
+            log::Level::Debug => std::env::set_var("RUST_LOG", "debug"),
+            _ => {}
+        }
+        env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if let Some(log::Level::Trace | log::Level::Debug) = args_common.verbose.log_level() {
std::env::set_var("RUST_LOG", "debug");
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
if let Some(level) = args_common.verbose.log_level() {
match level {
log::Level::Trace => std::env::set_var("RUST_LOG", "trace"),
log::Level::Debug => std::env::set_var("RUST_LOG", "debug"),
_ => {}
}
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));

@holtgrewe holtgrewe merged commit a6b46ff into main Nov 20, 2024
5 of 6 checks passed
@holtgrewe holtgrewe deleted the chore-bump-deps branch November 20, 2024 12:25
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.

1 participant