async def post_solve_watershed( watershed_pkg: Tuple[Dict[str, Any], Dict[str, Any]] = Depends(validate_watershed_request), ) -> Dict[str, Any]: watershed, context = watershed_pkg task = bg.background_solve_watershed.s(watershed=watershed, treatment_pre_validated=True, context=context) return run_task(task=task, router=router, get_route="get_watershed_result")
def test_run_task_by_name(subgraph_request_dict): graph, nodes = subgraph_request_dict["graph"], subgraph_request_dict[ "nodes"] task = bg.background_network_subgraphs.s(graph=graph, nodes=nodes) return utils.run_task(task=task, router=r"¯\_(ツ)_/¯", get_route=r"¯\_(ツ)_/¯", force_foreground=True)
async def calculate_loading( land_surfaces: LandSurfaces = Body( ..., example={ "land_surfaces": [ { "node_id": "1", "surface_key": "10101100-RESMF-A-5", "area_acres": 1.834347898661638, "imp_area_acres": 1.430224547955745, }, { "node_id": "0", "surface_key": "10101100-OSDEV-A-0", "area_acres": 4.458327528535912, "imp_area_acres": 0.4457209193544626, }, { "node_id": "0", "surface_key": "10101000-IND-A-10", "area_acres": 3.337086111390218, "imp_area_acres": 0.47675887386582366, }, { "node_id": "0", "surface_key": "10101100-COMM-C-0", "area_acres": 0.5641157902710026, "imp_area_acres": 0.40729090799199347, }, { "node_id": "1", "surface_key": "10101200-TRANS-C-5", "area_acres": 0.007787658410143283, "imp_area_acres": 0.007727004694355631, }, ] }, ), details: bool = False, context: dict = Depends(get_valid_context), ) -> Dict[str, Any]: land_surfaces_req = land_surfaces.dict(by_alias=True) task = bg.background_land_surface_loading.s( land_surfaces=land_surfaces_req, details=details, context=context ) return run_task( task=task, router=router, get_route="get_land_surface_loading_result" )
async def initialize_treatment_facility_parameters(tmnt_facility_req: Tuple[ TreatmentFacilitiesStrict, Dict[str, Any]] = Depends(validate_facility_request)) -> Dict[str, Any]: treatment_facilities, context = tmnt_facility_req task = bg.background_initialize_treatment_facilities.s( treatment_facilities=treatment_facilities.dict(), pre_validated=True, context=context, ) return run_task(task=task, router=router, get_route="get_treatment_facility_parameters")
async def validate_network(graph: network_models.Graph = Body( ..., example={ "directed": True, "nodes": [{ "id": "A" }, { "id": "B" }], "edges": [{ "source": "A", "target": "B" }], }, )) -> Dict[str, Any]: task = bg.background_validate_network.s(graph=graph.dict(by_alias=True)) return run_task(task=task, router=router, get_route="get_validate_network_result")
async def subgraph_network( graph: network_models.Graph = Body( ..., example={ "directed": True, "edges": [ { "source": "3", "target": "1" }, { "source": "5", "target": "3" }, { "source": "7", "target": "1" }, { "source": "9", "target": "1" }, { "source": "11", "target": "1" }, { "source": "13", "target": "3" }, { "source": "15", "target": "9" }, { "source": "17", "target": "7" }, { "source": "19", "target": "17" }, { "source": "21", "target": "15" }, { "source": "23", "target": "1" }, { "source": "25", "target": "5" }, { "source": "27", "target": "11" }, { "source": "29", "target": "7" }, { "source": "31", "target": "11" }, { "source": "33", "target": "25" }, { "source": "35", "target": "23" }, { "source": "4", "target": "2" }, { "source": "6", "target": "2" }, { "source": "8", "target": "6" }, { "source": "10", "target": "2" }, { "source": "12", "target": "2" }, { "source": "14", "target": "2" }, { "source": "16", "target": "12" }, { "source": "18", "target": "12" }, { "source": "20", "target": "8" }, { "source": "22", "target": "6" }, { "source": "24", "target": "12" }, ], }, ), nodes: List[network_models.Node] = Body( ..., example=[{ "id": "3" }, { "id": "29" }, { "id": "18" }], ), ) -> Dict[str, Any]: task = bg.background_network_subgraphs.s(graph=graph.dict(by_alias=True), nodes=jsonable_encoder(nodes)) return run_task(task=task, router=router, get_route="get_subgraph_network_result")
async def network_solution_sequence( graph: network_models.Graph = Body( ..., example={ "directed": True, "edges": [ { "source": "3", "target": "1" }, { "source": "5", "target": "3" }, { "source": "7", "target": "1" }, { "source": "9", "target": "1" }, { "source": "11", "target": "1" }, { "source": "13", "target": "3" }, { "source": "15", "target": "9" }, { "source": "17", "target": "7" }, { "source": "19", "target": "17" }, { "source": "21", "target": "15" }, { "source": "23", "target": "1" }, { "source": "25", "target": "5" }, { "source": "27", "target": "11" }, { "source": "29", "target": "7" }, { "source": "31", "target": "11" }, { "source": "33", "target": "25" }, { "source": "35", "target": "23" }, { "source": "4", "target": "2" }, { "source": "6", "target": "2" }, { "source": "8", "target": "6" }, { "source": "10", "target": "2" }, { "source": "12", "target": "2" }, { "source": "14", "target": "2" }, { "source": "16", "target": "12" }, { "source": "18", "target": "12" }, { "source": "20", "target": "8" }, { "source": "22", "target": "6" }, { "source": "24", "target": "12" }, ], }, ), min_branch_size: int = Query(4), ) -> Dict[str, Any]: task = bg.background_solution_sequence.s(graph=graph.dict(by_alias=True), min_branch_size=min_branch_size) return run_task(task=task, router=router, get_route="get_network_solution_sequence")