Skip to content

Commit adf68d1

Browse files
committed
fix pai open with 'a' (#430)
1 parent 44ec8ab commit adf68d1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

swift/trainers/callback.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from transformers.trainer_utils import IntervalStrategy, has_length
1010

1111
from swift.trainers import TrainingArguments
12+
from swift.utils import is_pai_training_job
1213

1314

1415
class ProgressCallbackNew(ProgressCallback):
@@ -47,7 +48,7 @@ def on_log(self,
4748
for k, v in logs.items():
4849
if isinstance(v, float):
4950
logs[k] = round(logs[k], 8)
50-
if state.is_local_process_zero and self.training_bar is not None:
51+
if not is_pai_training_job() and state.is_local_process_zero:
5152
jsonl_path = os.path.join(args.output_dir, 'logging.jsonl')
5253
with open(jsonl_path, 'a', encoding='utf-8') as f:
5354
f.write(json.dumps(logs) + '\n')
@@ -77,7 +78,7 @@ def on_log(self, args, state, control, logs=None, **kwargs):
7778
for k, v in logs.items():
7879
if isinstance(v, float):
7980
logs[k] = round(logs[k], 8)
80-
if state.is_local_process_zero:
81+
if not is_pai_training_job() and state.is_local_process_zero:
8182
jsonl_path = os.path.join(args.output_dir, 'logging.jsonl')
8283
with open(jsonl_path, 'a', encoding='utf-8') as f:
8384
f.write(json.dumps(logs) + '\n')

0 commit comments

Comments
 (0)