Skip to content
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

refactor: align repo with new ETL template #8

Merged
merged 1 commit into from
Sep 12, 2024
Merged
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
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
root = true
[*]
indent_style = space
indent_size = 4
max_line_length = 80
15 changes: 15 additions & 0 deletions .github/workflows/cape.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: CAPE
on:
push:
branches: [main]
pull_request:

jobs:
python:
name: Python
uses: cape-ph/.github/.github/workflows/python_checks.yml@main
with:
pytest: false
general:
name: General
uses: cape-ph/.github/.github/workflows/general_checks.yml@main
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release

on:
push:
tags: ["**"]
workflow_dispatch:

permissions:
contents: write

jobs:
Release:
uses: cape-ph/.github/.github/workflows/release.yml@main
secrets: inherit
222 changes: 198 additions & 24 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,198 @@
# OS
# ===========
.DS_Store
ehthumbs.db
Icon?
Thumbs.db
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# General
# =======
# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# JetBrains
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
.idea/**/aws.xml
.idea/**/contentModel.xml
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
.idea/**/gradle.xml
.idea/**/libraries
cmake-build-*/
.idea/**/mongoSettings.xml
*.iws
out/
.idea_modules/
atlassian-ide-plugin.xml
.idea/replstate.xml
.idea/sonarlint/
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
.idea/httpRequests
.idea/caches/build_file_checksums.ser

# Vagrant/Ansible/CI
.vagrant
playbook.retry
.vault
ansible.out

# General
*.dat
*.out
*.pid
Expand All @@ -19,23 +204,12 @@ Thumbs.db
logs/
build/

# IDEs
# ====
*.iml
*.idea
.vscode
*.code-workspace

# Vagrant/Ansible/CI related
# ==========================
.vagrant
playbook.retry
.vault
ansible.out
# OS
.DS_Store
ehthumbs.db
Icon?
Thumbs.db

# Other
# =====
sslcerts.pfx
scripts/*gz
__pycache__/
*.py[cod]
8 changes: 8 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
proseWrap: always
tabWidth: 4
useTabs: false

overrides:
- files: "*.md"
options:
parser: "markdown"
9 changes: 6 additions & 3 deletions etl_gphl_cre_alert.py → main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io
import sys
from pathlib import Path

import boto3 as boto3
import dateutil.parser as dparser
Expand Down Expand Up @@ -42,7 +43,7 @@
# NOTE: for now we'll take the alert object key and change out the file
# extension for the clean data (leaving all namespacing and such). this
# will probably need to change
clean_obj_key = alert_obj_key.replace(".docx", ".csv")
clean_obj_key = str(Path(alert_obj_key).with_suffix(".csv"))

# NOTE: May need some creds here
s3_client = boto3.client("s3")
Expand Down Expand Up @@ -105,7 +106,9 @@
# include it in the AR query, but we still have it if we end up
# needing it for anything else
interim = pd.DataFrame()
interim["Mechanism (*Submitters Report)"] = data["Anti-Microbial Resistance RT-PCR"]
interim["Mechanism (*Submitters Report)"] = data[
"Anti-Microbial Resistance RT-PCR"
]
interim["Organism"] = data["Organism ID"]
interim["Date Received"] = date_received
interim["Date Reported"] = date_received
Expand All @@ -119,7 +122,7 @@
interim["Facility of Origin"] = data["Received from"]
interim["State_Lab_ID"] = data["Lab ID"]

# write out the transofrmed data
# write out the transformed data
with io.StringIO() as csv_buff:
interim.to_csv(csv_buff, index=False)

Expand Down
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[tool.black]
line-length = 80

[tool.isort]
profile = "black"
line_length = 80

[tool.ruff]
line-length = 80
4 changes: 4 additions & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"autoImportCompletions": true,
"typeCheckingMode": "basic"
}