MCPcopy
hub / github.com/QData/TextAttack / run

Method run

textattack/commands/attack_resume_command.py:23–44  ·  view source on GitHub ↗
(self, args)

Source from the content-addressed store, hash-verified

21 """
22
23 def run(self, args):
24 checkpoint = self._parse_checkpoint_from_args(args)
25 assert isinstance(checkpoint.attack_args, CommandLineAttackArgs), (
26 f"Expect `attack_args` to be of type `textattack.args.CommandLineAttackArgs`, but got type `{type(checkpoint.attack_args)}`. "
27 f"If saved `attack_args` is not of type `textattack.args.CommandLineAttackArgs`, cannot resume attack from command line."
28 )
29 # merge/update arguments
30 checkpoint.attack_args.parallel = args.parallel
31 if args.checkpoint_dir:
32 checkpoint.attack_args.checkpoint_dir = args.checkpoint_dir
33 if args.checkpoint_interval:
34 checkpoint.attack_args.checkpoint_interval = args.checkpoint_interval
35
36 model_wrapper = ModelArgs._create_model_from_args(
37 checkpoint.attack_args.attack_args
38 )
39 attack = CommandLineAttackArgs._create_attack_from_args(
40 checkpoint.attack_args, model_wrapper
41 )
42 dataset = DatasetArgs.parse_dataset_from_args(checkpoint.attack_args)
43 attacker = Attacker.from_checkpoint(attack, dataset, checkpoint)
44 attacker.attack_dataset()
45
46 def _parse_checkpoint_from_args(self, args):
47 file_name = os.path.basename(args.checkpoint_file)

Callers

nothing calls this directly

Calls 5

from_checkpointMethod · 0.80
attack_datasetMethod · 0.80

Tested by

no test coverage detected