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

92 fix backend linting errors #111

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

suprajamannava17
Copy link
Collaborator

@suprajamannava17 suprajamannava17 commented Nov 18, 2024

Fixes #92

What was changed?

I worked on resolving linting errors across the project by modifying multiple files and ensuring that the pylint GitHub Action workflow runs successfully. The changes affected the following files:

  • CI/CD Files: pylint.yml, pytest.yml, and README.md.
  • Code Files: config.py, rest/search_orca_data.py, rest/upload_files.py, responses.py, usecases/search_orca_data.py, usecases/upload_files.py, file_search_operations.py, file_upload_operations.py.
  • Test Files: app_test.py.
  • Newly Added File: http_status_mapping.py.

Why was it changed?

The primary issue was that linting errors were detected during the execution of pylint in GitHub Actions, preventing the workflow from passing successfully. Fixing these errors was necessary to maintain code quality, enforce coding standards, and ensure a successful CI/CD pipeline.

How was it changed?

Configuration Updates:

  • Adjusted the pylint.yml and pytest.yml files to properly configure linting workflows.
  • The README.md file was reformatted using Prettier to ensure consistent formatting and improve readability without altering its content.

Code Modifications:

  • Fixed Linting Errors: Addressed issues such as unused imports, incorrect naming conventions, formatting inconsistencies, and other pylint-detected problems in files such as config.py, rest/search_orca_data.py, rest/upload_files.py, and others.
  • Refactored Functions: Made code more modular and readable by refactoring functions in usecases/search_orca_data.py, file_search_operations.py, and rest/search_orca_data.py.
  • New File Addition: Added http_status_mapping.py to centralize and manage HTTP status code mappings, which helped resolve related linting issues and enhance maintainability.

Testing Adjustments:

  • Updated app_test.py to ensure that test cases align with the linted and refactored code.

Final Validation:

  • After making all changes, ran the pylint workflow to confirm that all errors were resolved and the GitHub Action now passes successfully.

Screenshots that show the changes (if applicable):
image
image

@suprajamannava17 suprajamannava17 linked an issue Nov 18, 2024 that may be closed by this pull request
@SiriChandanaGarimella
Copy link
Collaborator

@suprajamannava17 - Great work! I started reviewing the code. Meanwhile, could you please update the PR description with proper details?

Copy link
Collaborator

@SiriChandanaGarimella SiriChandanaGarimella left a comment

Choose a reason for hiding this comment

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

@suprajamannava17 - Great work! The code looks much cleaner now. Thanks for improving it. I have reviewed the code and left some comments. Can you please look into them.

server/README.md Outdated Show resolved Hide resolved
@@ -1,3 +1,5 @@
# pylint: disable=too-few-public-methods
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove the in-file Pylint rule disabling and add a .pylintrc file

Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. Can you please look into the code once? With the current changes, the search term is not being displayed as a Header in the output file.

Expected:
image

Actual:
image

  1. Please add the logic related to the use_total_lines and total_lines parameters. If required, we might have to use them in the future.
  2. Update the method names to be more meaningful and, if possible, add proper error messages as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks great! Can you also update the following:

  1. Update the variable names to be more descriptive like document_content instead of docx_content and document_response instead of docx_response in both /preview and /find-sections
  2. Define the values inside the content-type ('application/vnd.openxmlformats-officedocument.wordprocessingml.document'), mimetype and output filename as constants and update the parameters accordingly
  3. If possible, refactor the response handling in the /preview and /find-sections. Create methods for handling responses and call the methods respectively

# Use ORCALogExtractor for extraction
extractor = ORCALogExtractor(file_path)
document_content = extractor.extract_sections(
search_terms=search_terms, sections=sections, specify_lines=specify_lines
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add the use_total_lines and total_lines, but make them optional parameters with default values.

requirements.txt Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please move the requirements.txt file into the server folder.

@SiriChandanaGarimella
Copy link
Collaborator

@suprajamannava17 - Could you please let me know once the PR is ready for review?

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.

Fix Backend Linting Errors
2 participants