Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update /status response and docs #10189

Merged
merged 11 commits into from
Nov 12, 2021
1 change: 1 addition & 0 deletions changelog/10189.improvement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated the `/status` endpoint response payload, and relevant documentation, to return/reflect the updated 3.0 keys/values.
2 changes: 1 addition & 1 deletion docs/static/spec/rasa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ paths:
schema:
type: object
properties:
fingerprint:
model_id:
type: object
description: Fingerprint of the loaded model
example:
Expand Down
1 change: 1 addition & 0 deletions rasa/core/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def __init__(
self.action_endpoint = action_endpoint
self.model_metadata, self.graph_runner = self._load_model(model_path)
self.model_path = Path(model_path)
self.model_filename = os.path.basename(get_latest_model(Path(model_path)) or "")
self.domain = self.model_metadata.domain
self.http_interpreter = http_interpreter

Expand Down
5 changes: 2 additions & 3 deletions rasa/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,11 +684,10 @@ async def version(request: Request) -> HTTPResponse:
@ensure_loaded_agent(app)
async def status(request: Request) -> HTTPResponse:
"""Respond with the model name and the fingerprint of that model."""

return response.json(
{
"model_file": app.agent.model_name,
"fingerprint": app.agent.model_id,
"model_file": app.agent.processor.model_filename,
"model_id": app.agent.model_id,
"num_active_training_jobs": app.active_training_processes.value,
}
)
Expand Down
20 changes: 10 additions & 10 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ async def test_status(rasa_app: SanicASGITestClient, trained_rasa_model: Text):
_, response = await rasa_app.get("/status")
model_file = response.json["model_file"]
assert response.status == HTTPStatus.OK
assert "fingerprint" in response.json
assert "model_id" in response.json
assert model_file == Path(trained_rasa_model).name


Expand All @@ -183,7 +183,7 @@ async def test_status_nlu_only(
_, response = await rasa_app_nlu.get("/status")
model_file = response.json["model_file"]
assert response.status == HTTPStatus.OK
assert "fingerprint" in response.json
assert "model_id" in response.json
assert "model_file" in response.json
assert model_file == Path(trained_nlu_model).name

Expand Down Expand Up @@ -1509,9 +1509,9 @@ async def test_load_model(rasa_app: SanicASGITestClient, trained_core_model: Tex
_, response = await rasa_app.get("/status")

assert response.status == HTTPStatus.OK
assert "fingerprint" in response.json
assert "model_id" in response.json

old_fingerprint = response.json["fingerprint"]
old_model_id = response.json["model_id"]

data = {"model_file": trained_core_model}
_, response = await rasa_app.put("/model", json=data)
Expand All @@ -1521,9 +1521,9 @@ async def test_load_model(rasa_app: SanicASGITestClient, trained_core_model: Tex
_, response = await rasa_app.get("/status")

assert response.status == HTTPStatus.OK
assert "fingerprint" in response.json
assert "model_id" in response.json

assert old_fingerprint != response.json["fingerprint"]
assert old_model_id != response.json["model_id"]


async def test_load_model_from_model_server(
Expand All @@ -1532,9 +1532,9 @@ async def test_load_model_from_model_server(
_, response = await rasa_app.get("/status")

assert response.status == HTTPStatus.OK
assert "fingerprint" in response.json
assert "model_id" in response.json

old_fingerprint = response.json["fingerprint"]
old_model_id = response.json["model_id"]

endpoint = EndpointConfig("https://example.com/model/trained_core_model")
with open(trained_core_model, "rb") as f:
Expand All @@ -1559,9 +1559,9 @@ async def test_load_model_from_model_server(
_, response = await rasa_app.get("/status")

assert response.status == HTTPStatus.OK
assert "fingerprint" in response.json
assert "model_id" in response.json

assert old_fingerprint != response.json["fingerprint"]
assert old_model_id != response.json["model_id"]


async def test_load_model_invalid_request_body(
Expand Down