Skip to content

Refactor script into python pypi package for easier reuse in pipelines #5

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea
.venv
.env
dist
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# How to use
This project can be run via:

`poetry run create_report`

provided the appropriate environment variables are set in a `.env` file.

Alternatively, the project can also be built into a package and the package file installed in another machine:

```
poetry build
# distribute package file to another machine
pip install dist/create_report*.whl
create_report
```

Another way, is to run directly from git using pipx. This is useful for usage in pipelines:

```
pipx run --spec git+https://<link to git repo> create_report
```

31 changes: 31 additions & 0 deletions env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
REPORTING_SQL_SERVER=127.0.0.1
REPORTING_SQL_PORT=3306
REPORTING_SQL_DATABASE=myreportingdatabase
REPORTING_SQL_USERNAME=
REPORTING_SQL_PASSWORD=
REPORTING_SQL_TABLENAME=auldata_lake

AUDIT_MONGO_SERVER=127.0.0.1:27018
AUDIT_MONGO_REPLICASET=rs4
AUDIT_MONGO_USERNAME=
AUDIT_MONGO_PASSWORD=
AUDIT_MONGO_DATABASE=mydb
AUDIT_MONGO_COLLECTION=myauditcollection

ARC_MONGO_SERVER_A=127.0.0.1:27017
ARC_MONGO_REPLICASET_A=rs0
ARC_MONGO_SERVER_B=127.0.0.1:27017
ARC_MONGO_REPLICASET_B=rs1
ARC_MONGO_SERVER_C=127.0.0.1:27017
ARC_MONGO_REPLICASET_C=rs2
ARC_MONGO_USERNAME=
ARC_MONGO_PASSWORD=
ARC_MONGO_DATABASE=mydb
ARC_MONGO_COLLECTION=mycollection
ARC_MONGO_AUTH_MECHANISM=SCRAM-SHA-1
ARC_MONGO_AUTH_SOURCE=admin
ARC_MONGO_AUTH_DATABASE=admin
ARC_MONGO_READ_PREFERENCE=secondary

OFFER_NAME=MYOFFERNAME
LOG_LEVEL=DEBUG
678 changes: 678 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[tool.poetry]
name = "create_report"
version = "0.1.0"
description = ""
authors = ["Kenneth Langga"]
readme = "README.md"
packages = [{ include = "create_report", from = "src" }]

[tool.poetry.scripts]
create_report = "create_report.cli:main"

[tool.poetry.dependencies]
python = "^3.11"
pandas = "^2.0.3"
pymongo = "^4.4.1"
sqlalchemy = "^2.0.19"
python-dotenv = "^1.0.0"
python-dateutil = "^2.8.2"
pymysql = "^1.1.0"

[tool.poetry.group.dev.dependencies]
black = "^23.7.0"
ruff = "^0.0.282"

[tool.poetry.group.test.dependencies]
pytest = "^7.4.0"
pytest-env = "^0.8.2"
pytest-runner = "^6.0.0"

[tool.ruff]
select = ["ALL"]
ignore = ["ERA001", "D", "S608"]
fixable = ["E", "F", "I"]

[tool.pytest.ini_options]
pythonpath = ["src"]
testpaths = [
"tests",
]
env = [
"ARC_MONGO_AUTH_MECHANISM=SCRAM-SHA-1",
"ARC_MONGO_AUTH_SOURCE=admin",
"ARC_MONGO_READ_PREFERENCE=secondary",
"REPORTING_SQL_SERVER=127.0.0.1",
"REPORTING_SQL_PORT=3306",
"REPORTING_SQL_DATABASE=testdb",
"REPORTING_SQL_USERNAME=testuser",
"REPORTING_SQL_PASSWORD=testpass",
]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
269 changes: 0 additions & 269 deletions sample_script.py

This file was deleted.

Empty file added src/create_report/__init__.py
Empty file.
Loading