Skip to content

Commit

Permalink
Initial port from marburg repo
Browse files Browse the repository at this point in the history
  • Loading branch information
abhidg committed Aug 28, 2024
1 parent ffff425 commit 2472a0d
Show file tree
Hide file tree
Showing 11 changed files with 1,142 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: tests

on:
push:
branches: [main]
paths:
- '.github/workflows/tests.yml'
- 'src/obr/**.py'
- 'pyproject.toml'
- 'uv.lock'
pull_request:
paths:
- '.github/workflows/tests.yml'
- 'src/obr/**.py'
- 'pyproject.toml'
- 'uv.lock'
jobs:
ci:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v5
- name: Setup uv
run: curl -LsSf https://astral.sh/uv/0.4.0/install.sh | sh
- name: Install the project
run: uv sync --all-extras --dev
- name: Run tests
run: uv run pytest
23 changes: 23 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[project]
name = "obr"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"chevron>=0.14.0",
"pandas>=2.2.2",
"python-dateutil>=2.9.0.post0",
"plotly>=5.23.0",
"boto3>=1.35.8",
]
scripts = { obr = "obr:main" }

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv]
dev-dependencies = [
"pytest>=8.3.2",
]
37 changes: 37 additions & 0 deletions src/obr/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import sys
import argparse
from .util import build
from .outbreaks import OUTBREAKS


def abort(msg):
print(msg)
sys.exit(1)


def main():
parser = argparse.ArgumentParser(
description="Global.health outbreak report creator"
)
parser.add_argument("outbreak", help="Outbreak name")
parser.add_argument("url", help="Data URL")
parser.add_argument("-b", "--bucket", help="S3 bucket to write outbreak report to")
parser.add_argument(
"--cloudfront", help="Cloudfront distribution which should be invalidated"
)

args = parser.parse_args()
if args.outbreak not in OUTBREAKS:
abort(f"Outbreak not supported: {args.outbreak}")

build(
args.outbreak,
args.url,
OUTBREAKS[args.outbreak],
output_bucket=args.bucket,
cloudfront_distribution=args.cloudfront,
)


if __name__ == "__main__":
main()
45 changes: 45 additions & 0 deletions src/obr/outbreaks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""
Outbreak configurations
"""

from ..plots import (
get_counts,
plot_epicurve,
plot_timeseries_location_status,
plot_age_gender,
plot_delay_distribution,
)

outbreak_marburg = [
("data", get_counts),
("figure/epicurve", plot_epicurve),
(
"figure/epicurve_location_status",
plot_timeseries_location_status,
dict(admin_column="Location_District"),
),
("figure/age_gender", plot_age_gender),
(
"figure/delay_distribution_consult",
plot_delay_distribution,
dict(
col="Date_of_first_consult",
title="Delay to consultation from onset",
index="A",
max_delay_days=20,
),
),
(
"figure/delay_distribution_death",
plot_delay_distribution,
dict(
col="Date_death",
title="Delay to death from onset",
index="B",
max_delay_days=20,
),
),
]

OUTBREAKS = {"marburg": outbreak_marburg}
__all__ = ["OUTBREAKS"]
Loading

0 comments on commit 2472a0d

Please sign in to comment.