1111from dataclasses import dataclass , field
1212from datetime import datetime
1313from enum import Enum
14- from typing import Generic , Iterable , List , Optional , TypeVar , Union
14+ from typing import Generic , Iterable , List , Optional , TypeVar
1515
1616from torchx .specs import (
1717 AppDef ,
18+ AppDryRunInfo ,
1819 AppState ,
1920 NONE ,
2021 NULL_RESOURCE ,
@@ -95,11 +96,9 @@ def __hash__(self) -> int:
9596
9697
9798T = TypeVar ("T" )
98- A = TypeVar ("A" )
99- D = TypeVar ("D" )
10099
101100
102- class Scheduler (abc .ABC , Generic [T , A , D ]):
101+ class Scheduler (abc .ABC , Generic [T ]):
103102 """
104103 An interface abstracting functionalities of a scheduler.
105104 Implementers need only implement those methods annotated with
@@ -129,7 +128,7 @@ def close(self) -> None:
129128
130129 def submit (
131130 self ,
132- app : A ,
131+ app : AppDef ,
133132 cfg : T ,
134133 workspace : str | Workspace | None = None ,
135134 ) -> str :
@@ -157,7 +156,7 @@ def submit(
157156 return self .schedule (dryrun_info )
158157
159158 @abc .abstractmethod
160- def schedule (self , dryrun_info : D ) -> str :
159+ def schedule (self , dryrun_info : AppDryRunInfo ) -> str :
161160 """
162161 Same as ``submit`` except that it takes an ``AppDryRunInfo``.
163162 Implementers are encouraged to implement this method rather than
@@ -173,7 +172,7 @@ def schedule(self, dryrun_info: D) -> str:
173172
174173 raise NotImplementedError ()
175174
176- def submit_dryrun (self , app : A , cfg : T ) -> D :
175+ def submit_dryrun (self , app : AppDef , cfg : T ) -> AppDryRunInfo :
177176 """
178177 Rather than submitting the request to run the app, returns the
179178 request object that would have been submitted to the underlying
@@ -187,15 +186,15 @@ def submit_dryrun(self, app: A, cfg: T) -> D:
187186 # pyre-fixme: _submit_dryrun takes Generic type for resolved_cfg
188187 dryrun_info = self ._submit_dryrun (app , resolved_cfg )
189188
190- if isinstance ( app , AppDef ) :
191- for role in app . roles :
192- dryrun_info = role . pre_proc ( self . backend , dryrun_info )
189+ for role in app . roles :
190+ dryrun_info = role . pre_proc ( self . backend , dryrun_info )
191+
193192 dryrun_info ._app = app
194193 dryrun_info ._cfg = resolved_cfg
195194 return dryrun_info
196195
197196 @abc .abstractmethod
198- def _submit_dryrun (self , app : A , cfg : T ) -> D :
197+ def _submit_dryrun (self , app : AppDef , cfg : T ) -> AppDryRunInfo :
199198 raise NotImplementedError ()
200199
201200 def run_opts (self ) -> runopts :
@@ -394,15 +393,12 @@ def _pre_build_validate(self, app: AppDef, scheduler: str, cfg: T) -> None:
394393 """
395394 pass
396395
397- def _validate (self , app : A , scheduler : str , cfg : T ) -> None :
396+ def _validate (self , app : AppDef , scheduler : str , cfg : T ) -> None :
398397 """
399398 Validates after workspace build whether application is consistent with the scheduler.
400399
401400 Raises error if application is not compatible with scheduler
402401 """
403- if not isinstance (app , AppDef ):
404- return
405-
406402 for role in app .roles :
407403 if role .resource == NULL_RESOURCE :
408404 raise ValueError (
0 commit comments