From 148e54717aa1e6eb34fbe343cbe7aafbb8385a86 Mon Sep 17 00:00:00 2001 From: araison Date: Tue, 31 Jan 2023 10:19:17 +0100 Subject: [PATCH] Adding Force FastForward method --- config_gen.py | 2 +- explaining_framework/utils/explaining/cmd_args.py | 6 ++++++ main.py | 6 ++++++ parallel.sh | 7 ++++--- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/config_gen.py b/config_gen.py index bb1fb6b..b1d05ba 100644 --- a/config_gen.py +++ b/config_gen.py @@ -48,7 +48,7 @@ def explaining_conf( explaining_cfg["explainer"] = {} explaining_cfg["explainer"]["cfg"] = explainer_config explaining_cfg["explainer"]["name"] = explainer - explaining_cfg["explainer"]["force"] = True + explaining_cfg["explainer"]["force"] = False explaining_cfg["explanation_type"] = "phenomenon" explaining_cfg["model"] = {} explaining_cfg["model"]["ckpt"] = model_kind diff --git a/explaining_framework/utils/explaining/cmd_args.py b/explaining_framework/utils/explaining/cmd_args.py index 2174a72..5213f93 100644 --- a/explaining_framework/utils/explaining/cmd_args.py +++ b/explaining_framework/utils/explaining/cmd_args.py @@ -17,5 +17,11 @@ def parse_args() -> argparse.Namespace: type=int, help="GPU ID if cuda available", ) + parser.add_argument( + "--force_fastforward", + type=bool, + help="It does not load file for elaredy existing files", + default=False, + ) return parser.parse_args() diff --git a/main.py b/main.py index fce377d..2e0a71b 100644 --- a/main.py +++ b/main.py @@ -38,6 +38,9 @@ if __name__ == "__main__": ) makedirs(attack_path) data_attack_path = os.path.join(attack_path, f"{index}.json") + if args.force_fastforward: + if os.path.exists(data_attack_path): + continue data_attack = outline.get_attack( attack=attack, item=item, path=data_attack_path ) @@ -66,6 +69,9 @@ if __name__ == "__main__": ) makedirs(attack_path_) data_attack_path_ = os.path.join(attack_path_, f"{index}.json") + if args.force_fastforward: + if os.path.exists(data_attack_path_): + continue attack_data = outline.get_attack( attack=attack, item=item, path=data_attack_path_ ) diff --git a/parallel.sh b/parallel.sh index 6fc7a92..cfe9d26 100644 --- a/parallel.sh +++ b/parallel.sh @@ -1,8 +1,9 @@ CONFIG_DIR=$1 MAX_JOBS=${2:-3} GPU=${3:-0} -SLEEP=${4:-1} -MAIN=${5:-main} +FFF=${4:-False} +SLEEP=${5:-1} +MAIN=${6:-main} ( trap 'kill 0' SIGINT @@ -11,7 +12,7 @@ MAIN=${5:-main} if [ "$CONFIG" != "$CONFIG_DIR/*.yaml" ]; then ((CUR_JOBS >= MAX_JOBS)) && wait -n export CUDA_VISIBLE_DEVICES=$GPU - python3 $MAIN.py --explaining_cfg $CONFIG --gpu_id $GPU & + python3 $MAIN.py --explaining_cfg $CONFIG --gpu_id $GPU --force-fastforward $FFF & echo $CONFIG sleep $SLEEP ((++CUR_JOBS))