11
11
from lightning_app .utilities .component import _set_flow_context
12
12
13
13
14
- class SyncWorkLITDriveA (LightningWork ):
14
+ class SyncWorkA (LightningWork ):
15
15
def __init__ (self , tmpdir ):
16
16
super ().__init__ ()
17
17
self .tmpdir = tmpdir
@@ -25,35 +25,35 @@ def run(self, drive: Drive):
25
25
os .remove (f"{ self .tmpdir } /a.txt" )
26
26
27
27
28
- class SyncWorkLITDriveB (LightningWork ):
28
+ class SyncWorkB (LightningWork ):
29
29
def run (self , drive : Drive ):
30
30
assert not os .path .exists ("a.txt" )
31
31
drive .get ("a.txt" )
32
32
assert os .path .exists ("a.txt" )
33
33
34
34
35
- class SyncFlowLITDrives (LightningFlow ):
35
+ class SyncFlow (LightningFlow ):
36
36
def __init__ (self , tmpdir ):
37
37
super ().__init__ ()
38
38
self .log_dir = Drive ("lit://log_dir" )
39
- self .work_a = SyncWorkLITDriveA (str (tmpdir ))
40
- self .work_b = SyncWorkLITDriveB ()
39
+ self .work_a = SyncWorkA (str (tmpdir ))
40
+ self .work_b = SyncWorkB ()
41
41
42
42
def run (self ):
43
43
self .work_a .run (self .log_dir )
44
44
self .work_b .run (self .log_dir )
45
45
self ._exit ()
46
46
47
47
48
- def test_synchronization_lit_drive (tmpdir ):
48
+ def test_synchronization_drive (tmpdir ):
49
49
if os .path .exists ("a.txt" ):
50
50
os .remove ("a.txt" )
51
- app = LightningApp (SyncFlowLITDrives (tmpdir ))
51
+ app = LightningApp (SyncFlow (tmpdir ))
52
52
MultiProcessRuntime (app , start_server = False ).dispatch ()
53
53
os .remove ("a.txt" )
54
54
55
55
56
- class LITDriveWork (LightningWork ):
56
+ class Work (LightningWork ):
57
57
def __init__ (self ):
58
58
super ().__init__ (parallel = True )
59
59
self .drive = None
@@ -75,7 +75,7 @@ def run(self, *args, **kwargs):
75
75
self .counter += 1
76
76
77
77
78
- class LITDriveWork2 (LightningWork ):
78
+ class Work2 (LightningWork ):
79
79
def __init__ (self ):
80
80
super ().__init__ (parallel = True )
81
81
@@ -86,11 +86,11 @@ def run(self, drive: Drive, **kwargs):
86
86
assert drive .list ("." , component_name = self .name ) == []
87
87
88
88
89
- class LITDriveFlow (LightningFlow ):
89
+ class Flow (LightningFlow ):
90
90
def __init__ (self ):
91
91
super ().__init__ ()
92
- self .work = LITDriveWork ()
93
- self .work2 = LITDriveWork2 ()
92
+ self .work = Work ()
93
+ self .work2 = Work2 ()
94
94
95
95
def run (self ):
96
96
self .work .run ("0" )
@@ -102,15 +102,15 @@ def run(self):
102
102
self ._exit ()
103
103
104
104
105
- def test_lit_drive_transferring_files ():
106
- app = LightningApp (LITDriveFlow ())
105
+ def test_drive_transferring_files ():
106
+ app = LightningApp (Flow ())
107
107
MultiProcessRuntime (app , start_server = False ).dispatch ()
108
108
os .remove ("a.txt" )
109
109
110
110
111
- def test_lit_drive ():
112
- with pytest .raises (Exception , match = "Unknown protocol for the drive 'id' argument " ):
113
- Drive ("invalid_drive_id " )
111
+ def test_drive ():
112
+ with pytest .raises (Exception , match = "The Drive id needs to start with one of the following protocols " ):
113
+ Drive ("this_drive_id " )
114
114
115
115
with pytest .raises (
116
116
Exception , match = "The id should be unique to identify your drive. Found `this_drive_id/something_else`."
@@ -213,56 +213,19 @@ def test_lit_drive():
213
213
os .remove ("a.txt" )
214
214
215
215
216
- def test_s3_drives ():
217
- drive = Drive ("s3://foo/" , allow_duplicates = True )
218
- drive .component_name = "root.work"
219
-
220
- with pytest .raises (
221
- Exception , match = "S3 based drives cannot currently add files via this API. Did you mean to use `lit://` drives?"
222
- ):
223
- drive .put ("a.txt" )
224
- with pytest .raises (
225
- Exception ,
226
- match = "S3 based drives cannot currently list files via this API. Did you mean to use `lit://` drives?" ,
227
- ):
228
- drive .list ("a.txt" )
229
- with pytest .raises (
230
- Exception , match = "S3 based drives cannot currently get files via this API. Did you mean to use `lit://` drives?"
231
- ):
232
- drive .get ("a.txt" )
233
- with pytest .raises (
234
- Exception ,
235
- match = "S3 based drives cannot currently delete files via this API. Did you mean to use `lit://` drives?" ,
236
- ):
237
- drive .delete ("a.txt" )
216
+ def test_maybe_create_drive ():
238
217
239
- _set_flow_context ()
240
- with pytest .raises (Exception , match = "The flow isn't allowed to put files into a Drive." ):
241
- drive .put ("a.txt" )
242
- with pytest .raises (Exception , match = "The flow isn't allowed to list files from a Drive." ):
243
- drive .list ("a.txt" )
244
- with pytest .raises (Exception , match = "The flow isn't allowed to get files from a Drive." ):
245
- drive .get ("a.txt" )
246
-
247
-
248
- def test_create_s3_drive_without_trailing_slash_fails ():
249
- with pytest .raises (ValueError , match = "S3 drives must end in a trailing slash" ):
250
- Drive ("s3://foo" )
251
-
252
-
253
- @pytest .mark .parametrize ("drive_id" , ["lit://drive" , "s3://drive/" ])
254
- def test_maybe_create_drive (drive_id ):
255
- drive = Drive (drive_id , allow_duplicates = False )
218
+ drive = Drive ("lit://drive_3" , allow_duplicates = False )
256
219
drive .component_name = "root.work1"
257
220
new_drive = _maybe_create_drive (drive .component_name , drive .to_dict ())
258
221
assert new_drive .protocol == drive .protocol
259
222
assert new_drive .id == drive .id
260
223
assert new_drive .component_name == drive .component_name
261
224
262
225
263
- @ pytest . mark . parametrize ( "drive_id" , [ "lit://drive" , "s3://drive/" ])
264
- def test_drive_deepcopy ( drive_id ):
265
- drive = Drive (drive_id , allow_duplicates = True )
226
+ def test_drive_deepcopy ():
227
+
228
+ drive = Drive ("lit://drive" , allow_duplicates = True )
266
229
drive .component_name = "root.work1"
267
230
new_drive = deepcopy (drive )
268
231
assert new_drive .id == drive .id
0 commit comments