@@ -142,78 +142,77 @@ def dispatch(
142
142
v1_env_vars .append (V1EnvVar (name = "ENABLE_PUSHING_STATE_ENDPOINT" , value = "0" ))
143
143
144
144
works : List [V1Work ] = []
145
- for flow in self .app .flows :
146
- for work in flow .works (recurse = False ):
147
- if not work ._start_with_flow :
148
- continue
149
-
150
- work_requirements = "\n " .join (work .cloud_build_config .requirements )
151
- build_spec = V1BuildSpec (
152
- commands = work .cloud_build_config .build_commands (),
153
- python_dependencies = V1PythonDependencyInfo (
154
- package_manager = V1PackageManager .PIP , packages = work_requirements
155
- ),
156
- image = work .cloud_build_config .image ,
157
- )
158
- user_compute_config = V1UserRequestedComputeConfig (
159
- name = work .cloud_compute .name ,
160
- count = 1 ,
161
- disk_size = work .cloud_compute .disk_size ,
162
- preemptible = work .cloud_compute .preemptible ,
163
- shm_size = work .cloud_compute .shm_size ,
164
- )
145
+ for work in self .app .works :
146
+ if not work ._start_with_flow :
147
+ continue
165
148
166
- drive_specs : List [V1LightningworkDrives ] = []
167
- for drive_attr_name , drive in [
168
- (k , getattr (work , k )) for k in work ._state if isinstance (getattr (work , k ), Drive )
169
- ]:
170
- if drive .protocol == "lit://" :
171
- drive_type = V1DriveType .NO_MOUNT_S3
172
- source_type = V1SourceType .S3
173
- else :
174
- raise RuntimeError (
175
- f"unknown drive protocol `{ drive .protocol } `. Please verify this "
176
- f"drive type has been configured for use in the cloud dispatcher."
177
- )
149
+ work_requirements = "\n " .join (work .cloud_build_config .requirements )
150
+ build_spec = V1BuildSpec (
151
+ commands = work .cloud_build_config .build_commands (),
152
+ python_dependencies = V1PythonDependencyInfo (
153
+ package_manager = V1PackageManager .PIP , packages = work_requirements
154
+ ),
155
+ image = work .cloud_build_config .image ,
156
+ )
157
+ user_compute_config = V1UserRequestedComputeConfig (
158
+ name = work .cloud_compute .name ,
159
+ count = 1 ,
160
+ disk_size = work .cloud_compute .disk_size ,
161
+ preemptible = work .cloud_compute .preemptible ,
162
+ shm_size = work .cloud_compute .shm_size ,
163
+ )
178
164
179
- drive_specs .append (
180
- V1LightningworkDrives (
181
- drive = V1Drive (
182
- metadata = V1Metadata (
183
- name = f"{ work .name } .{ drive_attr_name } " ,
184
- ),
185
- spec = V1DriveSpec (
186
- drive_type = drive_type ,
187
- source_type = source_type ,
188
- source = f"{ drive .protocol } { drive .id } " ,
189
- ),
190
- status = V1DriveStatus (),
165
+ drive_specs : List [V1LightningworkDrives ] = []
166
+ for drive_attr_name , drive in [
167
+ (k , getattr (work , k )) for k in work ._state if isinstance (getattr (work , k ), Drive )
168
+ ]:
169
+ if drive .protocol == "lit://" :
170
+ drive_type = V1DriveType .NO_MOUNT_S3
171
+ source_type = V1SourceType .S3
172
+ else :
173
+ raise RuntimeError (
174
+ f"unknown drive protocol `{ drive .protocol } `. Please verify this "
175
+ f"drive type has been configured for use in the cloud dispatcher."
176
+ )
177
+
178
+ drive_specs .append (
179
+ V1LightningworkDrives (
180
+ drive = V1Drive (
181
+ metadata = V1Metadata (
182
+ name = f"{ work .name } .{ drive_attr_name } " ,
183
+ ),
184
+ spec = V1DriveSpec (
185
+ drive_type = drive_type ,
186
+ source_type = source_type ,
187
+ source = f"{ drive .protocol } { drive .id } " ,
191
188
),
192
- mount_location = str ( drive . root_folder ),
189
+ status = V1DriveStatus ( ),
193
190
),
194
- )
191
+ mount_location = str (drive .root_folder ),
192
+ ),
193
+ )
195
194
196
- # TODO: Move this to the CloudCompute class and update backend
197
- if work .cloud_compute .mounts is not None :
198
- mounts = work .cloud_compute .mounts
199
- if isinstance (mounts , Mount ):
200
- mounts = [mounts ]
201
- for mount in mounts :
202
- drive_specs .append (
203
- _create_mount_drive_spec (
204
- work_name = work .name ,
205
- mount = mount ,
206
- )
195
+ # TODO: Move this to the CloudCompute class and update backend
196
+ if work .cloud_compute .mounts is not None :
197
+ mounts = work .cloud_compute .mounts
198
+ if isinstance (mounts , Mount ):
199
+ mounts = [mounts ]
200
+ for mount in mounts :
201
+ drive_specs .append (
202
+ _create_mount_drive_spec (
203
+ work_name = work .name ,
204
+ mount = mount ,
207
205
)
206
+ )
208
207
209
- random_name = "" .join (random .choice (string .ascii_lowercase ) for _ in range (5 ))
210
- work_spec = V1LightningworkSpec (
211
- build_spec = build_spec ,
212
- drives = drive_specs ,
213
- user_requested_compute_config = user_compute_config ,
214
- network_config = [V1NetworkConfig (name = random_name , port = work .port )],
215
- )
216
- works .append (V1Work (name = work .name , spec = work_spec ))
208
+ random_name = "" .join (random .choice (string .ascii_lowercase ) for _ in range (5 ))
209
+ work_spec = V1LightningworkSpec (
210
+ build_spec = build_spec ,
211
+ drives = drive_specs ,
212
+ user_requested_compute_config = user_compute_config ,
213
+ network_config = [V1NetworkConfig (name = random_name , port = work .port )],
214
+ )
215
+ works .append (V1Work (name = work .name , spec = work_spec ))
217
216
218
217
# We need to collect a spec for each flow that contains a frontend so that the backend knows
219
218
# for which flows it needs to start servers by invoking the cli (see the serve_frontend() method below)
0 commit comments