isabelrem / 2023-Software-Development-Assessment

MIT License
2 stars 1 forks source link

61 alternative setup script for local non dockerised sql database #62

Closed isabelrem closed 8 months ago

jess789550 commented 8 months ago

Manual version works - will test Docker tomorrow

jess789550 commented 8 months ago

./setup.sh

Welcome to PanelSearch! If you would like to setup the app with a Docker container SQL database, please enter '1'. If you would like to setup the app with a cloud SQL database, please enter '2'. 2 [+] Building 3.1s (13/13) FINISHED docker:desktop-linux => [internal] load .dockerignore 0.0s => => transferring context: 680B 0.0s => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 2.09kB 0.0s => resolve image config for docker.io/docker/dockerfile:1 1.6s => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:ac85f380a63b13dfcefa89046420e1781752bab202122f8f50032edf31be0021 0.0s => [internal] load metadata for docker.io/library/python:3.10-slim 1.2s => [stage-1 1/6] FROM docker.io/library/python:3.10-slim@sha256:646f0a074d101fae8a85c8889f9458d2fb52763b47f12ac654c8dcb2ee6e43f4 0.0s => => resolve docker.io/library/python:3.10-slim@sha256:646f0a074d101fae8a85c8889f9458d2fb52763b47f12ac654c8dcb2ee6e43f4 0.0s => [internal] load build context 0.0s => => transferring context: 4.25kB 0.0s => CACHED [stage-1 2/6] WORKDIR /app 0.0s => CACHED [stage-1 3/6] RUN adduser --disabled-password --gecos "" --home "/nonexistent" --shell "/sbin/nologin" 0.0s => CACHED [stage-1 4/6] RUN chown appuser:appuser -R /app 0.0s => CACHED [stage-1 5/6] RUN --mount=type=cache,target=/root/.cache/pip --mount=type=bind,source=requirements.txt,target=requirem 0.0s => CACHED [stage-1 6/6] COPY . . 0.0s => exporting to image 0.0s => => exporting layers 0.0s => => writing image sha256:f6951a58e81c81059cccb2f04e2f7fd5d118a5696d59cefce4ecc2336f6b1fe2 0.0s => => naming to docker.io/library/panelsearch 0.0s panelsearch app container created running panelsearch app... Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/pymysql/connections.py", line 644, in connect sock = socket.create_connection( File "/usr/local/lib/python3.10/socket.py", line 845, in create_connection raise err File "/usr/local/lib/python3.10/socket.py", line 833, in create_connection sock.connect(sa) TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 145, in init self._dbapi_connection = engine.raw_connection() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3292, in raw_connection return self.pool.connect() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 452, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 1269, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 716, in checkout rec = pool._do_get() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 169, in _do_get with util.safe_reraise(): File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 146, in exit raise exc_value.with_traceback(exc_tb) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 167, in _do_get return self._create_connection() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 393, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 678, in init self.connect() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 902, in connect with util.safe_reraise(): File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 146, in exit raise exc_value.with_traceback(exc_tb) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 898, in connect self.dbapi_connection = connection = pool._invoke_creator(self) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 637, in connect return dialect.connect(*cargs, *cparams) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 616, in connect return self.loaded_dbapi.connect(cargs, **cparams) File "/usr/local/lib/python3.10/site-packages/pymysql/connections.py", line 358, in init__ self.connect() File "/usr/local/lib/python3.10/site-packages/pymysql/connections.py", line 711, in connect raise exc pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '35.197.209.133' (timed out)")

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/app/./PanelSearch/main.py", line 21, in from API_to_SQL_cloud import PK_Parse_Data_to_SQL_cloud File "/app/PanelSearch/API_to_SQL_cloud.py", line 3, in from SQL_Cloud_Functions import connect_cloud_db, add_new_cloud_record File "/app/PanelSearch/SQL_Cloud_Functions.py", line 46, in connection_string = docker_or_cloud() File "/app/PanelSearch/SQL_Cloud_Functions.py", line 39, in docker_or_cloud conn = engine.connect() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3268, in connect return self._connection_cls(self) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 147, in init Connection._handle_dbapi_exception_noconnection( File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2430, in _handle_dbapi_exception_noconnection raise sqlalchemy_exception.with_traceback(exc_info[2]) from e File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 145, in init self._dbapi_connection = engine.raw_connection() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3292, in raw_connection return self.pool.connect() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 452, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 1269, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 716, in checkout rec = pool._do_get() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 169, in _do_get with util.safe_reraise(): File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 146, in exit raise exc_value.with_traceback(exc_tb) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 167, in _do_get return self._create_connection() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 393, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 678, in init self.connect() File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 902, in connect with util.safe_reraise(): File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 146, in exit raise exc_value.with_traceback(exc_tb) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 898, in connect self.dbapi_connection = connection = pool._invoke_creator(self) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 637, in connect return dialect.connect(*cargs, *cparams) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 616, in connect return self.loaded_dbapi.connect(cargs, **cparams) File "/usr/local/lib/python3.10/site-packages/pymysql/connections.py", line 358, in init__ self.connect() File "/usr/local/lib/python3.10/site-packages/pymysql/connections.py", line 711, in connect raise exc sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on '35.197.209.133' (timed out)") (Background on this error at: https://sqlalche.me/e/20/e3q8)

jess789550 commented 8 months ago

./setup.sh

Welcome to PanelSearch! If you would like to setup the app with a Docker container SQL database, please enter '1'. If you would like to setup the app with a cloud SQL database, please enter '2'. 1 Proceeding with docker set up... Checking for docker.io: No docker.io. Setting up docker.io. Reading package lists... Done Building dependency tree... Done Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:

The following packages have unmet dependencies. containerd.io : Conflicts: containerd E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages. Checking for docker-buildx: No docker-buildx. Setting up docker-buildx. Reading package lists... Done Building dependency tree... Done Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:

The following packages have unmet dependencies. containerd.io : Conflicts: containerd docker-ce : Conflicts: docker.io but 24.0.5-0ubuntu1~22.04.1 is to be installed docker-ce-cli : Conflicts: docker.io but 24.0.5-0ubuntu1~22.04.1 is to be installed E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages. Docker running Checking for mysql-server: install ok installed Error response from daemon: network with name panelsearch-network already exists panelsearch-network created panelsearch-volume panelsearch-volume created Unable to find image 'mysql:8' locally 8: Pulling from library/mysql bce031bc522d: Pull complete cf7e9f463619: Pull complete 105f403783c7: Pull complete 878e53a613d8: Pull complete 2a362044e79f: Pull complete 6e4df4f73cfe: Pull complete 69263d634755: Pull complete fe5e85549202: Pull complete 5c02229ce6f1: Pull complete 7320aa32bf42: Pull complete Digest: sha256:4ef30b2c11a3366d7bb9ad95c70c0782ae435df52d046553ed931621ea36ffa5 Status: Downloaded newer image for mysql:8 0fcb00931047f0a9e9d0367c0e59f77d94937f6e036e0eb1590051a29c0b88de panelsearch-database container created mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Attempt 1 failed. Trying again... mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Attempt 2 failed. Trying again... mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) Attempt 3 failed. Trying again... mysql: [Warning] Using a password on the command line interface can be insecure. The command was successful after 4 attempts. panelsearch database created database tables 'searches' and 'patients' created permissions enabled [+] Building 1.9s (15/15) FINISHED docker:desktop-linux => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 2.22kB 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 680B 0.0s => resolve image config for docker.io/docker/dockerfile:1 0.8s => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:ac85f380a63b13dfcefa89046420e1781752bab202122f8f50032edf31be0021 0.0s => [internal] load metadata for docker.io/library/python:3.10-slim 0.8s => [stage-1 1/8] FROM docker.io/library/python:3.10-slim@sha256:e91e79e5af602e7dbe9200e71c8e39006aa60621b547b26f75e9bddc9f7b07c9 0.0s => [internal] load build context 0.0s => => transferring context: 4.25kB 0.0s => CACHED [stage-1 2/8] WORKDIR /app 0.0s => CACHED [stage-1 3/8] RUN adduser --disabled-password --gecos "" --home "/nonexistent" --shell "/sbin/nologin" 0.0s => CACHED [stage-1 4/8] RUN chown appuser:appuser -R /app 0.0s => CACHED [stage-1 5/8] RUN chmod 777 -R /app 0.0s => CACHED [stage-1 6/8] RUN --mount=type=cache,target=/root/.cache/pip --mount=type=bind,source=requirements.txt,target=requirem 0.0s => CACHED [stage-1 7/8] COPY . . 0.0s => CACHED [stage-1 8/8] WORKDIR ./PanelSearch 0.0s => exporting to image 0.0s => => exporting layers 0.0s => => writing image sha256:3bfe7b2939f277ed3873f1c7210c4e046dfc8a3fa66ff99a18612f2cf167bb86 0.0s => => naming to docker.io/library/panelsearch 0.0s panelsearch app container created running panelsearch app... successful connection to docker database If you would like to search by R-code, enter 1. If you would like to enter a disease description, enter 2. 1 Enter your search term: (e.g., R128 or pneumothorax) R128 Which genome build would you like to use? Enter 1 for GRCh37. Enter 2 for GRCh38. 1 GRch37 build selected. Panel ID: 13 Panel Name: Brugada syndrome and cardiac sodium channel disease GMS Sign-off Status: Signed Off Associated NGTD R-codes: R128 Gene Number: 23 Gene List: HGNC_ID Symbol Coords Mane_Select_Transcript HGNC:10593 SCN5A 3:38589548-38691164 NM_000335.5 HGNC:6251 KCNH2 7:150642049-150675403 NM_000238.4 HGNC:60 ABCC9 12:21950335-22094336 NM_020297.4 HGNC:493 ANK2 4:113739265-114304896 NM_001148.6 HGNC:1390 CACNA1C 12:2079952-2802108 NM_000719.7 HGNC:1399 CACNA2D1 7:81575760-82073114 NM_000722.4 HGNC:1402 CACNB2 10:18429606-18830798 NM_201596.3 HGNC:1529 CAV3 3:8775486-8883492 NM_033337.3 HGNC:2900 DLG1 3:196769431-197026171 NM_001366207.1 HGNC:28956 GPD1L 3:32147181-32210205 NM_015141.4 HGNC:16882 HCN4 15:73612200-73661605 NM_005477.3 HGNC:6239 KCND3 1:112313284-112531777 NM_001378969.1 HGNC:6243 KCNE3 11:74165886-74178774 NM_005472.5 HGNC:6241 KCNE5 X:108866929-108868393 NM_012282.4 HGNC:6269 KCNJ8 12:21917889-21928515 NM_004982.4 HGNC:9024 PKP2 12:32943679-33049774 NM_001005242.3 HGNC:17679 RANGRF 17:8191815-8193410 NM_016492.5 HGNC:10582 SCN10A 3:38738293-38835501 NM_006514.4 HGNC:10586 SCN1B 19:35521588-35531352 NM_001037.5 HGNC:10589 SCN2B 11:118032666-118047388 NM_004588.5 HGNC:20665 SCN3B 11:123499895-123525952 NM_001040151.2 HGNC:16643 SLMAP 3:57741177-57914895 NM_001377540.1 HGNC:17993 TRPM4 19:49660998-49715093 NM_017636.4 Generate BED file? (Y/N) Y Traceback (most recent call last): File "/app/PanelSearch/generate_bed.py", line 20, in RotatingFileHandler(log_file, maxBytes=10000, backupCount=1) File "/usr/local/lib/python3.10/logging/handlers.py", line 155, in init BaseRotatingHandler.init(self, filename, mode, encoding=encoding, File "/usr/local/lib/python3.10/logging/handlers.py", line 58, in init logging.FileHandler.init(self, filename, mode=mode, File "/usr/local/lib/python3.10/logging/init.py", line 1169, in init StreamHandler.init(self, self._open()) File "/usr/local/lib/python3.10/logging/init.py", line 1201, in _open return open_func(self.baseFilename, self.mode, PermissionError: [Errno 13] Permission denied: '/app/PanelSearch/generate_bed.log' Would you like to save this search against a patient ID? (Y/N) Y What patient ID would you like to save this search against? hester Brugada syndrome and cardiac sodium channel disease GRch37 GRch37 build selected. Panel ID: 13 Panel Name: Brugada syndrome and cardiac sodium channel disease GMS Sign-off Status: Signed Off Associated NGTD R-codes: R128 Gene Number: 23 Gene List: HGNC_ID Symbol Coords Mane_Select_Transcript HGNC:10593 SCN5A 3:38589548-38691164 NM_000335.5 HGNC:6251 KCNH2 7:150642049-150675403 NM_000238.4 HGNC:60 ABCC9 12:21950335-22094336 NM_020297.4 HGNC:493 ANK2 4:113739265-114304896 NM_001148.6 HGNC:1390 CACNA1C 12:2079952-2802108 NM_000719.7 HGNC:1399 CACNA2D1 7:81575760-82073114 NM_000722.4 HGNC:1402 CACNB2 10:18429606-18830798 NM_201596.3 HGNC:1529 CAV3 3:8775486-8883492 NM_033337.3 HGNC:2900 DLG1 3:196769431-197026171 NM_001366207.1 HGNC:28956 GPD1L 3:32147181-32210205 NM_015141.4 HGNC:16882 HCN4 15:73612200-73661605 NM_005477.3 HGNC:6239 KCND3 1:112313284-112531777 NM_001378969.1 HGNC:6243 KCNE3 11:74165886-74178774 NM_005472.5 HGNC:6241 KCNE5 X:108866929-108868393 NM_012282.4 HGNC:6269 KCNJ8 12:21917889-21928515 NM_004982.4 HGNC:9024 PKP2 12:32943679-33049774 NM_001005242.3 HGNC:17679 RANGRF 17:8191815-8193410 NM_016492.5 HGNC:10582 SCN10A 3:38738293-38835501 NM_006514.4 HGNC:10586 SCN1B 19:35521588-35531352 NM_001037.5 HGNC:10589 SCN2B 11:118032666-118047388 NM_004588.5 HGNC:20665 SCN3B 11:123499895-123525952 NM_001040151.2 HGNC:16643 SLMAP 3:57741177-57914895 NM_001377540.1 HGNC:17993 TRPM4 19:49660998-49715093 NM_017636.4 1 Your search was saved Thank you for using PanelSearch. Goodbye.

jess789550 commented 8 months ago

Error with option 1 is now fixed thank you