Skip to content

IN-928 Restructure the config module to use a 'Config' class #121

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 2 commits into from
Oct 3, 2023

Conversation

jonavellecuerdo
Copy link
Contributor

@jonavellecuerdo jonavellecuerdo commented Oct 2, 2023

What does this PR do?

Refactor config module to use a Config class to improve code readability and flow.
The CLI main() method was also updated to exit cleanly in the event of failed
connection tests.

Helpful background context

  • Updating the CLI main() method

    • During testing, it was discovered that the Traceback was printing twice in the CloudWatch logs.
    • In order to address this issue, the following updates were made:
      • Wrap each connection test in a try-except block;
      • Moving the wrapped code into a function in carbon.app.run_all_connection_tests() to keep cli.py
        organized.
      • I debugged a couple of errors with @ghukill and he suggested that "logging.exception [may] not [be] needed for an understood exception like oracledb.exceptions.DatabaseError: ORA-12170: TNS:Connect timeout occurred" and posted that logging.error is sufficient for such cases (this requires ignoring Ruff rule TRY400).
    • I originally tried to store this method in carbon.app.helpers, but it wasn't possible due to a circular import.
  • Added a .dockerignore file.

    • Copied the .dockerignore file from the Python CLI template repo!

How can a reviewer manually see the effects of these changes?

Review the following CloudWatch logs in Stage-Workloads.

  1. Log showing clean exit from carbon.app.run_all_connection_tests and simplified error log for failed Data Warehouse connection test.
    image

  2. Log showing clean exit from carbon.app.run_all_connection_tests and simplified error log for failed Elements FTP connection test.
    image

  3. Log showing clean exit from carbon.app.run_all_connection_tests where all connection tests were successful.
    image

  4. Log showing successful Carbon run for HR Feed using carbon.config.Config
    image

  5. Log showing successful Carbon run for Articles Feed using carbon.config.Config
    image

  6. Screenshot showing XML files on Elements FTP server.
    image

Includes new or updated dependencies?

NO

Developer

  • README is updated to reflect all changes as needed
  • All related Jira tickets are linked in commit message(s)

Code Reviewer

  • The commit message is clear and follows our guidelines
    (not just this pull request message)
  • There are appropriate tests covering any new functionality
  • The documentation has been updated to reflect all changes or is not needed
  • The changes have been verified
  • New dependencies are appropriate or there were no changes

@jonavellecuerdo jonavellecuerdo self-assigned this Oct 2, 2023
Why these changes are being introduced:
* Refactor configuration process and improve code readability

How this addresses that need:
* Create Config class
* Update dependent modules to use Config
* Update unit tests
* Simplify error logging for failed connection tests
* Add .dockerignore file

Side effects of this change:
* None

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/IN-928
@jonavellecuerdo jonavellecuerdo force-pushed the IN-928-create-config-class branch from 8104917 to 70cb9c3 Compare October 2, 2023 20:44
@jonavellecuerdo jonavellecuerdo marked this pull request as ready for review October 2, 2023 20:46
@jonavellecuerdo
Copy link
Contributor Author

@ghukill @ehanson8 I just added the screenshot showing the successful upload of XML files to the Elements FTP server to
the PR description.

Copy link
Contributor

@ghukill ghukill left a comment

Choose a reason for hiding this comment

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

I think it looks good! Nice work.

All my comments are questions / suggestions, so not formally requesting any changes and consider it approved. If you decide to implement any of these changes happy to re-review, but if you'd prefer to skip, okay with that too!

Copy link
Contributor

@ehanson8 ehanson8 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, a few questions. And I would recommend making the changes Graham suggested to streamline it. Great work!

@jonavellecuerdo jonavellecuerdo force-pushed the IN-928-create-config-class branch from db1e48a to b88fbc4 Compare October 3, 2023 16:55
@jonavellecuerdo jonavellecuerdo merged commit 9fd0a56 into main Oct 3, 2023
@jonavellecuerdo jonavellecuerdo deleted the IN-928-create-config-class branch October 3, 2023 18:11
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.

3 participants