Skip to content

Commit

Permalink
fixexception
Browse files Browse the repository at this point in the history
  • Loading branch information
huijunw committed Aug 25, 2018
1 parent 55ac866 commit dd245ec
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions api/model/topology/heron.py
Expand Up @@ -64,16 +64,12 @@ def __init__(self, model_classes: List[Type], model_config: Dict[str, Any],

super().__init__()

def post(self) -> Tuple[Dict[str, Any], int]:
def post(self, topology_id: str) -> Tuple[Dict[str, Any], int]:
""" Method handling POST requests to the current topology performance
modelling endpoint."""

# Make sure we have the args we need
errors: List[Dict[str, str]] = []
if "topology_id" not in request.args:
errors.append({"type": "MissingParameter",
"error": ("'topology_id' parameter should be "
"supplied")})
if "cluster" not in request.args:
errors.append({"type": "MissingParameter",
"error": "'cluster' parameter should be supplied"})
Expand All @@ -94,7 +90,7 @@ def post(self) -> Tuple[Dict[str, Any], int]:

LOG.info("Processing performance modelling request for topology: %s, "
"cluster: %s, environment: %s, using model: %s",
request.args.get("topology_id"), request.args.get("cluster"),
topology_id, request.args.get("cluster"),
request.args.get("environ"),
str(request.args.getlist("model")))

Expand All @@ -103,11 +99,11 @@ def post(self) -> Tuple[Dict[str, Any], int]:
try:
graph_check(self.graph_client, self.model_config, self.tracker_url,
request.args["cluster"], request.args["environ"],
request.args["topology_id"])
topology_id)
except Exception as err:
LOG.error("Error running graph check for topology: %s -> %s",
request.args["topology_id"], str(err))
errors.append({"topology": request.args["topology_id"],
topology_id, str(err))
errors.append({"topology": topology_id,
"type": str(type(err)),
"error": str(err)})
return {"errors": errors}, 400
Expand All @@ -134,10 +130,8 @@ def post(self) -> Tuple[Dict[str, Any], int]:
model_kwargs.pop("model")
model_kwargs.pop("cluster")
model_kwargs.pop("environ")
model_kwargs.pop("topology_id")
cluster = request.args.get("cluster")
environ = request.args.get("environ")
topology_id = request.args.get("topology_id")

output = {}
for model_name in models:
Expand Down

0 comments on commit dd245ec

Please sign in to comment.