fix(actor): repair list_actors lock-filter test fixtures (#8588)
Address CI lint + unit_tests failures on the namespace-lock test suite:
- Step file: drop unused imports (yaml, ExitStack, ValidationError) and
unused noqa directives flagged by ruff F401/RUF100; rewrite the
collected-errors list to use iterable unpacking (RUF005); register the
"I create an ActorLoader with initial actors from multiple namespaces"
step under both @given and @when so scenario 3 is no longer reported as
undefined; remove the dead _error_collector inner function the reviewer
flagged.
- Step regex fix: the concurrent-modifications step pattern ended with
'' (two single quotes) instead of `` (two backticks), so it never
matched the feature file's `(triggering ``discover()``)` literal.
- Test fixtures: add the required `description` field to _make_actor_yaml
in both the BDD step file and tests/actor/test_loader_list_actors_thread_safety.py
so ActorConfigSchema validation passes (previously every scenario
errored at discover() with "description: Field required").
- Concurrent worker names: collapse three-slash actor names like
"conc/ns{i % 2}/concurrent_{i}" to the single-slash form
"conc/concurrent_{i}" required by the schema's namespaced-name rule.
- Test file: drop unused `yaml` import and three unused F841 assignments
in _list_worker; apply ruff format.
- Feature file: switch the @issue_8660 TDD tag to @tdd_issue_8588 to
match the CONTRIBUTING.md tag convention for the bug issue this PR
closes.
ISSUES CLOSED: #8588
This commit is contained in:
@@ -13,14 +13,13 @@ import threading
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
from cleveragents.actor.loader import ActorLoader
|
||||
|
||||
|
||||
def _make_actor_yaml(name: str, provider: str = "openai", model: str = "gpt-4") -> str:
|
||||
return f"""name: {name}
|
||||
type: llm
|
||||
description: Test actor {name}
|
||||
provider: {provider}
|
||||
model: {model}
|
||||
tools: []
|
||||
@@ -60,7 +59,9 @@ class TestListActorsThreadSafety:
|
||||
try:
|
||||
for i in range(20):
|
||||
extra_file = root / f"extra_{i}.yaml"
|
||||
extra_file.write_text(_make_actor_yaml(f"conc/ns{i % 2}/thread_{i}"))
|
||||
extra_file.write_text(
|
||||
_make_actor_yaml(f"conc/thread_{i}")
|
||||
)
|
||||
loader.discover()
|
||||
time.sleep(0.01)
|
||||
if extra_file.exists():
|
||||
@@ -115,9 +116,9 @@ class TestListActorsThreadSafety:
|
||||
def _list_worker() -> None:
|
||||
try:
|
||||
for _ in range(30):
|
||||
all_actors = loader.list_actors()
|
||||
local = loader.list_actors(namespace="local")
|
||||
remote = loader.list_actors(namespace="remote")
|
||||
loader.list_actors()
|
||||
loader.list_actors(namespace="local")
|
||||
loader.list_actors(namespace="remote")
|
||||
time.sleep(0.01)
|
||||
except Exception as exc:
|
||||
errors.append(exc)
|
||||
@@ -141,7 +142,9 @@ class TestListActorsThreadSafety:
|
||||
def _add_actor() -> None:
|
||||
try:
|
||||
for i in range(20):
|
||||
(root / f"new_{i}.yaml").write_text(_make_actor_yaml(f"conc/new_{i}"))
|
||||
(root / f"new_{i}.yaml").write_text(
|
||||
_make_actor_yaml(f"conc/new_{i}")
|
||||
)
|
||||
loader.discover()
|
||||
time.sleep(0.01)
|
||||
if (root / f"new_{i}.yaml").exists():
|
||||
@@ -172,4 +175,5 @@ class TestListActorsThreadSafety:
|
||||
|
||||
if __name__ == "__main__": # pragma: no cover
|
||||
import pytest
|
||||
|
||||
pytest.main([__file__, "-v"])
|
||||
|
||||
Reference in New Issue
Block a user