Skip to content

Commit

Permalink
Cleanup datamodel - remove unused properties, and add better descript…
Browse files Browse the repository at this point in the history
…ions, and add None description instead of empty string
  • Loading branch information
scosman committed Nov 12, 2024
1 parent 755597f commit d338e67
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
13 changes: 8 additions & 5 deletions libs/core/kiln_ai/datamodel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,15 @@ class Task(
"""

name: str = NAME_FIELD
description: str = Field(default="")
priority: Priority = Field(default=Priority.p2)
determinism: TaskDeterminism = Field(default=TaskDeterminism.flexible)
instruction: str = Field(min_length=1)
description: str | None = Field(
default=None,
description="A description of the task for you and your team. Will not be used in prompts/training/validation.",
)
instruction: str = Field(
min_length=1,
description="The instructions for the task. Will be used in prompts/training/validation.",
)
requirements: List[TaskRequirement] = Field(default=[])
# TODO: make this required, or formalize the default message output schema
output_json_schema: JsonObjectSchema | None = None
input_json_schema: JsonObjectSchema | None = None
thinking_instruction: str | None = Field(
Expand Down
8 changes: 1 addition & 7 deletions libs/core/kiln_ai/datamodel/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ def test_save_to_file(test_project_file):

def test_task_defaults():
task = Task(name="Test Task", instruction="Test Instruction")
assert task.description == ""
assert task.priority == Priority.p2
assert task.determinism == TaskDeterminism.flexible
assert task.description is None


def test_task_serialization(test_project_file):
Expand All @@ -82,8 +80,6 @@ def test_task_serialization(test_project_file):
parent=project,
name="Test Task",
description="Test Description",
determinism=TaskDeterminism.semantic_match,
priority=Priority.p0,
instruction="Test Base Task Instruction",
thinking_instruction="Test Thinking Instruction",
)
Expand All @@ -95,8 +91,6 @@ def test_task_serialization(test_project_file):
assert parsed_task.description == "Test Description"
assert parsed_task.instruction == "Test Base Task Instruction"
assert parsed_task.thinking_instruction == "Test Thinking Instruction"
assert parsed_task.determinism == TaskDeterminism.semantic_match
assert parsed_task.priority == Priority.p0


def test_save_to_file_without_path():
Expand Down
4 changes: 0 additions & 4 deletions libs/server/kiln_server/test_task_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def test_create_task_success(client, tmp_path):
assert res["name"] == "Test Task"
assert res["description"] == "This is a test task"
assert res["id"] is not None
assert res["priority"] == 2

# Verify that project_from_id was called with the correct argument
mock_project_from_id.assert_called_once_with("project1-id")
Expand Down Expand Up @@ -131,7 +130,6 @@ def test_create_task_real_project(client, tmp_path):
assert res["description"] == "This is a real task"
assert res["instruction"] == "Task instruction"
assert res["id"] is not None
assert res["priority"] == 2

# Verify the task file on disk
task_from_disk = project.tasks()[0]
Expand All @@ -140,7 +138,6 @@ def test_create_task_real_project(client, tmp_path):
assert task_from_disk.description == "This is a real task"
assert task_from_disk.instruction == "Task instruction"
assert task_from_disk.id == res["id"]
assert task_from_disk.priority == 2

# now post again, with an update
update_data = {
Expand All @@ -162,7 +159,6 @@ def test_create_task_real_project(client, tmp_path):
)
assert task_from_disk_reloaded.id == task_from_disk.id
assert task_from_disk_reloaded.instruction == "Task instruction"
assert task_from_disk_reloaded.priority == 2
assert task_from_disk_reloaded.name == "Real Task"
assert task_from_disk_reloaded.id == task_from_disk.id

Expand Down

0 comments on commit d338e67

Please sign in to comment.