Skip to content

Commit 6a9e24a

Browse files
committed
Add some basic typeguard checks to Spec/Attrs/ResourceSpec constructors
1 parent de25698 commit 6a9e24a

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/psij/job_attributes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from datetime import timedelta
22
from typing import Optional, Dict
33

4+
from typeguard import check_argument_types
5+
46

57
class JobAttributes(object):
68
"""A class containing ancillary job information that describes how a job is to be run."""
@@ -27,6 +29,8 @@ def __init__(self, duration: timedelta = timedelta(minutes=10),
2729
:class:`~psij.JobExecutor` define and are responsible for interpreting custom
2830
attributes.
2931
"""
32+
assert check_argument_types()
33+
3034
self.duration = duration
3135
self.queue_name = queue_name
3236
self.project_name = project_name

src/psij/job_spec.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import sys
22
from pathlib import Path
33
from typing import Optional, List, Dict, Any
4+
5+
from typeguard import check_argument_types
6+
47
from psij.job_attributes import JobAttributes
58
from psij.resource_spec import ResourceSpec
69

@@ -53,6 +56,8 @@ def __init__(self, name: Optional[str] = None, executable: Optional[str] = None,
5356
:param launcher: The name of a launcher to use, such as "mpirun", "srun", "single", etc.
5457
For a list of available launchers,:ref:`launchers`
5558
"""
59+
assert check_argument_types()
60+
5661
self._name = name
5762
self.executable = executable
5863
self.arguments = arguments

src/psij/resource_spec.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from abc import ABC, abstractmethod
22
from typing import Optional, List
33

4+
from typeguard import check_argument_types
5+
46
from psij.exceptions import InvalidJobException
57

68

@@ -58,6 +60,8 @@ def __init__(self, node_count: Optional[int] = None,
5860
:param gpu_cores_per_process:
5961
:param exclusive_node_use:
6062
"""
63+
assert check_argument_types()
64+
6165
self.node_count = node_count
6266
self.process_count = process_count
6367
self.processes_per_node = processes_per_node

0 commit comments

Comments
 (0)