Skip to content

Commit

Permalink
Update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
PeiwenGaoMS committed Dec 7, 2023
1 parent 0c4d59f commit a68c061
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import multiprocessing
import threading
import time
from pathlib import Path
from tempfile import mkdtemp
from typing import Optional, Tuple, Union
Expand Down Expand Up @@ -47,17 +46,14 @@ def test_batch_cancel(self):
assert batch_engine._is_canceled is False
batch_run_thread.start()
# cancel the batch run
time.sleep(10)
batch_engine.cancel()
batch_run_thread.join()
assert batch_engine._is_canceled is True
assert batch_result_global.status == Status.Canceled
assert batch_result_global.system_metrics.duration > 0
# there exists some completed lines before the cancellation
assert batch_result_global.total_lines > 0

def _submit_batch_run(
self, run_in_thread=False, has_error=False, input_file_name="inputs.jsonl"
self, run_in_thread=False, has_error=False
) -> Union[Tuple[BatchEngine, threading.Thread], Tuple[BatchEngine, BatchResult]]:
flow_folder = "csharp_flow"
mem_run_storage = MemoryRunStorage()
Expand All @@ -66,7 +62,7 @@ def _submit_batch_run(
get_yaml_file(flow_folder), get_flow_folder(flow_folder), storage=mem_run_storage, has_error=has_error
)
# prepare the inputs
input_dirs = {"data": get_flow_inputs_file(flow_folder, file_name=input_file_name)}
input_dirs = {"data": get_flow_inputs_file(flow_folder)}
inputs_mapping = {"question": "${data.question}"}
output_dir = Path(mkdtemp())
if run_in_thread:
Expand Down
3 changes: 0 additions & 3 deletions src/promptflow/tests/executor/mock_execution_server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import asyncio
import json
import random
from functools import partial

from aiohttp import web
Expand All @@ -24,7 +22,6 @@ async def _handle_health(request: web.Request):
async def _handle_execution(request: web.Request, has_error=False):
try:
request = await request.json()
await asyncio.sleep(random.uniform(0, 3))
return _get_execution_result(request, has_error=has_error)
except json.JSONDecodeError:
return web.Response(status=400, text="Bad Request: Invalid JSON")
Expand Down

This file was deleted.

0 comments on commit a68c061

Please sign in to comment.