Skip to content

Commit 085e075

Browse files
cofinShane Bordenwpuziewicz
authored
v3.0.4 (#186)
* script refactoring * python refactoring and cleanup (phase 1) * added flask app to debug config * remove typing extensions since 3.7 support isn't needed * added file read to remote endpoint. Co-authored-by: Shane Borden <[email protected]> Co-authored-by: Warren Puziewicz <[email protected]> Co-authored-by: warren puziewicz <[email protected]>
1 parent 6986741 commit 085e075

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+16774
-5406
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ ENV/
112112
env.bak/
113113
venv.bak/
114114
.venv
115+
service_account.json
115116

116117
# Spyder project settings
117118
.spyderproject
@@ -131,17 +132,25 @@ dmypy.json
131132
# Pyre type checker
132133
.pyre/
133134

135+
# osx
136+
.ds_store
137+
134138
# vscode
135139
# .vscode
136140

137141
# App specifics
138142
invoke.yml
139143
sample/datacollection/*/*.log
144+
sample/datacollection/*/*.csv
140145
sample/datacollection/*.log
146+
sample/datacollection/*.csv
141147
!sample/datacollection/*.tar.gz
142148
.env
143149
op-venv
144150
*.log
145151
log/*
146152
op_output
147153
db_assessment/op_etl*.sql
154+
*.csv
155+
tmp
156+
tmp/*

.vscode/extensions.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"recommendations": [
3-
"matangover.mypy",
43
"ms-python.black-formatter",
54
"mikestead.dotenv",
65
"eamodio.gitlens",

.vscode/launch.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "OP: Sample File Load",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "db_assessment/optimusprime.py",
12+
"args": [
13+
"--collection-id",
14+
"",
15+
"--project-name",
16+
"optimus-prime-ci",
17+
"--dataset",
18+
"op_api_testing_v3",
19+
"--files-location",
20+
"${workspaceFolder}/sample/datacollection",
21+
"--sep",
22+
"|",
23+
"--delete-dataset"
24+
],
25+
"justMyCode": true,
26+
"console": "integratedTerminal"
27+
},
28+
{
29+
"name": "OP: Flask App",
30+
"type": "python",
31+
"request": "launch",
32+
"module": "gunicorn",
33+
"args": [
34+
"--bind",
35+
"0.0.0.0:8080",
36+
"--timeout",
37+
"0",
38+
"--workers",
39+
"1",
40+
"db_assessment.api:app"
41+
],
42+
"justMyCode": true,
43+
"console": "integratedTerminal"
44+
}
45+
]
46+
}

.vscode/settings.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"source.fixAll.eslint": true
2222
},
2323
"python.defaultInterpreterPath": ".venv/bin/python",
24-
"python.linting.flake8Enabled": false,
24+
"python.linting.flake8Enabled": true,
2525
"python.linting.flake8Args": ["--max-line-length=120"],
2626
"python.linting.pylintEnabled": true,
2727
"python.linting.enabled": true,
@@ -49,5 +49,10 @@
4949
"[javascript]": {
5050
"editor.defaultFormatter": "esbenp.prettier-vscode"
5151
},
52-
"cSpell.words": ["dbping"]
52+
"cSpell.words": ["dbping", "highwater", "isdefault", "opname", "skiprows"],
53+
"[sql]": {
54+
"editor.defaultFormatter": "adpyke.vscode-sql-formatter"
55+
},
56+
"python.linting.banditEnabled": false,
57+
"python.linting.mypyEnabled": false
5358
}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ RUN apt-get update \
1919
&& rm -rf /var/apt/lists/* \
2020
&& rm -rf /var/cache/apt/*
2121
RUN pip install --no-cache-dir --upgrade pip \
22-
pip install --no-cache-dir wheel setuptools cython
22+
pip install --no-cache-dir --upgrade wheel setuptools cython
2323

2424

2525
FROM python-base AS build-stage

Makefile

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,55 @@ help: ## Display this help
2020

2121
.PHONY: upgrade-dependencies
2222
upgrade-dependencies: ## Upgrade all dependencies to the latest stable versions
23-
pip-compile -r requirements/base.in > requirements/base.txt
24-
pip-compile -r requirements/dev.in > requirements/dev.txt
25-
pip-compile -r requirements/lint.in > requirements/lint.txt
23+
${ENV_PREFIX}pip-compile -r requirements/base.in > requirements/base.txt
24+
${ENV_PREFIX}pip-compile -r requirements/dev.in > requirements/dev.txt
25+
${ENV_PREFIX}pip-compile -r requirements/lint.in > requirements/lint.txt
2626

2727
.PHONY: install
2828
install: ## Install the project in dev mode.
29+
@if [ "$(VENV_EXISTS)" ]; then echo "Removing existing environment"; fi
30+
@if [ "$(VENV_EXISTS)" ]; then rm -Rf .venv; fi
31+
python3 -m venv .venv && source .venv/bin/activate && .venv/bin/pip install -U wheel setuptools cython pip
32+
${ENV_PREFIX}pip install -r requirements.txt
33+
${ENV_PREFIX}pip install .
34+
35+
36+
.PHONY: install-dev
37+
install-dev:
2938
@if [ "$(VENV_EXISTS)" ]; then echo "Removing existing environment"; fi
3039
@if [ "$(VENV_EXISTS)" ]; then rm -Rf .venv; fi
3140
python3 -m venv .venv && source .venv/bin/activate && .venv/bin/pip install -U wheel setuptools cython pip
3241
${ENV_PREFIX}pip install -r requirements/dev.txt
42+
${ENV_PREFIX}pip install -r requirements/lint.txt
43+
${ENV_PREFIX}pip install -e .
44+
45+
.PHONY: clean
46+
clean: ## remove all build, testing, and static documentation files
47+
rm -fr build/
48+
rm -fr dist/
49+
rm -fr .eggs/
50+
find . -name '*.egg-info' -exec rm -fr {} +
51+
find . -name '*.egg' -exec rm -f {} +
52+
find . -name '*.pyc' -exec rm -f {} +
53+
find . -name '*.pyo' -exec rm -f {} +
54+
find . -name '*~' -exec rm -f {} +
55+
find . -name '__pycache__' -exec rm -fr {} +
56+
find . -name '.ipynb_checkpoints' -exec rm -fr {} +
57+
rm -fr .tox/
58+
rm -fr .coverage
59+
rm -fr coverage.xml
60+
rm -fr coverage.json
61+
rm -fr htmlcov/
62+
rm -fr .pytest_cache
63+
rm -fr .mypy_cache
64+
rm -fr site
65+
66+
67+
.PHONY: gen-docs
68+
gen-docs: ## generate HTML documentation
69+
${ENV_PREFIX}mkdocs build
70+
71+
.PHONY: docs
72+
docs: ## generate HTML documentation and serve it to the browser
73+
${ENV_PREFIX}mkdocs build
74+
${ENV_PREFIX}mkdocs serve

README.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,9 @@ Make note of the project name and the data set name and location. The data set w
159159

160160
2.1 Automated load process
161161

162-
These instructions are written for running in a Cloud Shell environment. Ensure that your environment is configured to access the Google Cloud project you want to use:
163-
```
162+
These instructions are written for running in a Cloud Shell environment. Ensure that your environment is configured to access the Google Cloud project you want to use:
163+
164+
```shell
164165
gcloud config set project [PROJECT_ID]
165166
```
166167

@@ -191,7 +192,7 @@ cd data
191192

192193
2.1.3 Configure automation
193194

194-
The automated process is configured via setting several environment variables and then executing the file <workingdirectory>/oracle-database-assessment/db_assessment/0_configure_op_env.sh.
195+
The automated load process is configured via setting several environment variables and then executing a set of scripts in the <workingdirectory>/oracle-database-assessment/scripts/ directory.
195196

196197
Set these environment variables prior to starting the data load process:
197198

@@ -231,19 +232,18 @@ export COLSEP='|'
231232

232233
2.1.4 Execute the load scripts
233234

234-
The load scripts expect to be run from the <workingdirectory>/oracle-database-assessment directory. Change to this directory and run the following commands in numeric order. Check output of each for errors before continuing to the next.
235+
The load scripts expect to be run from the <workingdirectory>/oracle-database-assessment/scripts directory. Change to this directory and run the following commands in numeric order. Check output of each for errors before continuing to the next.
235236

236237
```shell
237-
. ./db_assessment/0_configure_op_env.sh
238-
./db_assessment/1_activate_op.sh
239-
./db_assessment/2_load_op.sh
240-
./db_assessment/3_run_op_etl.sh
241-
./db_assessment/4_gen_op_report_url.sh
238+
./scripts/1_activate_op.sh
239+
./scripts/2_load_op.sh
240+
./scripts/3_run_op_etl.sh
241+
./scripts/4_gen_op_report_url.sh
242242
```
243243

244244
The function of each script is as follows.
245245

246-
- 0_configure_op_env.sh - Defines environment variables that are used in the other scripts.
246+
- _configure_op_env.sh - Defines environment variables that are used in the other scripts. This script is executed only by the other scripts in the loading process.
247247
- 1_activate_op.sh - Installs necessary Python support modules and activates the Python virtual environment for Optimus Prime.
248248
- 2_load_op.sh - Loads the client data files into the base Optimus Prime tables in the requested data set.
249249
- 3_run_op_etl.sh - Installs and runs Big Query procedures that create additional views and tables to support the Optimus Prime dashboard.
@@ -320,34 +320,34 @@ unzip <zip files>
320320

321321
# If you want to import one single Optimus Prime file collection (From 1 single database), please follow the below step:
322322

323-
optimus-prime -dataset newdatasetORexistingdataset -collectionid 080421224807 -fileslocation /<work-directory>/oracle-database-assessment-output -projectname my-awesome-gcp-project -importcomment "this is for prod"
323+
optimus-prime -dataset newdatasetORexistingdataset -collectionid 080421224807 --files-location /<work-directory>/oracle-database-assessment-output --project-name my-awesome-gcp-project -importcomment "this is for prod"
324324

325-
# If you want to import various Optimus Prime file collections (From various databases) that are stored under the same directory being used for -fileslocation. Then, you can add to your command two additional flags (-fromdataframe -consolidatedataframes) and pass only "" to -collectionid. See example below:
325+
# If you want to import various Optimus Prime file collections (From various databases) that are stored under the same directory being used for --files-location. Then, you can add to your command two additional flags (--from-dataframe -consolidatedataframes) and pass only "" to -collectionid. See example below:
326326

327-
optimus-prime -dataset newdatasetORexistingdataset -collectionid "" -fileslocation /<work-directory>/oracle-database-assessment-output -projectname my-awesome-gcp-project -fromdataframe -consolidatedataframes
327+
optimus-prime -dataset newdatasetORexistingdataset -collectionid "" --files-location /<work-directory>/oracle-database-assessment-output --project-name my-awesome-gcp-project --from-dataframe -consolidatedataframes
328328

329-
# If you want to import only specific db version or sql version from Optimus Prime file collections hat are stored under the same directory being used for -fileslocation.
329+
# If you want to import only specific db version or sql version from Optimus Prime file collections hat are stored under the same directory being used for --files-location.
330330

331-
optimus-prime -dataset newdatasetORexistingdataset -collectionid "" -fileslocation /<work-directory>/oracle-database-assessment-output -projectname my-awesome-gcp-project -fromdataframe -consolidatedataframes -filterbydbversion 11.1 -filterbysqlversion 2.0.3
331+
optimus-prime -dataset newdatasetORexistingdataset -collectionid "" --files-location /<work-directory>/oracle-database-assessment-output --project-name my-awesome-gcp-project --from-dataframe -consolidatedataframes --filter-by-db-version 11.1 --filter-by-sql-version 2.0.3
332332

333333
# If you want to akip all file validations
334334

335-
optimus-prime -dataset newdatasetORexistingdataset -collectionid "" -fileslocation /<work-directory>/oracle-database-assessment-output -projectname my-awesome-gcp-project -skipvalidations
335+
optimus-prime -dataset newdatasetORexistingdataset -collectionid "" --files-location /<work-directory>/oracle-database-assessment-output --project-name my-awesome-gcp-project -skipvalidations
336336
```
337337

338-
- `-dataset`: is the name of the dataset in Google BigQuery. It is created if it does not exists. If it does already nothing to do then.
339-
- `-collectionid`: is the file identification which last numbers in the filename which represents `<datetime> (mmddrrhh24miss)`.
338+
- `--dataset`: is the name of the dataset in Google BigQuery. It is created if it does not exists. If it does already nothing to do then.
339+
- `--collection-id`: is the file identification which last numbers in the filename which represents `<datetime> (mmddrrhh24miss)`.
340340
- In this example of a filename `opdb__usedspacedetails__121_0.1.0_mydbhost.mycompany.com.ORCLDB.orcl1.071621111714.log` the file identification is `071621111714`.
341-
- `-fileslocation`: The location in which the opdb\*log were saved.
342-
- `-projectname`: The GCP project in which the data will be loaded.
343-
- `-deletedataset`: This an optinal. In case you want to delete the whole existing dataset before importing the data.
341+
- `--files-location`: The location in which the opdb\*log were saved.
342+
- `--project-name`: The GCP project in which the data will be loaded.
343+
- `--delete-dataset`: This an optinal. In case you want to delete the whole existing dataset before importing the data.
344344
- WARNING: It will DELETE permanently ALL tables previously in the dataset. No further confirmation will be required. Use it with caution.
345-
- `-importcomment`: This an optional. In case you want to store any comment about the load in opkeylog table. Eg: "This is for Production import"
346-
- `-filterbysqlversion`: This an optional. In case you have files from multiple sql versions in the folder and you want to load only specific sql version files
347-
- `-filterbydbversion`: This an optional. In case you have files from multiple db versions in the folder and you want to load only specific db version files
348-
- `-skipvalidations`: This is optional. Default is False. if we use the flag, file validations will be skipped
345+
- `--import-comment`: This an optional. In case you want to store any comment about the load in opkeylog table. Eg: "This is for Production import"
346+
- `--filter-by-sql-version`: This an optional. In case you have files from multiple sql versions in the folder and you want to load only specific sql version files
347+
- `--filter-by-db-version`: This an optional. In case you have files from multiple db versions in the folder and you want to load only specific db version files
348+
- `--skip-validations`: This is optional. Default is False. if we use the flag, file validations will be skipped
349349

350-
- > NOTE: If your file has elapsed time or any other string except data, fun following script to remove it
350+
- > NOTE: If your file has elapsed time or any other string except data, run the following script to remove it
351351
352352
```shell
353353
for i in `grep "Elapsed:" $OP_OUTPUT_DIR/*.log | cut -d ":" -f 1`; do sed -i '$ d' $i; done

cloudbuild.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ steps:
88
"us-central1-docker.pkg.dev/optimus-prime-ci/cloud-run-source-deploy/op-client:$BUILD_ID",
99
".",
1010
"-f",
11-
"deploy/Cloudbuild.dockerfile",
11+
"deploy/docker/cloudbuild/Dockerfile",
1212
]
1313
- name: "gcr.io/cloud-builders/docker"
1414
args:

db_assessment/0_configure_op_env.sh

Lines changed: 0 additions & 46 deletions
This file was deleted.

db_assessment/1_activate_op.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)