MCPcopy
hub / github.com/RasaHQ/rasa / test_train_nlu_success

Function test_train_nlu_success

tests/test_server.py:330–365  ·  view source on GitHub ↗
(
    rasa_app: SanicASGITestClient,
    stack_config_path: Text,
    nlu_data_path: Text,
    domain_path: Text,
    tmp_path_factory: TempPathFactory,
)

Source from the content-addressed store, hash-verified

328
329
330async def test_train_nlu_success(
331 rasa_app: SanicASGITestClient,
332 stack_config_path: Text,
333 nlu_data_path: Text,
334 domain_path: Text,
335 tmp_path_factory: TempPathFactory,
336):
337 domain_data = rasa.shared.utils.io.read_yaml_file(domain_path)
338 config_data = rasa.shared.utils.io.read_yaml_file(stack_config_path)
339 nlu_data = rasa.shared.utils.io.read_yaml_file(nlu_data_path)
340
341 # combine all data into our payload
342 payload = {
343 key: val for d in [domain_data, config_data, nlu_data] for key, val in d.items()
344 }
345
346 data = StringIO()
347 rasa.shared.utils.io.write_yaml(payload, data)
348
349 _, response = await rasa_app.post(
350 "/model/train",
351 data=data.getvalue(),
352 headers={"Content-type": rasa.server.YAML_CONTENT_TYPE},
353 )
354 assert response.status == HTTPStatus.OK
355
356 # save model to temporary file
357 model_path = str(Path(tmp_path_factory.mktemp("model_dir")) / "model.tar.gz")
358 with open(model_path, "wb") as f:
359 f.write(response.body)
360
361 storage_path = tmp_path_factory.mktemp("storage_path")
362 model_storage, model_metadata = LocalModelStorage.from_model_archive(
363 storage_path, model_path
364 )
365 assert model_metadata.model_id
366
367
368async def test_train_core_success_with(

Callers

nothing calls this directly

Calls 2

itemsMethod · 0.80
from_model_archiveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…