-
Couldn't load subscription status.
- Fork 2
IN-886 Refactor Carbon app to use new Data Warehouse secret #94
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
Conversation
892743b to
a3e21ae
Compare
Why these changes are being introduced: * Use the JSON formatted secret in Secrets Manager to obtain credentials for the Data Warehouse and remove redundant secrets. How this addresses that need: * Configure the engine with 'CONNECTION_STRING' * Create database connection test and add CLI option to run test * Add Make command to run database connection test * Remove unused 'click.echo' commands * Add error handling when retrieving database versions Side effects of this change: * None Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/IN-886
a3e21ae to
6388c9b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, 2 requested changes!
carbon/db.py
Outdated
| def configure(self, conn: str, **kwargs: Any) -> None: # noqa: ANN401 | ||
| self._engine = self._engine or create_engine(conn, **kwargs) | ||
|
|
||
| def run_connection_test(self) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstrings would be beneficial for clarifying what's happening here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring has been added. ✍🏼
carbon/db.py
Outdated
|
|
||
| def configure(self, conn: str) -> None: | ||
| self._engine = self._engine or create_engine(conn) | ||
| def configure(self, conn: str, **kwargs: Any) -> None: # noqa: ANN401 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's start expanding some of these variable names like conn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the latest commit! The only line of code where I kept conn was in CarbonCopyFTPS.storbinary; the class inherits from FTP_TLS, which uses the conn naming convention.
* Update README * Clean up variable name 'conn' * Add docstring to DatabaseEngine.run_connection_test
| 5. Run any `make` commands for testing the application. | ||
|
|
||
| 2. Run `make dist-dev` to build the container. | ||
| Any tests that involve connecting to the Data Warehouse will need to be run as an ECS task in `stage`, which requires building and publishing the Docker container image to ECR for the `stage` environment. As noted in step 1, the appropriate AWS credentials for the `stage` must be set to run the commands for building and publishing the Docker container image. The `ECR_NAME_STAGE` and `ECR_URL_STAGE` environment variables must also be set; the values correspond to the 'Repository name' and 'URI' indicated on ECR for the container image, respectively. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent description
Why these changes are being introduced: * Simplify management of FTP credentials by storing components in a JSON formatted string How this addresses that need: * Expand connection tests for Data Warehouse and Symplectic Elements FTP server * Update CLI tests * Update README Side effects of this change: * None Relevant ticket(s): * #94
What does this PR do?
Refactor Carbon to use the JSON formatted secret in Secrets Manager to obtain the credentials for the Data Warehouse.
This will make future management of the Data Warehouse password a bit easier, since we will have just one secret in Secrets Manager instead of two.
Helpful background context
Updating Carbon to use Python 3.11 meant replacing
cx-oraclewithoracledb(i.e.,python-oracledb) because as this page reads: cx_Oracle 8.3 has been tested [only] with Python versions 3.6 through 3.10.The Oracle database version used by the Data Warehouse requires "thick" mode when connecting to a database. This page describes how to do that using
sqlalchemy.create_engine()andoracledb.init_oracle_client().I chose the solution to use
sqlalchemy.create_engine()since that is the method currently used by the application, and the latter method would involve more changes that--in my perspective--would better suit a separate ticket/effort to replace allsqlalchemycommands withoracledb.How can a reviewer manually see the effects of these changes?
Review the CloudWatch log generated by running
make database-connection-test-stageIf you'd like to run it
IN-886-use-new-data-warehouse-secret.make install.make lint.make database-connection-test-stage.Includes new or updated dependencies?
NO
Developer
Code Reviewer
(not just this pull request message)