feat(tuning): release V0.8.2 Agent 界面重构
This commit is contained in:
@@ -12,6 +12,7 @@ from tuning.schema import ( # noqa: E402
|
||||
RewardConfigError,
|
||||
merge_proposal,
|
||||
validate_configuration,
|
||||
validate_constraints,
|
||||
validate_proposal,
|
||||
)
|
||||
from tuning.scoring import ( # noqa: E402
|
||||
@@ -19,7 +20,7 @@ from tuning.scoring import ( # noqa: E402
|
||||
EvaluationError,
|
||||
score_evaluation,
|
||||
)
|
||||
from tuning.storage import TuningStorage # noqa: E402
|
||||
from tuning.storage import StorageConflict, TuningStorage # noqa: E402
|
||||
|
||||
|
||||
class RewardSchemaTest(unittest.TestCase):
|
||||
@@ -69,6 +70,33 @@ class RewardSchemaTest(unittest.TestCase):
|
||||
BASE_REWARD_CONFIGURATION,
|
||||
)
|
||||
|
||||
def test_session_constraints_reject_unknown_out_of_range_and_fixed_changes(self):
|
||||
constraints = validate_constraints(
|
||||
{
|
||||
"weights.track_linear_velocity": {"kind": "fixed", "value": 1.0},
|
||||
"params.foot_gait.period": {"kind": "range", "min": 0.5, "max": 0.7},
|
||||
}
|
||||
)
|
||||
validate_proposal(
|
||||
{"params": {"foot_gait.period": 0.65}},
|
||||
BASE_REWARD_CONFIGURATION,
|
||||
constraints,
|
||||
)
|
||||
with self.assertRaisesRegex(RewardConfigError, "已固定"):
|
||||
validate_proposal(
|
||||
{"weights": {"track_linear_velocity": 1.1}},
|
||||
BASE_REWARD_CONFIGURATION,
|
||||
constraints,
|
||||
)
|
||||
with self.assertRaisesRegex(RewardConfigError, "工程锁定范围"):
|
||||
validate_proposal(
|
||||
{"params": {"foot_gait.period": 0.75}},
|
||||
BASE_REWARD_CONFIGURATION,
|
||||
constraints,
|
||||
)
|
||||
with self.assertRaisesRegex(RewardConfigError, "未知参数约束"):
|
||||
validate_constraints({"weights.not_allowed": {"kind": "fixed", "value": 1.0}})
|
||||
|
||||
|
||||
class ScoringTest(unittest.TestCase):
|
||||
baseline = {
|
||||
@@ -174,8 +202,24 @@ class StorageTest(unittest.TestCase):
|
||||
self.assertEqual(sampled[0]["step"], 0)
|
||||
self.assertEqual(sampled[-1]["step"], 99)
|
||||
self.assertIn(50.0, [point["value"] for point in sampled])
|
||||
control = self.storage.replace_constraints(
|
||||
session["id"],
|
||||
0,
|
||||
{"weights.pose": {"kind": "range", "min": 0.5, "max": 1.5}},
|
||||
)
|
||||
self.assertEqual(control["constraintsRevision"], 1)
|
||||
with self.assertRaises(StorageConflict):
|
||||
self.storage.replace_constraints(session["id"], 0, {})
|
||||
self.storage.grant_dispatch_token(session["id"])
|
||||
with self.assertRaises(StorageConflict):
|
||||
self.storage.grant_dispatch_token(session["id"])
|
||||
self.assertTrue(self.storage.use_dispatch_token(session["id"]))
|
||||
self.assertFalse(self.storage.use_dispatch_token(session["id"]))
|
||||
incremental = self.storage.metrics(trial["id"], max_points=100, after_step=90)[0]
|
||||
self.assertEqual(incremental["points"][0]["step"], 91)
|
||||
reopened = TuningStorage(self.storage.path)
|
||||
self.assertEqual(reopened.get_session(session["id"])["mode"], "approval")
|
||||
self.assertEqual(reopened.get_control(session["id"])["constraintsRevision"], 1)
|
||||
|
||||
def test_recovery_marks_inflight_records(self):
|
||||
session = self.storage.create_session(
|
||||
|
||||
Reference in New Issue
Block a user