Skip to content

Commit

Permalink
fix Bug: KeyError: 'text' Corresponding to issue #296 (#300)
Browse files Browse the repository at this point in the history
* fix Bug: KeyError: 'text' 

File data_juice/config/config.py lines 418-429 did not consider the situation when arg: text_key was initialized to 'text', resulting in arg: text_key not being updated properly and always being initialized to the value of 'text'

* Fix Bug: key_text do not update correctly

* Update config.py

Normalize Format
  • Loading branch information
shiweijiezero authored Apr 18, 2024
1 parent c1a8aa8 commit 33f72b1
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions data_juicer/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ def init_configs(args=None):

try:
cfg = parser.parse_args(args=args)
cfg = update_op_process(cfg, parser)
cfg = init_setup_from_cfg(cfg)
cfg = update_op_process(cfg, parser)

# copy the config file into the work directory
config_backup(cfg)
Expand Down Expand Up @@ -422,11 +422,15 @@ def init_setup_from_cfg(cfg):
'audio_key': cfg.audio_key,
'video_key': cfg.video_key,
}
elif args['text_key'] is None:
args['text_key'] = text_key
args['image_key'] = cfg.image_key
args['audio_key'] = cfg.audio_key
args['video_key'] = cfg.video_key
else:
if 'text_key' not in args or args['text_key'] is None:
args['text_key'] = text_key
if 'image_key' not in args or args['image_key'] is None:
args['image_key'] = cfg.image_key
if 'audio_key' not in args or args['audio_key'] is None:
args['audio_key'] = cfg.audio_key
if 'video_key' not in args or args['video_key'] is None:
args['video_key'] = cfg.video_key
op[op_name] = args

return cfg
Expand Down

0 comments on commit 33f72b1

Please sign in to comment.