@@ -113,6 +113,13 @@ def __init__(self, launcher_log_file: Optional[Path] = None,
113113 if 'PSIJ_BATCH_KEEP_FILES' in os .environ :
114114 self .keep_files = True
115115
116+ @classmethod
117+ def _from_config (cls , config : JobExecutorConfig ) -> 'BatchSchedulerExecutorConfig' :
118+ new = cls ()
119+ new .work_directory = config .work_directory
120+ new .launcher_log_file = config .launcher_log_file
121+ return new
122+
116123
117124class InvalidJobStateError (Exception ):
118125 """An exception that signals that a job cannot be cancelled due to it being already done."""
@@ -199,14 +206,21 @@ def __init__(self, url: Optional[str] = None,
199206 An configuration for this executor instance; if none is specified, a default
200207 configuration is used.
201208 """
202- super ().__init__ (url = url , config = config if config else BatchSchedulerExecutorConfig ( ))
209+ super ().__init__ (url = url , config = self . _get_config ( config ))
203210 assert config
204211 self .work_directory = config .work_directory / self .name
205212 self ._queue_poll_thread = self ._start_queue_poll_thread ()
206213
207214 def _ensure_work_dir (self ) -> None :
208215 self .work_directory .mkdir (parents = True , exist_ok = True )
209216
217+ def _get_config (self , config : Optional [JobExecutorConfig ]) -> BatchSchedulerExecutorConfig :
218+ if config is None :
219+ return BatchSchedulerExecutorConfig ()
220+ if isinstance (config , BatchSchedulerExecutorConfig ):
221+ return config
222+ return BatchSchedulerExecutorConfig ._from_config (config )
223+
210224 def submit (self , job : Job ) -> None :
211225 """See :func:`~psij.JobExecutor.submit`."""
212226 logger .info ('Job %s: submitting' , job .id )
0 commit comments