Skip to content
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

List of attack clients #608

Open
dalqattan opened this issue May 22, 2023 · 8 comments
Open

List of attack clients #608

dalqattan opened this issue May 22, 2023 · 8 comments

Comments

@dalqattan
Copy link

Hi

I have tried to add list of attack id but I got type mismatch error.

(fs) PS C:\temp\FederatedScope-backdoor-bench> python federatedscope/main.py --cfg scripts/backdoor_scripts/attack_config/backdoor_fedavg_convnet2_on_femnist.yaml
Namespace(cfg_file='scripts/backdoor_scripts/attack_config/backdoor_fedavg_convnet2_on_femnist.yaml', client_cfg_file=None, opts=[])
Traceback (most recent call last):
File "C:\temp\FederatedScope-backdoor-bench\federatedscope\main.py", line 29, in
init_cfg.merge_from_file(args.cfg_file)
File "C:\Users\b8059713\Anaconda3\envs\fs\lib\site-packages\federatedscope-0.1.0-py3.9.egg\federatedscope\core\configs\config.py", line 41, in merge_from_file
super(CN, self).merge_from_file(cfg_filename)
File "C:\Users\b8059713\Anaconda3\envs\fs\lib\site-packages\yacs\config.py", line 213, in merge_from_file
self.merge_from_other_cfg(cfg)
File "C:\Users\b8059713\Anaconda3\envs\fs\lib\site-packages\federatedscope-0.1.0-py3.9.egg\federatedscope\core\configs\config.py", line 51, in merge_from_other_cfg
super(CN, self).merge_from_other_cfg(cfg_other)
File "C:\Users\b8059713\Anaconda3\envs\fs\lib\site-packages\yacs\config.py", line 217, in merge_from_other_cfg
_merge_a_into_b(cfg_other, self, self, [])
File "C:\Users\b8059713\Anaconda3\envs\fs\lib\site-packages\yacs\config.py", line 478, in _merge_a_into_b
_merge_a_into_b(v, b[k], root, key_list + [k])
File "C:\Users\b8059713\Anaconda3\envs\fs\lib\site-packages\yacs\config.py", line 474, in _merge_a_into_b
v = _check_and_coerce_cfg_value_type(v, b[k], k, full_key)
File "C:\Users\b8059713\Anaconda3\envs\fs\lib\site-packages\yacs\config.py", line 534, in _check_and_coerce_cfg_value_type
raise ValueError(
ValueError: Type mismatch (<class 'int'> vs. <class 'list'>) with values (-1 vs. [1, 2, 3, 4, 5]) for config key: attack.attacker_id

Thanks

Duaa

@rayrayraykk
Copy link
Collaborator

You could change

cfg.attack.attacker_id = -1

to

cfg.attack.attacker_id = [-1]

to avoid ValueError .

@dalqattan
Copy link
Author

You could change

cfg.attack.attacker_id = -1

to

cfg.attack.attacker_id = [-1]

to avoid ValueError .

Thanks for your reply.
However, I need to simulate multi-client attack so that I have to list all the attack clients' id in a list (e.g. [1, 2, 3, 4, 5]).

@rayrayraykk
Copy link
Collaborator

You could change

cfg.attack.attacker_id = -1

to

cfg.attack.attacker_id = [-1]

to avoid ValueError .

Thanks for your reply. However, I need to simulate multi-client attack so that I have to list all the attack clients' id in a list (e.g. [1, 2, 3, 4, 5]).

Yes, you should change the type of cfg.attack.attacker_id from int to list to avoid ValueError: Type mismatch (<class 'int'> vs. <class 'list'>) with values (-1 vs. [1, 2, 3, 4, 5]) for config key: attack.attacker_id.

@dalqattan
Copy link
Author

cfg.attack.attacker_id = [-1]

Hi
I did it but still got same error.

Do you have any idea?

Thanks

@rayrayraykk
Copy link
Collaborator

cfg.attack.attacker_id = [-1]

Hi I did it but still got same error.

Do you have any idea?

Thanks

Try to re-install FS with editable mode via pip install -e .

@dalqattan
Copy link
Author

dalqattan commented Jun 1, 2023

@rayrayraykk
Hi
I re-installed it.
But still I got a sequence of error messages starting from poisoning_data.py and server_attacker.py and then fed_runner.py . I tried to fix by converting commands to read from a list but it doesn't work it seems FS has not been configured to read from a list of id attacker.

@Osier-Yi
Copy link
Collaborator

Osier-Yi commented Jun 1, 2023

@rayrayraykk Hi I re-installed it. But still I got a sequence of error messages starting from poisoning_data.py and server_attacker.py and then fed_runner.py . I tried to fix by converting commands to read from a list but it doesn't work it seems FS has not been configured to read from a list of id attacker.

try: change '==' to 'in' in line

since ctx.attack.attacker_id is now a list type not the original int type.

Please double check other files that use attacker_id.

@dalqattan
Copy link
Author

@rayrayraykk Hi I re-installed it. But still I got a sequence of error messages starting from poisoning_data.py and server_attacker.py and then fed_runner.py . I tried to fix by converting commands to read from a list but it doesn't work it seems FS has not been configured to read from a list of id attacker.

try: change '==' to 'in' in line

since ctx.attack.attacker_id is now a list type not the original int type.
Please double check other files that use attacker_id.

Yes, I did already.

And then got this error

File "c:\temp\federatedscope-backdoor-bench\federatedscope\attack\worker_as_attacker\server_attacker.py", line 68, in broadcast_model_para
    self._cfg.attack.attacker_id - 1)
TypeError: unsupported operand type(s) for -: 'list' and 'int'

I fixed it with

[x - 1 for x in self._cfg.attack.attacker_id])

Then

File "c:\temp\federatedscope-backdoor-bench\federatedscope\attack\worker_as_attacker\server_attacker.py", line 75, in broadcast_model_para 'starting the poisoning round: {:d}, the attacker ID: {:d}' TypeError: unsupported format string passed to list.__format_

And then

File "c:\temp\federatedscope-backdoor-bench\federatedscope\core\fed_runner.py", line 273, in _handle_msg self.client[each_receiver].msg_handlers[msg.msg_type](msg) TypeError: unhashable type: 'list'
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants