Skip to content

Commit 935188f

Browse files
committed
fix: ensure directory exists before writing markdown files
1 parent 7eb9a70 commit 935188f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

ajet/backbone/trainer_verl.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515

16+
import os
1617
import uuid
1718
from collections import defaultdict
1819
from pprint import pprint
@@ -432,6 +433,7 @@ def fit(self): # noqa: C901
432433
self.verl_logger.log(data=val_metrics, step=self.global_steps)
433434
val_print_to_markdown_file_path = self.config.ajet.trainer_common.val_print_to_markdown_file_path
434435
if val_print_to_markdown_file_path:
436+
os.makedirs(os.path.dirname(val_print_to_markdown_file_path), exist_ok=True)
435437
with open(val_print_to_markdown_file_path, mode="a+") as f:
436438
f.write(str(val_metrics))
437439
f.write('\n')
@@ -736,6 +738,7 @@ def fit(self): # noqa: C901
736738
metrics.update(val_metrics)
737739
val_print_to_markdown_file_path = self.config.ajet.trainer_common.val_print_to_markdown_file_path
738740
if val_print_to_markdown_file_path:
741+
os.makedirs(os.path.dirname(val_print_to_markdown_file_path), exist_ok=True)
739742
with open(val_print_to_markdown_file_path, mode="a+") as f:
740743
f.write(str(val_metrics))
741744
f.write('\n')
@@ -789,6 +792,7 @@ def fit(self): # noqa: C901
789792
self.verl_logger.log(data=metrics, step=self.global_steps)
790793
train_print_to_markdown_file_path = self.config.ajet.trainer_common.train_print_to_markdown_file_path
791794
if train_print_to_markdown_file_path:
795+
os.makedirs(os.path.dirname(train_print_to_markdown_file_path), exist_ok=True)
792796
with open(train_print_to_markdown_file_path, mode="a+") as f:
793797
f.write(str(metrics))
794798
f.write('\n')

tutorial/example_math_lora/math_agent.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ ajet:
5151
debug_first_n_tasks: 1
5252

5353
trainer_common:
54-
val_print_to_markdown_file_path: /mnt/data_cpfs/qingxu.fu/autoresearch-rl/exp_result/hello-agentjet-math-lora/val_result.md
55-
train_print_to_markdown_file_path: /mnt/data_cpfs/qingxu.fu/autoresearch-rl/exp_result/hello-agentjet-math-lora/train_result.md
5654
save_freq: 100
5755
test_freq: 100
5856
total_epochs: 100

0 commit comments

Comments
 (0)