Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/psij/executors/batch/batch_scheduler_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ def __init__(self, launcher_log_file: Optional[Path] = None,
if 'PSIJ_BATCH_KEEP_FILES' in os.environ:
self.keep_files = True

@classmethod
def _from_config(cls, config: JobExecutorConfig) -> 'BatchSchedulerExecutorConfig':
new = cls()
new.work_directory = config.work_directory
new.launcher_log_file = config.launcher_log_file
return new


class InvalidJobStateError(Exception):
"""An exception that signals that a job cannot be cancelled due to it being already done."""
Expand Down Expand Up @@ -199,14 +206,21 @@ def __init__(self, url: Optional[str] = None,
An configuration for this executor instance; if none is specified, a default
configuration is used.
"""
super().__init__(url=url, config=config if config else BatchSchedulerExecutorConfig())
super().__init__(url=url, config=self._get_config(config))
assert config
self.work_directory = config.work_directory / self.name
self._queue_poll_thread = self._start_queue_poll_thread()

def _ensure_work_dir(self) -> None:
self.work_directory.mkdir(parents=True, exist_ok=True)

def _get_config(self, config: Optional[JobExecutorConfig]) -> BatchSchedulerExecutorConfig:
if config is None:
return BatchSchedulerExecutorConfig()
if isinstance(config, BatchSchedulerExecutorConfig):
return config
return BatchSchedulerExecutorConfig._from_config(config)

def submit(self, job: Job) -> None:
"""See :func:`~psij.JobExecutor.submit`."""
logger.info('Job %s: submitting', job.id)
Expand Down
Loading