Skip to content

Commit

Permalink
Initial implementation of point name list
Browse files Browse the repository at this point in the history
  • Loading branch information
dhblum committed Aug 5, 2022
1 parent 7a302d7 commit 2d1d22a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
7 changes: 5 additions & 2 deletions forecast/forecaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ def __init__(self, testcase):
# Point to the test case object
self.case = testcase

def get_forecast(self,horizon=None, interval=None,
def get_forecast(self,point_names, horizon=None, interval=None,
category=None, plot=False):
'''Returns forecast of the test case data
Parameters
----------
point_names : list of str
List of forecast point names for which to get data.
horizon : int, default is None
Length of the requested forecast in seconds. If None,
the test case horizon will be used instead.
Expand Down Expand Up @@ -69,7 +71,8 @@ def get_forecast(self,horizon=None, interval=None,
interval = self.case.interval

# Get the forecast
forecast = self.case.data_manager.get_data(horizon=horizon,
forecast = self.case.data_manager.get_data(variables = point_names,
horizon=horizon,
interval=interval,
category=category,
plot=plot)
Expand Down
13 changes: 10 additions & 3 deletions restapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ def handle_validation_error(self, error, bundle_errors):
parser_scenario = reqparse.RequestParser(argument_class=CustomArgument)
parser_scenario.add_argument('electricity_price', type=str)
parser_scenario.add_argument('time_period', type=str)
# ``forecast`` interface
parser_forecast_points = reqparse.RequestParser(argument_class=CustomArgument)
parser_forecast_points.add_argument('point_names', type=list, action='append', required=True)
# ``results`` interface
results_var = reqparse.RequestParser(argument_class=CustomArgument)
results_var.add_argument('point_name', type=str, required=True)
Expand Down Expand Up @@ -203,9 +206,13 @@ def put(self):
class Forecast(Resource):
'''Interface to test case forecast data.'''

def get(self):
'''GET request to receive forecast data.'''
status, message, payload = case.get_forecast()
def put(self):
'''PUT request to receive forecast data.'''
args = parser_forecast_points.parse_args()
point_names = []
for point_name in args['point_names']:
point_names.append(''.join(point_name))
status, message, payload = case.get_forecast(point_names)
return construct(status, message, payload)


Expand Down
8 changes: 5 additions & 3 deletions testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,12 +850,13 @@ def get_forecast_parameters(self):

return status, message, payload

def get_forecast(self):
def get_forecast(self, point_names):
'''Returns the test case data forecast
Parameters
----------
None
point_names : list of str
List of forecast point names for which to get data.
Returns
-------
Expand All @@ -878,7 +879,8 @@ def get_forecast(self):
status = 200
message = "Queried the forecast data successfully."
try:
payload = self.forecaster.get_forecast(horizon=self.horizon,
payload = self.forecaster.get_forecast(point_names,
horizon=self.horizon,
interval=self.interval)
except:
status = 500
Expand Down

0 comments on commit 2d1d22a

Please sign in to comment.