b7222818e9dd4d33ee933388e73a11ad8d0bf89b,tests/helper_functions.py,,score_model_in_sagemaker_docker_container,#Any#Any#,24
Before Change
proc = Popen(["mlflow", "sagemaker", "run-local", "-m", model_path], stdout=PIPE, stderr=STDOUT,
universal_newlines=True, env=env)
try:
for i in range(0, 50):
assert proc.poll() is None, "scoring process died"
time.sleep(5)
// noinspection PyBroadException
try:
ping_status = requests.get(url="http://localhost:5000/ping")
print("connection attempt", i, "server is up! ping status", ping_status)
if ping_status.status_code == 200:
break
except Exception: // pylint: disable=broad-except
print("connection attempt", i, "failed, server is not up yet")
assert proc.poll() is None, "scoring process died"
ping_status = requests.get(url="http://localhost:5000/ping")
print("server up, ping status", ping_status)
if ping_status.status_code != 200:
raise Exception("ping failed, server is not happy")
if type(data) == pd.DataFrame:
data = data.to_dict(orient="records")
y = requests.post(url="http://localhost:5000/invocations", json=data)
import json
return json.loads(y.content )
finally:
if proc.poll() is None:
proc.terminate()
After Change
universal_newlines=True, env=env)
r = _score_proc(proc, 5000, data, "json").content
import json
return json.loads(r) // TODO: we should return pd.Dataframe the same as pyfunc serve
def pyfunc_serve_and_score_model(model_path, data):
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 11
Instances Project Name: mlflow/mlflow
Commit Name: b7222818e9dd4d33ee933388e73a11ad8d0bf89b
Time: 2018-09-06
Author: 33237569+tomasatdatabricks@users.noreply.github.com
File Name: tests/helper_functions.py
Class Name:
Method Name: score_model_in_sagemaker_docker_container
Project Name: home-assistant/home-assistant
Commit Name: 7bf7c727d1582fb82ac726a41fbd04d587a2fd5c
Time: 2017-02-10
Author: pschmitt@users.noreply.github.com
File Name: homeassistant/components/zoneminder.py
Class Name:
Method Name: get_state
Project Name: home-assistant/home-assistant
Commit Name: 4c5e6399e9163c564992e20fec837cacb506533f
Time: 2017-02-09
Author: pschmitt@users.noreply.github.com
File Name: homeassistant/components/zoneminder.py
Class Name:
Method Name: get_state