Skip to content

Commit

Permalink
Fix RecExplainer bug: Automatically create directory if it does not e…
Browse files Browse the repository at this point in the history
…xist
  • Loading branch information
t-yuxuanlei authored and Micheallei committed Dec 18, 2024
1 parent a2c9cf6 commit 0e5b13f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions RecExplainer/preprocess/amazon_generate_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ def gen_uid2next_rank(user_items, args):
tokenizer = AutoTokenizer.from_pretrained(args.model_name, model_max_length=args.model_max_length, use_fast=True)

if args.gpt_query_file is not None:
os.makedirs(os.path.dirname(args.gpt_query_file), exist_ok=True)
gen_uid2summary(user_items, meta_infos, args)
else:
os.makedirs(os.path.dirname(args.save_intention_file), exist_ok=True)
train_intention = []
train_behavior = []
train_both = []
Expand Down
1 change: 1 addition & 0 deletions RecExplainer/preprocess/data_preprocess_amazon.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,4 +383,5 @@ def main_process(data_name, args, data_type='Amazon'):

if __name__ == '__main__':
args = parse_args()
os.makedirs(os.path.dirname(args.save_data_file), exist_ok=True)
main_process(args.full_data_name, args=args, data_type='Amazon')
2 changes: 2 additions & 0 deletions RecExplainer/preprocess/eval_explan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pandas as pd
import argparse
import os

def parse_args():
parser = argparse.ArgumentParser(description="data process")
Expand Down Expand Up @@ -81,6 +82,7 @@ def eval_metric(args):
if __name__ == '__main__':
args = parse_args()
if args.judge_query_file is not None:
os.makedirs(os.path.dirname(args.judge_query_file), exist_ok=True)
eval_data_gen(args)
else:
eval_metric(args)
1 change: 1 addition & 0 deletions RecExplainer/preprocess/gpt_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,5 @@ def main(args):
parser.add_argument("--output_file", type=str)
parser.add_argument("--input_columns", type=str, default="question")
args = parser.parse_args()
os.makedirs(os.path.dirname(args.output_file), exist_ok=True)
main(args)
2 changes: 2 additions & 0 deletions RecExplainer/preprocess/mf_amazon_video_games_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,10 @@ def gen_uid2next_rank(user_items, args):
tokenizer = AutoTokenizer.from_pretrained(args.model_name, model_max_length=args.model_max_length, use_fast=True)

if args.gpt_query_file is not None:
os.makedirs(os.path.dirname(args.gpt_query_file), exist_ok=True)
gen_uid2summary(user_items, meta_infos, args)
else:
os.makedirs(os.path.dirname(args.save_intention_file), exist_ok=True)
train_intention = []
train_behavior = []
train_both = []
Expand Down
2 changes: 2 additions & 0 deletions RecExplainer/preprocess/unirec_utils/unirec_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pandas as pd
import argparse
import os

def parse_args():
parser = argparse.ArgumentParser(description="data process")
Expand Down Expand Up @@ -64,5 +65,6 @@ def rank_split(args):

if __name__ == '__main__':
args = parse_args()
os.makedirs(os.path.dirname(args.train_file), exist_ok=True)
unirec_split(args)
rank_split(args)

0 comments on commit 0e5b13f

Please sign in to comment.