Skip to content

Commit

Permalink
Release 2.0.0 (#6)
Browse files Browse the repository at this point in the history
* update tutorial docs

update tutorial to match the new shakemap facade design. previously
shakemap was still combined with earthquake, now they are separated.

* update badge

update ci badge and add codeql badge for readme and docs index.

* update codecov workflow

* remove slots in api

it is difficult to merge dataclass and other class that has slots. so
remove it.

* update pytest config

use importlib import mode for pytest.

* add pytest pythonpath

pytest module discovery is very confusing. hopefully this will fix it.

* add . to pytest pythonpath

* change version to 1.0.1

* export more api

* update api docs reference

* rename exception to exceptions

* update docs and tests to exceptions

* change version to 2.0.0

* update docs api reference

* update tutorial docs

fix wrong reference url and use `/` prefix for url.

* remove enum test because useless

* move integration test to separate folder

* fix codecov upload workflow

fix fail upload code coverage

* update ruff badge

* add test

add test for parse_weather_forecast_data

* bump pytest and ruff

this updates
- pyproject.toml
- precommit config
- lock file
  • Loading branch information
kiraware committed Feb 16, 2024
1 parent 28d9ae9 commit a709401
Show file tree
Hide file tree
Showing 38 changed files with 218 additions and 401 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ jobs:
- name: Build docs with Material for MkDocs
run: poetry run mkdocs build
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
8 changes: 5 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ jobs:
- name: Build docs with Material for MkDocs
run: poetry run mkdocs build
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ repos:

# ruff - linting and format
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.14"
rev: "v0.2.1"
hooks:
- id: ruff
args: [--fix]
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# PyBMKG

![CI](https://github.com/kiraware/PyBMKG/actions/workflows/ci.yml/badge.svg)
[![CI](https://github.com/kiraware/PyBMKG/workflows/ci/badge.svg)](https://github.com/kiraware/PyBMKG/actions/workflows/ci.yml)
[![CodeQL](https://github.com/kiraware/PyBMKG/workflows/codeql/badge.svg)](https://github.com/kiraware/PyBMKG/actions/workflows/codeql.yml)
[![Docs](https://readthedocs.org/projects/pybmkg/badge/?version=latest)](https://pybmkg.readthedocs.io/en/latest/?badge=latest)
[![codecov](https://codecov.io/gh/kiraware/PyBMKG/graph/badge.svg?token=MN6AXAHO0P)](https://codecov.io/gh/kiraware/PyBMKG)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![Ruff](https://camo.githubusercontent.com/7f995d42c2de5a9eb8ced2df552a0813050d324427a3facabfcfa5f88cb11c59/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f636861726c6965726d617273682f727566662f6d61696e2f6173736574732f62616467652f76312e6a736f6e)](https://github.com/astral-sh/ruff)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![pypi](https://img.shields.io/pypi/v/PyBMKG.svg)](https://pypi.org/project/PyBMKG/)
[![python](https://img.shields.io/pypi/pyversions/PyBMKG.svg)](https://pypi.org/project/PyBMKG/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/license/mit/)
Expand Down
5 changes: 3 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# PyBMKG

![CI](https://github.com/kiraware/PyBMKG/actions/workflows/ci.yml/badge.svg)
[![CI](https://github.com/kiraware/PyBMKG/workflows/ci/badge.svg)](https://github.com/kiraware/PyBMKG/actions/workflows/ci.yml)
[![CodeQL](https://github.com/kiraware/PyBMKG/workflows/codeql/badge.svg)](https://github.com/kiraware/PyBMKG/actions/workflows/codeql.yml)
[![Docs](https://readthedocs.org/projects/pybmkg/badge/?version=latest)](https://pybmkg.readthedocs.io/en/latest/?badge=latest)
[![codecov](https://codecov.io/gh/kiraware/PyBMKG/graph/badge.svg?token=MN6AXAHO0P)](https://codecov.io/gh/kiraware/PyBMKG)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![Ruff](https://camo.githubusercontent.com/7f995d42c2de5a9eb8ced2df552a0813050d324427a3facabfcfa5f88cb11c59/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f636861726c6965726d617273682f727566662f6d61696e2f6173736574732f62616467652f76312e6a736f6e)](https://github.com/astral-sh/ruff)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![pypi](https://img.shields.io/pypi/v/PyBMKG.svg)](https://pypi.org/project/PyBMKG/)
[![python](https://img.shields.io/pypi/pyversions/PyBMKG.svg)](https://pypi.org/project/PyBMKG/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/license/mit/)
Expand Down
5 changes: 1 addition & 4 deletions docs/reference/api.md
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
::: bmkg.BMKG
::: bmkg.api.earthquake.Earthquake
::: bmkg.api.weather_forecast.WeatherForecast
::: bmkg.api.shakemap.Shakemap
::: bmkg.api
2 changes: 1 addition & 1 deletion docs/reference/exception.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::: bmkg.exception
::: bmkg.exceptions
93 changes: 49 additions & 44 deletions docs/tutorials.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ All done!

## Earthquake API

There are four APIs available for earthquakes
namely get_latest_earthquake, get_latest_earthquake_shakemap,
get_strong_earthquake, and get_felt_earthquake.
There are three APIs available for earthquakes
namely get_latest_earthquake, get_strong_earthquake,
and get_felt_earthquake.

### get_latest_earthquake

get_latest_earthquake is used to get latest earthquake
information at `https://data.bmkg.go.id/DataMKG/TEWS/autogempa.json`.
Read get_latest_earthquake
[reference](reference/api.md/#bmkg.earthquake.Earthquake.get_latest_earthquake)
[reference](reference/api.md/#bmkg.api.Earthquake.get_latest_earthquake)
for more details.

Code example:
Expand Down Expand Up @@ -70,48 +70,13 @@ Tidak berpotensi tsunami
Shakemap(file_name='20240118013237.mmi.jpg')
```

### get_latest_earthquake_shakemap

get_latest_earthquake_shakemap is used to get latest
earthquake shake map. The link starts with `https://data.bmkg.go.id/DataMKG/TEWS/`
and followed with shakemap filename. Read get_latest_earthquake_shakemap
[reference](reference/api.md/#bmkg.earthquake.Earthquake.get_latest_earthquake_shakemap)
for more details.

Code example:

```python
import asyncio

from bmkg import BMKG


async def main():
async with BMKG() as bmkg:
latest_earthquake = await bmkg.earthquake.get_latest_earthquake()
shakemap = latest_earthquake.shakemap
shakemap_content = await shakemap.get_content()

print(shakemap.file_name)
print(shakemap_content)

asyncio.run(main())
```

Example output:

```console
20240203152510.mmi.jpg
b'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00...'
```

### get_strong_earthquake

get_strong_earthquake is used to get fifteen strong earthquake
information with a magnitude of 5.0 M and above at
`https://data.bmkg.go.id/DataMKG/TEWS/gempaterkini.json`.
Read get_strong_earthquake
[reference](reference/api.md/#bmkg.earthquake.Earthquake.get_strong_earthquake)
[reference](reference/api.md/#bmkg.api.Earthquake.get_strong_earthquake)
for more details.

Code example:
Expand Down Expand Up @@ -161,7 +126,7 @@ Tidak berpotensi tsunami
get_felt_earthquake is used to get fifteen felt earthquake
information at `https://data.bmkg.go.id/DataMKG/TEWS/gempadirasakan.json`.
Read get_felt_earthquake
[reference](reference/api.md/#bmkg.earthquake.Earthquake.get_felt_earthquake)
[reference](reference/api.md/#bmkg.api.Earthquake.get_felt_earthquake)
for more details.

Code example:
Expand Down Expand Up @@ -206,6 +171,46 @@ III Banda Aceh, II-III Calang Aceh Jaya, II-III Aceh Besar
...
```

## Shakemap API

Shakemap API is part of the earthquake API. There is one method
that the shakemap API has, namely the get_content method.

### get_content

get_content is used to get latest earthquake shake map.
The link starts with `https://data.bmkg.go.id/DataMKG/TEWS`
and followed with `/shakemap-filename`. Read get_content
[reference](reference/api.md/#bmkg.api.Shakemap.get_content)
for more details.

Code example:

```python
import asyncio

from bmkg import BMKG


async def main():
async with BMKG() as bmkg:
latest_earthquake = await bmkg.earthquake.get_latest_earthquake()
shakemap = latest_earthquake.shakemap
shakemap_content = await shakemap.get_content()

print(shakemap.file_name)
print(shakemap_content)

asyncio.run(main())
```

Example output:

```console
20240203152510.mmi.jpg
b'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00...'
```

## Weather Forecast API

There is only one API available for weather forecast
Expand All @@ -219,9 +224,9 @@ within three days. There are 35 weather forecast data
representing provinces and major cities in Indonesia.
For each area you will get twelve weather forecasts data
so there are four weather forecasts for one day. The link
starts with `https://data.bmkg.go.id/DataMKG/MEWS/DigitalForecast/`
and followed with `DigitalForecast-{PROVINCE_NAME}.xml`. Read
get_weather_forecast [reference](reference/api.md/#bmkg.weather_forecast.WeatherForecast.get_weather_forecast)
starts with `https://data.bmkg.go.id/DataMKG/MEWS/DigitalForecast`
and followed with `/DigitalForecast-{PROVINCE_NAME}.xml`. Read
get_weather_forecast [reference](reference/api.md/#bmkg.api.WeatherForecast.get_weather_forecast)
for more details.

Code example:
Expand Down
Loading

0 comments on commit a709401

Please sign in to comment.