Skip to content
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
39 changes: 19 additions & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,24 @@ jobs:
- name: Run pytest
run: poetry run coverage run -m pytest -p no:sugar

- name: Upload coverage data to coveralls.io
run: poetry run coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.test-name }}
COVERALLS_PARALLEL: true

coveralls:
name: Indicate completion to coveralls.io
needs: tests
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Finished
run: |
pip3 install --upgrade coveralls
coveralls --service=github --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Temporarily disabled because of bug on windows tests
# - name: Coveralls Parallel
# uses: coverallsapp/github-action@v2
# with:
# flag-name: run-${{ join(matrix.*, '-') }}
# parallel: true

# coveralls:
# name: Indicate completion to coveralls.io
# needs: tests
# runs-on: ubuntu-latest
# container: python:3-slim
# steps:
# - name: Finished
# uses: coverallsapp/github-action@v2
# with:
# parallel-finished: true
# carryforward: "run-1,run-2"

publish:
name: Build package and publish to PyPI
Expand All @@ -120,7 +119,7 @@ jobs:
- name: Setup poetry
uses: abatilo/actions-poetry@v2.0.0
with:
poetry-version: "1.3.1"
poetry-version: "1.4.2"

- name: Authenticate poetry
run: poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
Expand Down
6 changes: 6 additions & 0 deletions src/blueskyapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ def latest_forecast(
lon: float,
forecast_distances: Iterable[int] = None,
columns: Iterable[str] = None,
dataset: Optional[str] = None,
) -> pd.DataFrame:
"""Obtain the latest forecast.

:param lat: Latitude for which to fetch the forecast.
:param lon: Longitude for which to fetch the forecast.
:param forecast_distances: Forecast distances to fetch data for (hours from ``forecast_moment``).
:param columns: Which variables to fetch (see `this page for available variables <https://blueskyapi.io/docs/data>`_).
:param dataset: Which dataset to fetch data from (only for users on the Professional plan).
"""
response = self._get(
"/forecasts/latest",
Expand All @@ -90,6 +92,7 @@ def latest_forecast(
forecast_distances, "forecast_distances"
),
columns=_prepare_comma_separated_list(columns, "columns"),
dataset=dataset,
),
)
return _create_dataframe(response)
Expand All @@ -102,6 +105,7 @@ def forecast_history(
max_forecast_moment: Optional[Union[datetime, str]] = None,
forecast_distances: Optional[Iterable[int]] = None,
columns: Optional[Iterable[str]] = None,
dataset: Optional[str] = None,
) -> pd.DataFrame:
"""Obtain historical forecasts.

Expand All @@ -111,6 +115,7 @@ def forecast_history(
:param max_forecast_moment: The last forecast moment to include.
:param forecast_distances: Forecast distances to return data for (hours from ``forecast_moment``).
:param columns: Which variables to fetch (see `this page for available variables <https://blueskyapi.io/docs/data>`_).
:param dataset: Which dataset to fetch data from (only for users on the Professional plan).
"""
response = self._get(
"/forecasts/history",
Expand All @@ -127,6 +132,7 @@ def forecast_history(
forecast_distances, "forecast_distances"
),
columns=_prepare_comma_separated_list(columns, "columns"),
dataset=dataset,
),
)
return _create_dataframe(response)
Expand Down
22 changes: 0 additions & 22 deletions test.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ def test_result(client):
)
assert np.all(result.some_column == [5])

def describe_dataset():
@responses.activate
def with_valid(client):
add_api_response(
"/forecasts/latest"
"?lat=53.5&lon=13.5&dataset=the-dataset"
)
client.latest_forecast(
53.5,
13.5,
dataset="the-dataset",
)

@pytest.mark.vcr()
def test_integration(client):
result = client.latest_forecast(53.5, 13.5)
Expand Down Expand Up @@ -211,6 +224,20 @@ def with_none(client):
max_forecast_moment=None,
)

def describe_dataset():
@responses.activate
def with_valid(client):
add_api_response(
"/forecasts/history"
"?lat=53.5&lon=13.5&dataset=the-dataset"
)
client.forecast_history(
53.5,
13.5,
dataset="the-dataset",
)


@pytest.mark.vcr()
def test_integration(client):
min_moment = datetime(2021, 12, 27, 18, 0)
Expand Down
File renamed without changes.