def consolidate(year): """ Only required for DFMC model """ mr = ModelRegister() model = mr.get('DFMC') looped = asyncio.new_event_loop() result = looped.run_until_complete(model.consolidate_year(year)) return result
def do_query(geo_json, start, finish, model): result = {} try: sq = ShapeQuery(geo_json=geo_json, start=start, finish=finish) mr = ModelRegister() model = mr.get(model) looped = asyncio.new_event_loop() result = looped.run_until_complete(model.get_timeseries_results(sq)) except ValueError as e: logger.error("ValueError") # result['error'] = json.dumps(e) mrs = ModelResultSchema() json_result, errors = mrs.dump(result) return json_result
def do_netcdf(geo_json, start, finish, model): result = {} try: sq = ShapeQuery(geo_json=geo_json, start=start, finish=finish) mr = ModelRegister() model = mr.get(model) looped = asyncio.new_event_loop() result = looped.run_until_complete(model.get_netcdf_results(sq)) except ValueError as e: logger.error("ValueError") # result['error'] = json.dumps(e) # Return result as filename string # HUG will stream the binary data return result
def do_mp4(geo_json, start, finish, model): result = {} try: sq = ShapeQuery(geo_json=geo_json, start=start, finish=finish) mr = ModelRegister() model = mr.get(model) looped = asyncio.new_event_loop() result = looped.run_until_complete(model.get_mp4_results(sq)) except ValueError as e: logger.error("ValueError") # result['error'] = json.dumps(e) # Return result as filename string # HUG will stream the binary data logger.debug(result) # TODO - Double Check model.code is always var_name of DataSet! return result
from serve.lfmc.models.ModelRegister import ModelRegister from serve.lfmc.models.rx.RegisterObserver import RegisterObserver mr = ModelRegister() ro = RegisterObserver() mr.subscribe(ro)