Skip to content

Commit a407ada

Browse files
committed
fix date generator, update tests, update version number, relative imports for gui
Date generator assumed that there was a fixed window of missing data, but actually, this is a changing window. Downloader now gives a warning about missing bid tables when they can't be downloaded.
1 parent 87283b2 commit a407ada

File tree

7 files changed

+28
-76
lines changed

7 files changed

+28
-76
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ NEMOSIS.exe
2727
nemosis/smoke_tests.py
2828
nemosis/check_new_bid_table_functionality.py
2929
*.pyc
30+
smoke.py

e.py

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

nemosis/date_generators.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,6 @@ def bid_table_gen(start_time, end_time):
120120
and year == end_year
121121
):
122122
continue
123-
if int(year) == 2021 and int(month) == 4 and int(day) == 1:
124-
logger.warning(
125-
"Offer data for 2021/04/01 is known to be missing from the AEMO public \n"
126-
"archive, explicitly skipping. This file would also contain data for the first 4 hr of \n"
127-
+ "2021/04/02 so that data will also be missing from the returned dataframe."
128-
)
129-
else:
130-
yield str(year), month, str(day).zfill(2), None
131-
123+
yield str(year), month, str(day).zfill(2), None
132124
else:
133-
if int(year) == 2021 and int(month) == 3:
134-
logger.warning(
135-
"Offer data for March 2021 is known to be missing from the AEMO public \n"
136-
"archive, explicitly skipping. This file would also contain data for the first 4 hr of \n"
137-
+ "2021/04/01 so that data will also be missing from the returned dataframe."
138-
)
139-
else:
140-
yield str(year), month, None, None
125+
yield str(year), month, None, None

nemosis/downloader.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,15 @@ def run_bid_tables(year, month, day, index, filename_stub, down_load_to):
3838
if day is None:
3939
run(year, month, day, index, filename_stub, down_load_to)
4040
else:
41-
_download_and_unpack_bid_move_complete_files(
42-
year, month, day, index, filename_stub, down_load_to
43-
)
44-
41+
try:
42+
_download_and_unpack_bid_move_complete_files(
43+
year, month, day, index, filename_stub, down_load_to
44+
)
45+
except Exception:
46+
logger.warning(f"{filename_stub} not downloaded. This is likely because this file is not being hosted \n" +
47+
"online by AEMO. You can check this url to confirm: \n" +
48+
"https://www.nemweb.com.au/REPORTS/Archive/Bidmove_Complete/. If the file is available but \n"
49+
"this warning persists please contact the NEMOSIS maintainers.")
4550

4651
def _download_and_unpack_bid_move_complete_files(
4752
year, month, day, index, filename_stub, down_load_to

nemosis/gui.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from . import rows
2-
from . import defaults
3-
from . import data_fetch_methods
1+
from nemosis import rows
2+
from nemosis import defaults
3+
from nemosis import data_fetch_methods
44
import pandas as pd
55
import tkinter as tk
66
import tkinter.ttk as ttk

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="nemosis",
8-
version="3.1.0",
8+
version="3.2.0",
99
author="Nicholas Gorman, Abhijith Prakash",
1010
author_email="n.gorman305@gmail.com",
1111
description="A tool for accessing AEMO data.",

tests/test_date_generators.py

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ def test_change_from_months_to_days(self):
185185
end_time = datetime.strptime("2021/04/03 00:00:00", "%Y/%m/%d %H:%M:%S")
186186
gen = date_generators.bid_table_gen(start_time, end_time)
187187
times = [(year, month, day, index) for year, month, day, index in gen]
188-
# Note we expect the 1st of april to be skipped
189188
self.assertEqual(times[0][0], "2021")
190189
self.assertEqual(times[0][1], "01")
191190
self.assertEqual(times[0][2], None)
@@ -194,49 +193,23 @@ def test_change_from_months_to_days(self):
194193
self.assertEqual(times[1][1], "02")
195194
self.assertEqual(times[1][2], None)
196195
self.assertEqual(times[1][3], None)
197-
# Data for march and the first of april is missing from the AEMO website so we don't generate the dates
198-
# for these times.
199196
self.assertEqual(times[2][0], "2021")
200-
self.assertEqual(times[2][1], "04")
201-
self.assertEqual(times[2][2], "02")
197+
self.assertEqual(times[2][1], "03")
198+
self.assertEqual(times[2][2], None)
202199
self.assertEqual(times[2][3], None)
203200
self.assertEqual(times[3][0], "2021")
204201
self.assertEqual(times[3][1], "04")
205-
self.assertEqual(times[3][2], "03")
202+
self.assertEqual(times[3][2], "01")
206203
self.assertEqual(times[3][3], None)
207-
self.assertEqual(len(times), 4)
208-
209-
def test_day_given_in_april_2021(self):
210-
start_time = datetime.strptime("2021/04/01 00:00:00", "%Y/%m/%d %H:%M:%S")
211-
end_time = datetime.strptime("2021/04/03 00:00:00", "%Y/%m/%d %H:%M:%S")
212-
gen = date_generators.bid_table_gen(start_time, end_time)
213-
times = [(year, month, day, index) for year, month, day, index in gen]
214-
# Note we expect the 1st of april to be skipped
215-
self.assertEqual(times[0][0], "2021")
216-
self.assertEqual(times[0][1], "04")
217-
self.assertEqual(times[0][2], "02")
218-
self.assertEqual(times[0][3], None)
219-
self.assertEqual(times[1][0], "2021")
220-
self.assertEqual(times[1][1], "04")
221-
self.assertEqual(times[1][2], "03")
222-
self.assertEqual(times[1][3], None)
223-
self.assertEqual(len(times), 2)
224-
225-
def test_include_previous_market_day(self):
226-
start_time = datetime.strptime("2021/05/10 01:00:00", "%Y/%m/%d %H:%M:%S")
227-
end_time = datetime.strptime("2021/05/10 05:00:00", "%Y/%m/%d %H:%M:%S")
228-
gen = date_generators.bid_table_gen(start_time, end_time)
229-
times = [(year, month, day, index) for year, month, day, index in gen]
230-
# Note we expect the 1st of april to be skipped
231-
self.assertEqual(times[0][0], "2021")
232-
self.assertEqual(times[0][1], "05")
233-
self.assertEqual(times[0][2], "09")
234-
self.assertEqual(times[0][3], None)
235-
self.assertEqual(times[1][0], "2021")
236-
self.assertEqual(times[1][1], "05")
237-
self.assertEqual(times[1][2], "10")
238-
self.assertEqual(times[1][3], None)
239-
self.assertEqual(len(times), 2)
204+
self.assertEqual(times[4][0], "2021")
205+
self.assertEqual(times[4][1], "04")
206+
self.assertEqual(times[4][2], "02")
207+
self.assertEqual(times[4][3], None)
208+
self.assertEqual(times[5][0], "2021")
209+
self.assertEqual(times[5][1], "04")
210+
self.assertEqual(times[5][2], "03")
211+
self.assertEqual(times[5][3], None)
212+
self.assertEqual(len(times), 6)
240213

241214
def test_include_previous_month_if_1st_market_day_of_month(self):
242215
start_time = datetime.strptime("2021/05/01 05:00:00", "%Y/%m/%d %H:%M:%S")

0 commit comments

Comments
 (0)