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(episcanner): move binary build branch to updated main #13

Merged
merged 14 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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
6 changes: 3 additions & 3 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ jobs:
pre-commit install
pre-commit run --all-files

# - name: Pytest
# run: |
# test-fetch-data
- name: Pytest
run: |
make tests
9 changes: 9 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ jobs:
with:
node-version: 18

- name: Install dependencies
run: poetry install

- name: Build binary
run: poetry run build

- name: Package binary
run: tar -czvf dist/episcanner.tar.gz -C dist/ episcanner

- name: Test release
if: ${{ github.event_name != 'workflow_dispatch' }}
env:
Expand Down
6 changes: 6 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
"prepareCmd": "poetry build"
}
],
[
"@semantic-release/github",
{
"assets": ["dist/*.whl", "dist/*.tar.gz"]
}
],
[
"@semantic-release/git",
{
Expand Down
16 changes: 5 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,15 @@
ENV:=$(ENV)


.PHONY: create-dotenv
create-dotenv:
.PHONY: dotenv
dotenv:
export HOST_UID=$$(id -u) && \
export HOST_GID=$$(id -g) && \
envsubst < env.tpl > .env

# Export data for all states and diseases to Parquet files in the default output directory
.PHONY:fetch-data
fetch-data:
python epi_scanner/downloader/export_data.py -s all -d dengue chikungunya

# Run pytest for all tests in epi_scanner/tests inside the container
.PHONY:test-fetch-data
test-fetch-data:
pytest -vv epi_scanner/tests
.PHONY:tests
tests:
pytest -vv src/tests

.PHONY: clean
clean: ## clean all artifacts
Expand Down
36 changes: 15 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Episcanner Downloader

Episcanner Downloader is a data downloader for the Episcanner application. It retrieves data related to diseases like dengue and chikungunya and saves it in a specified directory.
Episcanner Downloader is a data downloader for the Episcanner application. It retrieves data related to diseases like dengue, zika and chikungunya and saves it in a specified directory with the formats csv, parquet or duckdb.

## Features

Expand All @@ -27,13 +27,13 @@ To install Episcanner Downloader, follow these steps:
```shell
conda env create -f conda/env-base.yaml
```
2. conda activate episcanner
2. conda activate episcanner-downloader
```shell
conda activate episcanner
conda activate episcanner-downloader
```
3. Install the dependencies using Poetry:
3. Build the binary using Poetry:
```shell
poetry install
poetry run build
```
### Using a Virtual Environment (venv)
1. Create a virtual environment:
Expand All @@ -44,38 +44,32 @@ To install Episcanner Downloader, follow these steps:
```shell
source env/bin/activate
```
3. Install the dependencies using Poetry:
3. Build the binary using Poetry:
```shell
poetry install
poetry run build
```
## Setting Environment Variables
Before running Episcanner Downloader, make sure to set the required environment variables for connecting to the PSQL database. You can use the provided Makefile to create a .env file with the exported variables:
1. Set the required environment variables for connecting to the PSQL database:
```shell
export PSQL_USER=<your_psql_user>
export PSQL_PASSWORD=<your_psql_password>
export PSQL_HOST=<your_psql_host>
export PSQL_PORT=<your_psql_port>
export PSQL_USER=<your_psql_database>
export EPISCANNER_PSQL_URI="postgresql://user:password@host:port/database"
```

2. Create a .env file in the project root directory with the exported variables.
```shell
make create-dotenv
make dotenv
```
## Usage
To use Episcanner Downloader, follow these steps:

1. Activate the project's virtual environment:
1. Execute the binary (examples for Linux):
```shell
source /path/to/episcanner-downloader/venv/bin/activate
cd dist/
./episcanner -h
./episcanner -s RJ -d dengue -o /tmp -f duckdb
./episcanner --all -d zika -o /tmp -f csv parquet --verbose
```
2. Run the Episcanner Downloader:
```shell
mkdir data
python epi_scanner/downloader/export_data.py -s <source> -d <diseases> -o data
```
*Replace <source> with the desired source (e.g., 'MG', or 'all' to download all states) and <diseases> with the specific diseases you want to download (e.g., 'dengue chikungunya'). Specify the <output_directory> where the data should be saved.*
*Replace <source> with the desired source (e.g., 'MG', or '--all' to download all states) and <diseases> with the specific diseases you want to download (e.g., 'dengue chikungunya'). Specify the <output_directory> where the data should be saved.*

## License
Episcanner Downloader is licensed under the [MIT License](https://github.com/AlertaDengue/episcanner-downloader/blob/main/LICENSE). See the LICENSE file for more details.
11 changes: 1 addition & 10 deletions env.tpl
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
# Host
HOST_GID=$HOST_GID
HOST_UID=$HOST_UID

# Used to fetch data from the database
PSQL_DB=$PSQL_DB
PSQL_HOST=$PSQL_HOST
PSQL_PASSWORD=$PSQL_PASSWORD
PSQL_PORT=$PSQL_PORT
PSQL_USER=$PSQL_USER
EPISCANNER_PSQL_URI=$EPISCANNER_PSQL_URI
Binary file removed epi_scanner/data/muni_br.gpkg
Binary file not shown.
Empty file removed epi_scanner/downloader/__init__.py
Empty file.
170 changes: 0 additions & 170 deletions epi_scanner/downloader/export_data.py

This file was deleted.

Loading
Loading