@@ -21,6 +21,18 @@ def _to_path(arg: Union[str, pathlib.Path, None]) -> Optional[pathlib.Path]:
2121 return pathlib .Path (arg )
2222
2323
24+ def _to_env_dict (arg : Union [Dict [str , Union [str , int ]], None ]) -> Optional [Dict [str , str ]]:
25+ if arg is None :
26+ return None
27+ ret = dict ()
28+ for k , v in arg .items ():
29+ if isinstance (v , int ):
30+ ret [k ] = str (v )
31+ else :
32+ ret [k ] = v
33+ return ret
34+
35+
2436class JobSpec (object ):
2537 """A class that describes the details of a job."""
2638
@@ -29,7 +41,8 @@ def __init__(self, executable: Optional[str] = None, arguments: Optional[List[st
2941 # sphinx fails to find the class. Using Path in the getters and setters does not
3042 # appear to trigger a problem.
3143 directory : Union [str , pathlib .Path , None ] = None , name : Optional [str ] = None ,
32- inherit_environment : bool = True , environment : Optional [Dict [str , str ]] = None ,
44+ inherit_environment : bool = True ,
45+ environment : Optional [Dict [str , Union [str , int ]]] = None ,
3346 stdin_path : Union [str , pathlib .Path , None ] = None ,
3447 stdout_path : Union [str , pathlib .Path , None ] = None ,
3548 stderr_path : Union [str , pathlib .Path , None ] = None ,
@@ -125,7 +138,7 @@ def __init__(self, executable: Optional[str] = None, arguments: Optional[List[st
125138 # care of the conversion, but mypy gets confused
126139 self ._directory = _to_path (directory )
127140 self .inherit_environment = inherit_environment
128- self .environment = environment
141+ self .environment = _to_env_dict ( environment )
129142 self ._stdin_path = _to_path (stdin_path )
130143 self ._stdout_path = _to_path (stdout_path )
131144 self ._stderr_path = _to_path (stderr_path )
@@ -152,6 +165,16 @@ def name(self) -> Optional[str]:
152165 def name (self , value : Optional [str ]) -> None :
153166 self ._name = value
154167
168+ @property
169+ def environment (self ) -> Optional [Dict [str , str ]]:
170+ """Return the environment dict."""
171+ return self ._environment
172+
173+ @environment .setter
174+ def environment (self , env : Optional [Dict [str , Union [str , int ]]]) -> None :
175+ """Ensure env dict values to be string typed."""
176+ self ._environment = _to_env_dict (env )
177+
155178 @property
156179 def directory (self ) -> Optional [pathlib .Path ]:
157180 """The directory, on the compute side, in which the executable is to be run."""
0 commit comments