forked from phoenix-oss/llama-stack-mirror
Fix precommit check after moving to ruff (#927)
Lint check in main branch is failing. This fixes the lint check after we moved to ruff in https://github.com/meta-llama/llama-stack/pull/921. We need to move to a `ruff.toml` file as well as fixing and ignoring some additional checks. Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
This commit is contained in:
parent
4773092dd1
commit
34ab7a3b6c
217 changed files with 981 additions and 2681 deletions
|
@ -15,18 +15,13 @@ from typing import Any, Mapping
|
|||
from llama_stack.providers.utils.common.data_schema_validator import ColumnName
|
||||
|
||||
|
||||
def llama_stack_instruct_to_torchtune_instruct(
|
||||
sample: Mapping[str, Any]
|
||||
) -> Mapping[str, Any]:
|
||||
assert (
|
||||
ColumnName.chat_completion_input.value in sample
|
||||
and ColumnName.expected_answer.value in sample
|
||||
), "Invalid input row"
|
||||
def llama_stack_instruct_to_torchtune_instruct(sample: Mapping[str, Any]) -> Mapping[str, Any]:
|
||||
assert ColumnName.chat_completion_input.value in sample and ColumnName.expected_answer.value in sample, (
|
||||
"Invalid input row"
|
||||
)
|
||||
input_messages = eval(str(sample[ColumnName.chat_completion_input.value]))
|
||||
|
||||
assert (
|
||||
len(input_messages) == 1
|
||||
), "llama stack intruct dataset format only supports 1 user message"
|
||||
assert len(input_messages) == 1, "llama stack intruct dataset format only supports 1 user message"
|
||||
input_message = input_messages[0]
|
||||
|
||||
assert "content" in input_message, "content not found in input message"
|
||||
|
@ -48,13 +43,9 @@ def llama_stack_chat_to_torchtune_chat(sample: Mapping[str, Any]) -> Mapping[str
|
|||
roles = []
|
||||
conversations = []
|
||||
for message in dialog:
|
||||
assert (
|
||||
"role" in message and "content" in message
|
||||
), "role and content must in message"
|
||||
assert "role" in message and "content" in message, "role and content must in message"
|
||||
roles.append(message["role"])
|
||||
conversations.append(
|
||||
{"from": role_map[message["role"]], "value": message["content"]}
|
||||
)
|
||||
conversations.append({"from": role_map[message["role"]], "value": message["content"]})
|
||||
|
||||
assert roles[0] == "user", "first message must be from user"
|
||||
assert "assistant" in roles, "at least 1 message should be from assistant"
|
||||
|
|
|
@ -61,8 +61,7 @@ class SFTDataset(Dataset):
|
|||
if not ("tokens" in tokenized_dict and "mask" in tokenized_dict):
|
||||
keys_str = ", ".join(tokenized_dict.keys())
|
||||
error_message = (
|
||||
"model_transform returned the following keys: "
|
||||
f"{keys_str}. Must return 'tokens' and 'mask' as keys."
|
||||
f"model_transform returned the following keys: {keys_str}. Must return 'tokens' and 'mask' as keys."
|
||||
)
|
||||
raise ValueError(error_message)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue