Vitek-Lab / MSstatsBioNet

https://vitek-lab.github.io/MSstatsPPI/
Other
0 stars 0 forks source link

Wrappers for bioentity endpoints and tests #20

Open pnavada opened 3 weeks ago

pnavada commented 3 weeks ago

PR Type

Enhancement, Tests


Description


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
getBioEntityInfoFromIndra.R
Add API wrappers for bioentity information retrieval         

R/getBioEntityInfoFromIndra.R
  • Added API wrapper functions for bioentity information retrieval.
  • Implemented functions to convert between different bioentity
    identifiers.
  • Functions to check gene properties like kinase, phosphatase, and
    transcription factor.
  • +138/-0 
    Tests
    test-getBioEntityInfoFromIndra.R
    Add unit tests for bioentity API wrapper functions             

    tests/testthat/test-getBioEntityInfoFromIndra.R
  • Added unit tests for each API wrapper function.
  • Verified correct conversion and retrieval of bioentity information.
  • Ensured functions correctly identify gene properties.
  • +59/-0   

    ๐Ÿ’ก PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    github-actions[bot] commented 3 weeks ago

    PR Reviewer Guide ๐Ÿ”

    Here are some key observations to aid the review process:

    โฑ๏ธ Estimated effort to review: 3 ๐Ÿ”ต๐Ÿ”ต๐Ÿ”ตโšชโšช
    ๐Ÿงช PR contains tests
    ๐Ÿ”’ No security concerns identified
    โšก Recommended focus areas for review

    Hardcoded URL
    The API URLs are hardcoded to localhost, which might not be suitable for production environments. Consider using environment variables or configuration files to manage these URLs. Error Handling
    There is no error handling for the API requests. It's recommended to add error checking after the POST requests to handle potential failures gracefully.
    github-actions[bot] commented 3 weeks ago

    PR Code Suggestions โœจ

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Best practice
    Implement error handling for API requests to manage failures gracefully ___ **Add error handling for the API request to manage cases where the request fails or
    the API returns an error.** [R/getBioEntityInfoFromIndra.R [15-20]](https://github.com/Vitek-Lab/MSstatsBioNet/pull/20/files#diff-2e1405d9f60b34d63f4b2b1c52b4c20b94efd715ba3349a875add7c663269037R15-R20) ```diff -res <- POST( - apiUrl, - body = requestBody, - add_headers("Content-Type" = "application/json"), - encode = "raw" -) +res <- tryCatch({ + POST( + apiUrl, + body = requestBody, + add_headers("Content-Type" = "application/json"), + encode = "raw" + ) +}, error = function(e) { + message("Error in API request: ", e$message) + NULL +}) ```
    Suggestion importance[1-10]: 9 Why: Adding error handling is crucial for robustness, as it allows the program to handle API request failures gracefully, providing informative messages and preventing crashes.
    9
    Ensure robustness by validating input parameters before use in API requests ___ **Validate the input parameters to ensure they meet expected formats or conditions
    before making API requests.** [R/getBioEntityInfoFromIndra.R [12]](https://github.com/Vitek-Lab/MSstatsBioNet/pull/20/files#diff-2e1405d9f60b34d63f4b2b1c52b4c20b94efd715ba3349a875add7c663269037R12-R12) ```diff +if (!is.list(uniprotMnemonicIds) || length(uniprotMnemonicIds) == 0) { + stop("Invalid input: 'uniprotMnemonicIds' must be a non-empty list.") +} requestBody <- list(uniprot_mnemonic_ids = uniprotMnemonicIds) ```
    Suggestion importance[1-10]: 8 Why: Validating input parameters is a best practice that prevents errors and ensures that the function receives data in the expected format, enhancing the function's reliability.
    8
    Enhancement
    Improve security and flexibility by using environment variables for API URLs ___ **Replace the hardcoded API URL with a configurable option or environment variable to
    enhance flexibility and security.** [R/getBioEntityInfoFromIndra.R [10]](https://github.com/Vitek-Lab/MSstatsBioNet/pull/20/files#diff-2e1405d9f60b34d63f4b2b1c52b4c20b94efd715ba3349a875add7c663269037R10-R10) ```diff -apiUrl <- "http://localhost:5000/api/get_uniprot_ids_from_uniprot_mnemonic_ids" +apiUrl <- Sys.getenv("API_URL") ```
    Suggestion importance[1-10]: 8 Why: Using environment variables for API URLs enhances security and flexibility, allowing for easier configuration changes without modifying the code. This is a significant improvement over hardcoded URLs.
    8
    Performance
    Enhance performance and reduce network load by caching API call results ___ **Consider caching results from API calls to improve performance and reduce
    unnecessary network traffic.** [R/getBioEntityInfoFromIndra.R [21]](https://github.com/Vitek-Lab/MSstatsBioNet/pull/20/files#diff-2e1405d9f60b34d63f4b2b1c52b4c20b94efd715ba3349a875add7c663269037R21-R21) ```diff -res <- content(res) +res <- memoise::memoise(content)(res) ```
    Suggestion importance[1-10]: 6 Why: Caching API call results can improve performance by reducing redundant network requests. However, it may not be necessary for all use cases, depending on the frequency and variability of the data.
    6
    codecov-commenter commented 1 week ago

    Codecov Report

    Attention: Patch coverage is 84.23645% with 32 lines in your changes missing coverage. Please review.

    Project coverage is 85.66%. Comparing base (6f4bff5) to head (123cf61).

    Files with missing lines Patch % Lines
    R/utils_annotateProteinInfoFromIndra.R 77.27% 30 Missing :warning:
    R/utils_onLoad.R 0.00% 2 Missing :warning:
    Additional details and impacted files ```diff @@ Coverage Diff @@ ## devel #20 +/- ## ========================================== - Coverage 88.28% 85.66% -2.62% ========================================== Files 3 6 +3 Lines 111 314 +203 ========================================== + Hits 98 269 +171 - Misses 13 45 +32 ```

    :umbrella: View full report in Codecov by Sentry.
    :loudspeaker: Have feedback on the report? Share it here.

    tonywu1999 commented 1 week ago

    Great work Pruthvi - one more thing to rebase your changes to the devel branch and do a git push origin --force-with-push to this branch.