File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change
1
+ import datetime
1
2
import os
2
3
import tempfile
4
+ import time
3
5
from pathlib import Path
4
6
from typing import NoReturn
5
7
@@ -49,18 +51,33 @@ def dist_func() -> None:
49
51
50
52
num_workers = 2
51
53
54
+ before_timestamp = datetime .datetime .now ()
55
+
56
+ time .sleep (1 )
57
+
52
58
trx .launch (
53
59
dist_func ,
54
60
workers_per_host = num_workers ,
55
61
backend = "gloo" ,
56
62
)
57
63
58
- log_files = next (os .walk (tmp ), (None , None , []))[2 ]
64
+ after_timestamp = datetime .datetime .now ()
65
+
66
+ log_dirs = next (os .walk (tmp ), (None , [], None ))[1 ]
67
+
68
+ assert len (log_dirs ) == 1
69
+
70
+ # this should error if mis-formatted
71
+ log_timestamp = datetime .datetime .fromisoformat (log_dirs [0 ])
72
+
73
+ assert before_timestamp <= log_timestamp <= after_timestamp
74
+
75
+ log_files = next (os .walk (f"{ tmp } /{ log_dirs [0 ]} " ), (None , None , []))[2 ]
59
76
60
77
assert len (log_files ) == num_workers + 1
61
78
62
79
for file in log_files :
63
- with Path (f"{ tmp } /{ file } " ).open () as f :
80
+ with Path (f"{ tmp } /{ log_dirs [ 0 ] } / { file } " ).open () as f :
64
81
contents = f .read ()
65
82
print (contents )
66
83
if file .endswith ("[0].log" ):
You can’t perform that action at this time.
0 commit comments