Skip to content

Commit 6a4a9de

Browse files
authored
Fix: allow create dataset with resume chunk_method (#13798)
### What problem does this PR solve? Allow create dataset with resume chunk_method. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
1 parent 8402fca commit 6a4a9de

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

api/utils/validation_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,8 @@ def validate_parser_dependency(self) -> "CreateDatasetReq":
652652
@classmethod
653653
def validate_chunk_method(cls, v: Any, handler) -> Any:
654654
"""Wrap validation to unify error messages, including type errors (e.g. list)."""
655-
allowed = {"naive", "book", "email", "laws", "manual", "one", "paper", "picture", "presentation", "qa", "table", "tag"}
656-
error_msg = "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'"
655+
allowed = {"naive", "book", "email", "laws", "manual", "one", "paper", "picture", "presentation", "qa", "table", "tag", "resume"}
656+
error_msg = "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table', 'tag' or 'resume'"
657657
# Omitted field: handler won't be invoked (wrap still gets value); None treated as explicit invalid
658658
if v is None:
659659
raise PydanticCustomError("literal_error", error_msg)

test/testcases/test_http_api/test_dataset_management/test_create_dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def test_chunk_method_invalid(self, HttpApiAuth, name, chunk_method):
381381
payload = {"name": name, "chunk_method": chunk_method}
382382
res = create_dataset(HttpApiAuth, payload)
383383
assert res["code"] == 101, res
384-
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in res["message"], res
384+
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table', 'tag' or 'resume'" in res["message"], res
385385

386386
@pytest.mark.p2
387387
def test_chunk_method_unset(self, HttpApiAuth):
@@ -395,7 +395,7 @@ def test_chunk_method_none(self, HttpApiAuth):
395395
payload = {"name": "chunk_method_none", "chunk_method": None}
396396
res = create_dataset(HttpApiAuth, payload)
397397
assert res["code"] == 101, res
398-
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in res["message"], res
398+
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table', 'tag' or 'resume'" in res["message"], res
399399

400400
@pytest.mark.p1
401401
@pytest.mark.parametrize(

test/testcases/test_http_api/test_dataset_management/test_update_dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,15 +460,15 @@ def test_chunk_method_invalid(self, HttpApiAuth, add_dataset_func, chunk_method)
460460
payload = {"chunk_method": chunk_method}
461461
res = update_dataset(HttpApiAuth, dataset_id, payload)
462462
assert res["code"] == 101, res
463-
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in res["message"], res
463+
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table', 'tag' or 'resume'" in res["message"], res
464464

465465
@pytest.mark.p3
466466
def test_chunk_method_none(self, HttpApiAuth, add_dataset_func):
467467
dataset_id = add_dataset_func
468468
payload = {"chunk_method": None}
469469
res = update_dataset(HttpApiAuth, dataset_id, payload)
470470
assert res["code"] == 101, res
471-
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in res["message"], res
471+
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table', 'tag' or 'resume'" in res["message"], res
472472

473473
@pytest.mark.skipif(os.getenv("DOC_ENGINE") == "infinity", reason="#8208")
474474
@pytest.mark.p2

test/testcases/test_sdk_api/test_dataset_mangement/test_create_dataset.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,9 @@ def test_permission_none(self, client):
306306
("qa", "qa"),
307307
("table", "table"),
308308
("tag", "tag"),
309+
("resume", "resume")
309310
],
310-
ids=["naive", "book", "email", "laws", "manual", "one", "paper", "picture", "presentation", "qa", "table", "tag"],
311+
ids=["naive", "book", "email", "laws", "manual", "one", "paper", "picture", "presentation", "qa", "table", "tag", "resume"],
311312
)
312313
def test_chunk_method(self, client, name, chunk_method):
313314
payload = {"name": name, "chunk_method": chunk_method}
@@ -327,7 +328,7 @@ def test_chunk_method_invalid(self, client, name, chunk_method):
327328
payload = {"name": name, "chunk_method": chunk_method}
328329
with pytest.raises(Exception) as exception_info:
329330
client.create_dataset(**payload)
330-
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in str(exception_info.value), str(exception_info.value)
331+
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table', 'tag' or 'resume'" in str(exception_info.value), str(exception_info.value)
331332

332333
@pytest.mark.p2
333334
def test_chunk_method_unset(self, client):

test/testcases/test_sdk_api/test_dataset_mangement/test_update_dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,14 @@ def test_chunk_method_invalid(self, add_dataset_func, chunk_method):
320320
dataset = add_dataset_func
321321
with pytest.raises(Exception) as exception_info:
322322
dataset.update({"chunk_method": chunk_method})
323-
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in str(exception_info.value), str(exception_info.value)
323+
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table', 'tag' or 'resume'" in str(exception_info.value), str(exception_info.value)
324324

325325
@pytest.mark.p3
326326
def test_chunk_method_none(self, add_dataset_func):
327327
dataset = add_dataset_func
328328
with pytest.raises(Exception) as exception_info:
329329
dataset.update({"chunk_method": None})
330-
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in str(exception_info.value), str(exception_info.value)
330+
assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table', 'tag' or 'resume'" in str(exception_info.value), str(exception_info.value)
331331

332332
@pytest.mark.skipif(os.getenv("DOC_ENGINE") == "infinity", reason="#8208")
333333
@pytest.mark.p2

0 commit comments

Comments
 (0)