Skip to content

Commit 79f9b23

Browse files
authored
Merge pull request #4 from bluesky-api/dataset
Add dataset parameter
2 parents cac42f3 + b9172ac commit 79f9b23

File tree

5 files changed

+52
-42
lines changed

5 files changed

+52
-42
lines changed

.github/workflows/main.yml

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,25 +81,24 @@ jobs:
8181
- name: Run pytest
8282
run: poetry run coverage run -m pytest -p no:sugar
8383

84-
- name: Upload coverage data to coveralls.io
85-
run: poetry run coveralls --service=github
86-
env:
87-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88-
COVERALLS_FLAG_NAME: ${{ matrix.test-name }}
89-
COVERALLS_PARALLEL: true
90-
91-
coveralls:
92-
name: Indicate completion to coveralls.io
93-
needs: tests
94-
runs-on: ubuntu-latest
95-
container: python:3-slim
96-
steps:
97-
- name: Finished
98-
run: |
99-
pip3 install --upgrade coveralls
100-
coveralls --service=github --finish
101-
env:
102-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
# Temporarily disabled because of bug on windows tests
85+
# - name: Coveralls Parallel
86+
# uses: coverallsapp/github-action@v2
87+
# with:
88+
# flag-name: run-${{ join(matrix.*, '-') }}
89+
# parallel: true
90+
91+
# coveralls:
92+
# name: Indicate completion to coveralls.io
93+
# needs: tests
94+
# runs-on: ubuntu-latest
95+
# container: python:3-slim
96+
# steps:
97+
# - name: Finished
98+
# uses: coverallsapp/github-action@v2
99+
# with:
100+
# parallel-finished: true
101+
# carryforward: "run-1,run-2"
103102

104103
publish:
105104
name: Build package and publish to PyPI
@@ -120,7 +119,7 @@ jobs:
120119
- name: Setup poetry
121120
uses: abatilo/actions-poetry@v2.0.0
122121
with:
123-
poetry-version: "1.3.1"
122+
poetry-version: "1.4.2"
124123

125124
- name: Authenticate poetry
126125
run: poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}

src/blueskyapi/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,15 @@ def latest_forecast(
7373
lon: float,
7474
forecast_distances: Iterable[int] = None,
7575
columns: Iterable[str] = None,
76+
dataset: Optional[str] = None,
7677
) -> pd.DataFrame:
7778
"""Obtain the latest forecast.
7879
7980
:param lat: Latitude for which to fetch the forecast.
8081
:param lon: Longitude for which to fetch the forecast.
8182
:param forecast_distances: Forecast distances to fetch data for (hours from ``forecast_moment``).
8283
:param columns: Which variables to fetch (see `this page for available variables <https://blueskyapi.io/docs/data>`_).
84+
:param dataset: Which dataset to fetch data from (only for users on the Professional plan).
8385
"""
8486
response = self._get(
8587
"/forecasts/latest",
@@ -90,6 +92,7 @@ def latest_forecast(
9092
forecast_distances, "forecast_distances"
9193
),
9294
columns=_prepare_comma_separated_list(columns, "columns"),
95+
dataset=dataset,
9396
),
9497
)
9598
return _create_dataframe(response)
@@ -102,6 +105,7 @@ def forecast_history(
102105
max_forecast_moment: Optional[Union[datetime, str]] = None,
103106
forecast_distances: Optional[Iterable[int]] = None,
104107
columns: Optional[Iterable[str]] = None,
108+
dataset: Optional[str] = None,
105109
) -> pd.DataFrame:
106110
"""Obtain historical forecasts.
107111
@@ -111,6 +115,7 @@ def forecast_history(
111115
:param max_forecast_moment: The last forecast moment to include.
112116
:param forecast_distances: Forecast distances to return data for (hours from ``forecast_moment``).
113117
:param columns: Which variables to fetch (see `this page for available variables <https://blueskyapi.io/docs/data>`_).
118+
:param dataset: Which dataset to fetch data from (only for users on the Professional plan).
114119
"""
115120
response = self._get(
116121
"/forecasts/history",
@@ -127,6 +132,7 @@ def forecast_history(
127132
forecast_distances, "forecast_distances"
128133
),
129134
columns=_prepare_comma_separated_list(columns, "columns"),
135+
dataset=dataset,
130136
),
131137
)
132138
return _create_dataframe(response)

test.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/blueskyapi/client_test.py renamed to tests/blueskyapi/test_client.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,19 @@ def test_result(client):
134134
)
135135
assert np.all(result.some_column == [5])
136136

137+
def describe_dataset():
138+
@responses.activate
139+
def with_valid(client):
140+
add_api_response(
141+
"/forecasts/latest"
142+
"?lat=53.5&lon=13.5&dataset=the-dataset"
143+
)
144+
client.latest_forecast(
145+
53.5,
146+
13.5,
147+
dataset="the-dataset",
148+
)
149+
137150
@pytest.mark.vcr()
138151
def test_integration(client):
139152
result = client.latest_forecast(53.5, 13.5)
@@ -211,6 +224,20 @@ def with_none(client):
211224
max_forecast_moment=None,
212225
)
213226

227+
def describe_dataset():
228+
@responses.activate
229+
def with_valid(client):
230+
add_api_response(
231+
"/forecasts/history"
232+
"?lat=53.5&lon=13.5&dataset=the-dataset"
233+
)
234+
client.forecast_history(
235+
53.5,
236+
13.5,
237+
dataset="the-dataset",
238+
)
239+
240+
214241
@pytest.mark.vcr()
215242
def test_integration(client):
216243
min_moment = datetime(2021, 12, 27, 18, 0)
File renamed without changes.

0 commit comments

Comments
 (0)