Skip to content

Commit

Permalink
Merge branch 'main' into feature/restore-db-script
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandru-m-g authored Apr 3, 2024
2 parents 28466aa + 1a49f10 commit 4184b35
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ __pycache__/

.DS_Store

*.pg_restore
venv/
coverage.xml

*.pg_restore
13 changes: 9 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
120
],
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff"
},
// "editor.defaultFormatter": "charliermarsh.ruff",
"ruff.args": [
"--config=pyproject.toml"
"ruff.enable": true,
"ruff.importStrategy": "fromEnvironment",
"ruff.lint.args": [
"--config=pyproject.toml",
],
"ruff.format.args": [
"--config=pyproject.toml",
],
"python.analysis.autoImportCompletions": true,
"python.testing.pytestArgs": [
Expand Down
39 changes: 39 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Contributing

The Humanitarian API (HAPI) is being developed by a team from the [Centre for Humanitarian Data](https://centre.humdata.org/).

HDX developers are using [Visual Code](https://code.visualstudio.com/) as a standard IDE for this project with development taking place inside Docker containers.

The following needs to be run once to setup the Docker containers for testing:

```shell
cd docker
docker-compose up -d
docker-compose exec -T hapi sh -c "apk add git"
docker-compose exec -T hapi sh -c "pip install --upgrade -r requirements.txt"
docker-compose exec -T hapi sh -c "pip install --upgrade -r dev-requirements.txt"
cd ..
./initialize_test_db.sh
```

Tests can either be run from the Visual Code test runner or with:

```shell
docker-compose exec -T hapi sh -c "pytest --log-level=INFO --cov=. --cov-report term --cov-report xml:coverage.xml"
```

A local copy of HAPI can be run by importing a snapshot of the database using the following shell script invocation in the host machine.

```shell
./restore_database.sh https://github.com/OCHA-DAP/hapi-pipelines/raw/db-export/database/hapi_db.pg_restore hapi
```

The HAPI application can then be launched using the `start` launch configuration in Visual Code, this serves the documentation at `http://localhost:8844/docs` and the API at `http://localhost:8844/api` in the host machine.

The HAPI database can be accessed locally with the following connection details:

```
URL: jdbc:postgresql://localhost:45432/hapi
username: hapi
password: hapi
```
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Overview

This GitHub repository implements the Humanitarian API (API), this includes the API endpoints themselves, API documentation and documentation on readthedocs.

This project is currently in development and the outputs are not yet public except for the `readthedocs` documentation:

* HAPI documentation
* HAPI endpoint root
* [readthedocs](https://hdx-hapi.readthedocs.io/en/latest/)

# Related repositories

1. [Schema for HAPI database in SQLAlchemy](https://github.com/OCHA-DAP/hapi-sqlalchemy-schema)
2. [HDX HAPI smoke tests](https://github.com/OCHA-DAP/hdx-hapi-smoke-tests)
3. [Pipelines to populate the HAPI database](https://github.com/OCHA-DAP/hapi-pipelines)
2 changes: 1 addition & 1 deletion hdx_hapi/services/admin_level_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def compute_unspecified_values(admin_level: AdminLevel):
elif admin_level == AdminLevel.TWO:
admin1_is_unspecified = False
admin2_is_unspecified = False
return admin1_is_unspecified, admin2_is_unspecified
return admin1_is_unspecified, admin2_is_unspecified
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ extend-ignore = [
inline-quotes = "single"
multiline-quotes = "single"

[tool.ruff.format]
# Prefer single quotes over double quotes
quote-style = "single"

[tool.ruff.lint.extend-per-file-ignores]
"hdx_hapi/config/doc_snippets.py" = ["E501"] # line too long


[tool.black]
line-length = 120
skip-string-normalization = true
Expand Down

0 comments on commit 4184b35

Please sign in to comment.