Skip to content

Commit

Permalink
warn when using the name parameter with task created from @task d…
Browse files Browse the repository at this point in the history
…ecorated function (#202)
  • Loading branch information
jjallaire authored Aug 6, 2024
1 parent fd87755 commit 568e1db
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Log viewer: Ctrl/Cmd+F to find text when running in VS Code.
- Set Claude default `max_tokens` to 4096
- Combine user and assistant messages for Vertex models.
- Warn when using the `name` parameter with task created from `@task` decorated function.

## v0.3.20 (03 August 2024)

Expand Down
20 changes: 17 additions & 3 deletions src/inspect_ai/_eval/task/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pydantic import BaseModel
from typing_extensions import TypedDict, Unpack

from inspect_ai._util.logger import warn_once
from inspect_ai._util.registry import is_registry_object, registry_info
from inspect_ai.dataset import Dataset, MemoryDataset, Sample
from inspect_ai.log import EvalLog
Expand Down Expand Up @@ -108,10 +109,23 @@ def __init__(

@property
def name(self) -> str:
if self._name is not None:
if is_registry_object(self):
# lookup name in registry
name = registry_info(self).name

# warn if a custom name was added, as this will make it
# impossible find the task for retrying
if self._name is not None:
warn_once(
logger,
f"Ignoring name=\"{self._name}\" parameter for registered task '{name}' "
+ f'(tasks decorated with @task should not use the name parameter, use @task(name="{self._name}") instead).',
)

# return the name
return name
elif self._name is not None:
return self._name
elif is_registry_object(self):
return registry_info(self).name
else:
return "task"

Expand Down

0 comments on commit 568e1db

Please sign in to comment.