Skip to content

Commit 489581e

Browse files
committed
Use IO[str] rather than TextIO in batch scheduler executors in the context
of submit script generation.
1 parent 3109e7c commit 489581e

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

src/psij/executors/batch/batch_scheduler_executor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from datetime import timedelta
88
from pathlib import Path
99
from threading import Thread, RLock
10-
from typing import Optional, List, Dict, Collection, cast, TextIO, Union
10+
from typing import Optional, List, Dict, Collection, cast, Union, IO
1111

1212
from .escape_functions import bash_escape
1313
from psij.launchers.script_based_launcher import ScriptBasedLauncher
@@ -268,7 +268,7 @@ def attach(self, job: Job, native_id: str) -> None:
268268

269269
@abstractmethod
270270
def generate_submit_script(self, job: Job, context: Dict[str, object],
271-
submit_file: TextIO) -> None:
271+
submit_file: IO[str]) -> None:
272272
"""Called to generate a submit script for a job.
273273
274274
Concrete implementations of batch scheduler executors must override this method in

src/psij/executors/batch/cobalt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Defines a JobExecutor for the Cobalt resource manager."""
22
from datetime import timedelta
33
from pathlib import Path
4-
from typing import Optional, Collection, List, Dict, TextIO
4+
from typing import Optional, Collection, List, Dict, IO
55
import re
66
import os
77
import stat
@@ -59,7 +59,7 @@ def __init__(
5959
)
6060

6161
def generate_submit_script(
62-
self, job: Job, context: Dict[str, object], submit_file: TextIO
62+
self, job: Job, context: Dict[str, object], submit_file: IO[str]
6363
) -> None:
6464
"""See :meth:`~.BatchSchedulerExecutor.generate_submit_script`."""
6565
self.generator.generate_submit_script(job, context, submit_file)

src/psij/executors/batch/lsf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from pathlib import Path
44
import re
55
import json
6-
from typing import Optional, Collection, List, Dict, TextIO
6+
from typing import Optional, Collection, List, Dict, IO
77

88
from psij import Job, JobStatus, JobState, SubmitException
99
from psij.executors.batch.batch_scheduler_executor import (
@@ -62,7 +62,7 @@ def __init__(self, url: Optional[str], config: Optional[LsfExecutorConfig] = Non
6262
)
6363

6464
def generate_submit_script(
65-
self, job: Job, context: Dict[str, object], submit_file: TextIO
65+
self, job: Job, context: Dict[str, object], submit_file: IO[str]
6666
) -> None:
6767
"""See :meth:`~.BatchSchedulerExecutor.generate_submit_script`."""
6868
assert job.spec is not None

src/psij/executors/batch/pbspro.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from datetime import timedelta
22
from pathlib import Path
3-
from typing import Optional, Collection, List, Dict, TextIO
3+
from typing import Optional, Collection, List, Dict, IO
44

55
from psij import Job, JobStatus, JobState, SubmitException
66
from psij.executors.batch.batch_scheduler_executor import BatchSchedulerExecutor, \
@@ -72,7 +72,7 @@ def __init__(self, url: Optional[str] = None, config: Optional[PBSProExecutorCon
7272
# Submit methods
7373

7474
def generate_submit_script(self, job: Job, context: Dict[str, object],
75-
submit_file: TextIO) -> None:
75+
submit_file: IO[str]) -> None:
7676
"""See :meth:`~.BatchSchedulerExecutor.generate_submit_script`."""
7777
self.generator.generate_submit_script(job, context, submit_file)
7878

src/psij/executors/batch/script_generator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pathlib
22
from abc import ABC
3-
from typing import TextIO, Dict, Callable
3+
from typing import Dict, Callable, IO
44

55
import pystache
66

@@ -29,7 +29,7 @@ def __init__(self, config: JobExecutorConfig) -> None:
2929
"""
3030
self.config = config
3131

32-
def generate_submit_script(self, job: Job, context: Dict[str, object], out: TextIO) -> None:
32+
def generate_submit_script(self, job: Job, context: Dict[str, object], out: IO[str]) -> None:
3333
"""Generates a job submit script.
3434
3535
Concerete implementations of submit script generators must implement this method. Its
@@ -76,7 +76,7 @@ def __init__(self, config: JobExecutorConfig, template_path: pathlib.Path,
7676
self.template = pystache.parse(template_file.read())
7777
self.renderer = pystache.Renderer(escape=escape)
7878

79-
def generate_submit_script(self, job: Job, context: Dict[str, object], out: TextIO) -> None:
79+
def generate_submit_script(self, job: Job, context: Dict[str, object], out: IO[str]) -> None:
8080
"""See :func:`~SubmitScriptGenerator.generate_submit_script`.
8181
8282
Renders a submit script using the template specified when this generator was constructed.

src/psij/executors/batch/slurm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from datetime import timedelta
22
from pathlib import Path
3-
from typing import Optional, Collection, List, Dict, TextIO
3+
from typing import Optional, Collection, List, Dict, IO
44

55
from psij import Job, JobStatus, JobState, SubmitException
66
from psij.executors.batch.batch_scheduler_executor import BatchSchedulerExecutor, \
@@ -117,7 +117,7 @@ def __init__(self, url: Optional[str] = None, config: Optional[SlurmExecutorConf
117117
/ 'slurm.mustache')
118118

119119
def generate_submit_script(self, job: Job, context: Dict[str, object],
120-
submit_file: TextIO) -> None:
120+
submit_file: IO[str]) -> None:
121121
"""See :meth:`~.BatchSchedulerExecutor.generate_submit_script`."""
122122
self.generator.generate_submit_script(job, context, submit_file)
123123

tests/plugins1/_batch_test/_batch_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
from pathlib import Path
3-
from typing import Optional, Collection, List, Dict, TextIO, cast
3+
from typing import Optional, Collection, List, Dict, IO, cast
44

55
from psij import Job, JobStatus, JobState, SubmitException, JobExecutorConfig, ResourceSpecV1
66
from psij.executors.batch.batch_scheduler_executor import BatchSchedulerExecutor, \
@@ -48,7 +48,7 @@ def __init__(self, url: Optional[str] = None, config: Optional[_TestExecutorConf
4848
/ 'test.mustache')
4949

5050
def generate_submit_script(self, job: Job, context: Dict[str, object],
51-
submit_file: TextIO) -> None:
51+
submit_file: IO[str]) -> None:
5252
self.generator.generate_submit_script(job, context, submit_file)
5353

5454
def get_submit_command(self, job: Job, submit_file_path: Path) -> List[str]:

0 commit comments

Comments
 (0)