-
Notifications
You must be signed in to change notification settings - Fork 660
MAINT: Standardize scenario VERSION constant and replace asserts with proper lifecycle checks #1355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
78130f4
e1c86b2
ac78b46
3cd2d55
4290950
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,7 +60,8 @@ class Cyber(Scenario): | |
| techniques. | ||
| """ | ||
|
|
||
| version: int = 1 | ||
| VERSION: int = 1 | ||
| version: int = VERSION # Alias for backward compatibility | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should either If we
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would probably just get rid of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree since it's really really new. |
||
|
|
||
| @classmethod | ||
| def get_strategy_class(cls) -> type[ScenarioStrategy]: | ||
|
|
@@ -141,7 +142,7 @@ def __init__( | |
|
|
||
| super().__init__( | ||
| name="Cyber", | ||
| version=self.version, | ||
| version=self.VERSION, | ||
| strategy_class=CyberStrategy, | ||
| objective_scorer=objective_scorer, | ||
| include_default_baseline=include_baseline, | ||
|
|
@@ -241,10 +242,13 @@ def _get_atomic_attack_from_strategy(self, strategy: str) -> AtomicAttack: | |
| AtomicAttack: configured for the specified strategy. | ||
|
|
||
| Raises: | ||
| ValueError: if an unknown CyberStrategy is passed. | ||
| ValueError: If scenario is not properly initialized or an unknown CyberStrategy is passed. | ||
| """ | ||
| # objective_target is guaranteed to be non-None by parent class validation | ||
| assert self._objective_target is not None | ||
| if self._objective_target is None: | ||
| raise ValueError( | ||
| "Scenario not properly initialized. Call await scenario.initialize_async() before running." | ||
| ) | ||
| attack_strategy: Optional[AttackStrategy[Any, Any]] = None | ||
| if strategy == "single_turn": | ||
| attack_strategy = PromptSendingAttack( | ||
|
|
@@ -261,7 +265,8 @@ def _get_atomic_attack_from_strategy(self, strategy: str) -> AtomicAttack: | |
| raise ValueError(f"Unknown CyberStrategy: {strategy}") | ||
|
|
||
| # _seed_groups is guaranteed to be set by _get_atomic_attacks_async before this method is called | ||
| assert self._seed_groups is not None, "_seed_groups must be resolved before creating atomic attacks" | ||
| if self._seed_groups is None: | ||
| raise ValueError("_seed_groups must be resolved before creating atomic attacks") | ||
|
|
||
| return AtomicAttack( | ||
| atomic_attack_name=f"cyber_{strategy}", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Make sure that for each scenario you add the
ValueErroreach scenario raises to the function's docstring(s) to enforce ruff compliance.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added ValueError documentation to all 6 affected function docstrings across the scenario files for ruff compliance. (4290950)