siliconcompiler 0.35.0__py3-none-any.whl → 0.35.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- siliconcompiler/_metadata.py +1 -1
- siliconcompiler/apps/_common.py +3 -2
- siliconcompiler/apps/sc_dashboard.py +3 -1
- siliconcompiler/apps/sc_install.py +149 -37
- siliconcompiler/apps/smake.py +9 -3
- siliconcompiler/checklist.py +3 -3
- siliconcompiler/data/demo_fpga/z1000_yosys_config.json +24 -0
- siliconcompiler/design.py +51 -45
- siliconcompiler/flowgraph.py +2 -2
- siliconcompiler/library.py +23 -12
- siliconcompiler/package/__init__.py +77 -49
- siliconcompiler/package/git.py +11 -6
- siliconcompiler/package/github.py +11 -6
- siliconcompiler/package/https.py +6 -4
- siliconcompiler/pdk.py +23 -16
- siliconcompiler/scheduler/scheduler.py +30 -22
- siliconcompiler/scheduler/schedulernode.py +60 -50
- siliconcompiler/scheduler/taskscheduler.py +52 -32
- siliconcompiler/schema/baseschema.py +88 -69
- siliconcompiler/schema/docs/schemagen.py +4 -3
- siliconcompiler/schema/editableschema.py +5 -5
- siliconcompiler/schema/journal.py +19 -13
- siliconcompiler/schema/namedschema.py +16 -10
- siliconcompiler/schema/parameter.py +64 -37
- siliconcompiler/schema/parametervalue.py +126 -80
- siliconcompiler/schema/safeschema.py +16 -7
- siliconcompiler/schema/utils.py +3 -1
- siliconcompiler/schema_support/cmdlineschema.py +9 -9
- siliconcompiler/schema_support/dependencyschema.py +12 -7
- siliconcompiler/schema_support/filesetschema.py +15 -10
- siliconcompiler/schema_support/metric.py +29 -17
- siliconcompiler/schema_support/packageschema.py +2 -2
- siliconcompiler/schema_support/pathschema.py +30 -18
- siliconcompiler/schema_support/record.py +30 -23
- siliconcompiler/tool.py +265 -210
- siliconcompiler/tools/opensta/timing.py +13 -0
- siliconcompiler/tools/yosys/syn_fpga.py +3 -2
- siliconcompiler/toolscripts/_tools.json +3 -3
- siliconcompiler/utils/__init__.py +23 -16
- siliconcompiler/utils/curation.py +11 -5
- siliconcompiler/utils/multiprocessing.py +16 -14
- siliconcompiler/utils/paths.py +24 -12
- siliconcompiler/utils/units.py +16 -12
- {siliconcompiler-0.35.0.dist-info → siliconcompiler-0.35.1.dist-info}/METADATA +3 -4
- {siliconcompiler-0.35.0.dist-info → siliconcompiler-0.35.1.dist-info}/RECORD +49 -48
- {siliconcompiler-0.35.0.dist-info → siliconcompiler-0.35.1.dist-info}/entry_points.txt +4 -3
- {siliconcompiler-0.35.0.dist-info → siliconcompiler-0.35.1.dist-info}/WHEEL +0 -0
- {siliconcompiler-0.35.0.dist-info → siliconcompiler-0.35.1.dist-info}/licenses/LICENSE +0 -0
- {siliconcompiler-0.35.0.dist-info → siliconcompiler-0.35.1.dist-info}/top_level.txt +0 -0
|
@@ -24,9 +24,9 @@ class EditableSchema:
|
|
|
24
24
|
self.__schema = schema
|
|
25
25
|
|
|
26
26
|
def __insert(self,
|
|
27
|
-
keypath: Tuple[str],
|
|
27
|
+
keypath: Tuple[str, ...],
|
|
28
28
|
value: Union[BaseSchema, Parameter],
|
|
29
|
-
fullkey: Tuple[str],
|
|
29
|
+
fullkey: Tuple[str, ...],
|
|
30
30
|
clobber: bool) -> None:
|
|
31
31
|
key = keypath[0]
|
|
32
32
|
keypath = keypath[1:]
|
|
@@ -57,7 +57,7 @@ class EditableSchema:
|
|
|
57
57
|
new_schema._BaseSchema__key = key
|
|
58
58
|
EditableSchema(new_schema).__insert(keypath, value, fullkey, clobber)
|
|
59
59
|
|
|
60
|
-
def __remove(self, keypath: Tuple[str], fullkey: Tuple[str]) -> None:
|
|
60
|
+
def __remove(self, keypath: Tuple[str, ...], fullkey: Tuple[str, ...]) -> None:
|
|
61
61
|
key = keypath[0]
|
|
62
62
|
keypath = keypath[1:]
|
|
63
63
|
|
|
@@ -77,7 +77,7 @@ class EditableSchema:
|
|
|
77
77
|
else:
|
|
78
78
|
EditableSchema(next_param).__remove(keypath, fullkey)
|
|
79
79
|
|
|
80
|
-
def insert(self, *args, clobber: bool = False) -> None:
|
|
80
|
+
def insert(self, *args: Union[str, BaseSchema, Parameter], clobber: bool = False) -> None:
|
|
81
81
|
'''
|
|
82
82
|
Inserts a :class:`Parameter` or a :class:`BaseSchema` to the schema,
|
|
83
83
|
based on the keypath and value provided in the ``*args``.
|
|
@@ -93,7 +93,7 @@ class EditableSchema:
|
|
|
93
93
|
'''
|
|
94
94
|
|
|
95
95
|
value = args[-1]
|
|
96
|
-
keypath = args[0:-1]
|
|
96
|
+
keypath: Tuple[str, ...] = args[0:-1]
|
|
97
97
|
|
|
98
98
|
if not keypath:
|
|
99
99
|
raise ValueError("A keypath is required")
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import copy
|
|
2
2
|
import json
|
|
3
3
|
|
|
4
|
-
from typing import Tuple, Set, Dict, List
|
|
4
|
+
from typing import Tuple, Set, Dict, List, Optional, Union, TYPE_CHECKING
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from .baseschema import BaseSchema
|
|
5
8
|
|
|
6
9
|
|
|
7
10
|
class Journal:
|
|
@@ -14,7 +17,7 @@ class Journal:
|
|
|
14
17
|
keyprefix (list of str): keypath to prefix on to recorded path
|
|
15
18
|
"""
|
|
16
19
|
|
|
17
|
-
def __init__(self, keyprefix: Tuple[str] = None):
|
|
20
|
+
def __init__(self, keyprefix: Optional[Union[List[str], Tuple[str, ...]]] = None):
|
|
18
21
|
if not keyprefix:
|
|
19
22
|
self.__keyprefix = tuple()
|
|
20
23
|
else:
|
|
@@ -26,14 +29,14 @@ class Journal:
|
|
|
26
29
|
self.stop()
|
|
27
30
|
|
|
28
31
|
@property
|
|
29
|
-
def keypath(self) -> Tuple[str]:
|
|
32
|
+
def keypath(self) -> Tuple[str, ...]:
|
|
30
33
|
'''
|
|
31
34
|
Returns the reference key path for this journal
|
|
32
35
|
'''
|
|
33
36
|
|
|
34
37
|
return self.__keyprefix
|
|
35
38
|
|
|
36
|
-
def get_child(self, *keypath:
|
|
39
|
+
def get_child(self, *keypath: str) -> "Journal":
|
|
37
40
|
'''
|
|
38
41
|
Get a child journal based on a new keypath
|
|
39
42
|
|
|
@@ -45,7 +48,7 @@ class Journal:
|
|
|
45
48
|
child.__parent = self.__parent
|
|
46
49
|
return child
|
|
47
50
|
|
|
48
|
-
def from_dict(self, manifest: Dict):
|
|
51
|
+
def from_dict(self, manifest: List[Dict]) -> None:
|
|
49
52
|
'''
|
|
50
53
|
Import a journal from a manifest dictionary
|
|
51
54
|
|
|
@@ -55,7 +58,7 @@ class Journal:
|
|
|
55
58
|
|
|
56
59
|
self.__journal = manifest
|
|
57
60
|
|
|
58
|
-
def get(self) -> List[Dict]:
|
|
61
|
+
def get(self) -> Optional[List[Dict]]:
|
|
59
62
|
"""
|
|
60
63
|
Returns a copy of the current journal
|
|
61
64
|
"""
|
|
@@ -109,11 +112,11 @@ class Journal:
|
|
|
109
112
|
|
|
110
113
|
def record(self,
|
|
111
114
|
record_type: str,
|
|
112
|
-
key: Tuple[str],
|
|
115
|
+
key: Union[List[str], Tuple[str, ...]],
|
|
113
116
|
value=None,
|
|
114
|
-
field: str = None,
|
|
115
|
-
step: str = None,
|
|
116
|
-
index: str = None) -> None:
|
|
117
|
+
field: Optional[str] = None,
|
|
118
|
+
step: Optional[str] = None,
|
|
119
|
+
index: Optional[Union[int, str]] = None) -> None:
|
|
117
120
|
'''
|
|
118
121
|
Record the schema transaction
|
|
119
122
|
'''
|
|
@@ -127,6 +130,9 @@ class Journal:
|
|
|
127
130
|
if isinstance(value, set):
|
|
128
131
|
value = list(value)
|
|
129
132
|
|
|
133
|
+
if index is not None and isinstance(index, int):
|
|
134
|
+
index = str(index)
|
|
135
|
+
|
|
130
136
|
self.__parent.__journal.append({
|
|
131
137
|
"type": record_type,
|
|
132
138
|
"key": tuple([*self.__keyprefix, *key]),
|
|
@@ -154,7 +160,7 @@ class Journal:
|
|
|
154
160
|
self.__parent.__record_types.clear()
|
|
155
161
|
|
|
156
162
|
@staticmethod
|
|
157
|
-
def replay_file(schema, filepath: str) -> None:
|
|
163
|
+
def replay_file(schema: "BaseSchema", filepath: str) -> None:
|
|
158
164
|
'''
|
|
159
165
|
Replay a journal into a schema from a manifest
|
|
160
166
|
|
|
@@ -171,7 +177,7 @@ class Journal:
|
|
|
171
177
|
journal.from_dict(data["__journal__"])
|
|
172
178
|
journal.replay(schema)
|
|
173
179
|
|
|
174
|
-
def replay(self, schema) -> None:
|
|
180
|
+
def replay(self, schema: "BaseSchema") -> None:
|
|
175
181
|
'''
|
|
176
182
|
Replay journal into a schema
|
|
177
183
|
|
|
@@ -207,7 +213,7 @@ class Journal:
|
|
|
207
213
|
raise ValueError(f'Unknown record type {record_type}')
|
|
208
214
|
|
|
209
215
|
@staticmethod
|
|
210
|
-
def access(schema) -> "Journal":
|
|
216
|
+
def access(schema: "BaseSchema") -> "Journal":
|
|
211
217
|
'''
|
|
212
218
|
Access a journal from a schema
|
|
213
219
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# SC dependencies outside of its directory, since it may be used by tool drivers
|
|
5
5
|
# that have isolated Python environments.
|
|
6
6
|
|
|
7
|
-
from typing import Dict, Tuple
|
|
7
|
+
from typing import Dict, Tuple, Optional, Set, Union, List
|
|
8
8
|
|
|
9
9
|
from .baseschema import BaseSchema
|
|
10
10
|
|
|
@@ -17,13 +17,13 @@ class NamedSchema(BaseSchema):
|
|
|
17
17
|
name (str): name of the schema
|
|
18
18
|
'''
|
|
19
19
|
|
|
20
|
-
def __init__(self, name: str = None):
|
|
20
|
+
def __init__(self, name: Optional[str] = None):
|
|
21
21
|
super().__init__()
|
|
22
22
|
|
|
23
23
|
self.set_name(name)
|
|
24
24
|
|
|
25
25
|
@property
|
|
26
|
-
def name(self) -> str:
|
|
26
|
+
def name(self) -> Optional[str]:
|
|
27
27
|
'''
|
|
28
28
|
Returns the name of the schema
|
|
29
29
|
'''
|
|
@@ -32,7 +32,7 @@ class NamedSchema(BaseSchema):
|
|
|
32
32
|
except AttributeError:
|
|
33
33
|
return None
|
|
34
34
|
|
|
35
|
-
def set_name(self, name: str) -> None:
|
|
35
|
+
def set_name(self, name: Optional[str]) -> None:
|
|
36
36
|
"""
|
|
37
37
|
Set the name of this object
|
|
38
38
|
|
|
@@ -66,13 +66,16 @@ class NamedSchema(BaseSchema):
|
|
|
66
66
|
|
|
67
67
|
raise NotImplementedError("Must be implemented by the child classes.")
|
|
68
68
|
|
|
69
|
-
def _getdict_meta(self) -> Dict[str, str]:
|
|
69
|
+
def _getdict_meta(self) -> Dict[str, Optional[Union[str, int, float]]]:
|
|
70
70
|
info = super()._getdict_meta()
|
|
71
71
|
info["name"] = self.name
|
|
72
72
|
return info
|
|
73
73
|
|
|
74
74
|
@classmethod
|
|
75
|
-
def from_manifest(cls,
|
|
75
|
+
def from_manifest(cls,
|
|
76
|
+
filepath: Union[None, str] = None,
|
|
77
|
+
cfg: Union[None, Dict] = None,
|
|
78
|
+
name: Optional[str] = None):
|
|
76
79
|
'''
|
|
77
80
|
Create a new schema based on the provided source files.
|
|
78
81
|
|
|
@@ -92,10 +95,13 @@ class NamedSchema(BaseSchema):
|
|
|
92
95
|
if filepath:
|
|
93
96
|
schema.read_manifest(filepath)
|
|
94
97
|
if cfg:
|
|
95
|
-
schema._from_dict(cfg,
|
|
98
|
+
schema._from_dict(cfg, tuple())
|
|
96
99
|
return schema
|
|
97
100
|
|
|
98
|
-
def _from_dict(self, manifest: Dict,
|
|
101
|
+
def _from_dict(self, manifest: Dict,
|
|
102
|
+
keypath: Union[List[str], Tuple[str, ...]],
|
|
103
|
+
version: Optional[Tuple[int, ...]] = None) \
|
|
104
|
+
-> Tuple[Set[Tuple[str, ...]], Set[Tuple[str, ...]]]:
|
|
99
105
|
if keypath:
|
|
100
106
|
self.__name = keypath[-1]
|
|
101
107
|
elif not self.__name and "__meta__" in manifest and "name" in manifest["__meta__"]:
|
|
@@ -103,8 +109,8 @@ class NamedSchema(BaseSchema):
|
|
|
103
109
|
|
|
104
110
|
return super()._from_dict(manifest, keypath, version=version)
|
|
105
111
|
|
|
106
|
-
def copy(self, key: Tuple[str] = None) -> "NamedSchema":
|
|
107
|
-
copy = super().copy(key=key)
|
|
112
|
+
def copy(self, key: Optional[Tuple[str, ...]] = None) -> "NamedSchema":
|
|
113
|
+
copy: NamedSchema = super().copy(key=key)
|
|
108
114
|
|
|
109
115
|
if key and key[-1] != "default":
|
|
110
116
|
copy.__name = key[-1]
|
|
@@ -10,7 +10,7 @@ import re
|
|
|
10
10
|
import shlex
|
|
11
11
|
|
|
12
12
|
from enum import Enum
|
|
13
|
-
from typing import Tuple
|
|
13
|
+
from typing import Tuple, Optional, Union, List, Dict, Any, Set
|
|
14
14
|
|
|
15
15
|
from .parametervalue import NodeValue, DirectoryNodeValue, FileNodeValue, NodeListValue, \
|
|
16
16
|
NodeSetValue
|
|
@@ -67,20 +67,20 @@ class Parameter:
|
|
|
67
67
|
GLOBAL_KEY = 'global'
|
|
68
68
|
|
|
69
69
|
def __init__(self,
|
|
70
|
-
type,
|
|
71
|
-
require=False,
|
|
70
|
+
type: str,
|
|
71
|
+
require: bool = False,
|
|
72
72
|
defvalue=None,
|
|
73
|
-
scope=Scope.GLOBAL,
|
|
74
|
-
copy=False,
|
|
75
|
-
lock=False,
|
|
76
|
-
hashalgo='sha256',
|
|
77
|
-
notes=None,
|
|
78
|
-
unit=None,
|
|
79
|
-
shorthelp=None,
|
|
80
|
-
switch=None,
|
|
81
|
-
example=None,
|
|
82
|
-
help=None,
|
|
83
|
-
pernode=PerNode.NEVER,
|
|
73
|
+
scope: Scope = Scope.GLOBAL,
|
|
74
|
+
copy: bool = False,
|
|
75
|
+
lock: bool = False,
|
|
76
|
+
hashalgo: str = 'sha256',
|
|
77
|
+
notes: Optional[str] = None,
|
|
78
|
+
unit: Optional[str] = None,
|
|
79
|
+
shorthelp: Optional[str] = None,
|
|
80
|
+
switch: Optional[Union[List[str], str]] = None,
|
|
81
|
+
example: Optional[Union[List[str], str]] = None,
|
|
82
|
+
help: Optional[str] = None,
|
|
83
|
+
pernode: PerNode = PerNode.NEVER,
|
|
84
84
|
**kwargs):
|
|
85
85
|
|
|
86
86
|
self.__type = NodeType.parse(type)
|
|
@@ -127,7 +127,7 @@ class Parameter:
|
|
|
127
127
|
self.__hashalgo = str(hashalgo)
|
|
128
128
|
self.__copy = bool(copy)
|
|
129
129
|
|
|
130
|
-
def __setdefvalue(self, defvalue, **kwargs):
|
|
130
|
+
def __setdefvalue(self, defvalue, **kwargs) -> None:
|
|
131
131
|
if NodeType.contains(self.__type, 'file'):
|
|
132
132
|
if isinstance(self.__type, list):
|
|
133
133
|
self.__defvalue = NodeListValue(FileNodeValue(defvalue, **kwargs))
|
|
@@ -155,12 +155,12 @@ class Parameter:
|
|
|
155
155
|
else:
|
|
156
156
|
self.__defvalue = NodeValue(self.__type, value=defvalue, **kwargs)
|
|
157
157
|
|
|
158
|
-
def __str__(self):
|
|
158
|
+
def __str__(self) -> str:
|
|
159
159
|
return str(self.getvalues())
|
|
160
160
|
|
|
161
161
|
def _generate_doc(self, doc,
|
|
162
162
|
ref_root: str = "",
|
|
163
|
-
key_offset: Tuple[str] = None,
|
|
163
|
+
key_offset: Optional[Tuple[str, ...]] = None,
|
|
164
164
|
detailed: bool = True):
|
|
165
165
|
from .docs.utils import strong, para, code, build_list, build_table
|
|
166
166
|
from docutils.statemachine import ViewList
|
|
@@ -228,7 +228,9 @@ class Parameter:
|
|
|
228
228
|
|
|
229
229
|
return [body, table]
|
|
230
230
|
|
|
231
|
-
def get(self, field='value',
|
|
231
|
+
def get(self, field: Optional[str] = 'value',
|
|
232
|
+
step: Optional[str] = None,
|
|
233
|
+
index: Optional[Union[int, str]] = None):
|
|
232
234
|
"""
|
|
233
235
|
Returns the value in a parameter field.
|
|
234
236
|
|
|
@@ -297,7 +299,9 @@ class Parameter:
|
|
|
297
299
|
|
|
298
300
|
raise ValueError(f'"{field}" is not a valid field')
|
|
299
301
|
|
|
300
|
-
def __assert_step_index(self, field
|
|
302
|
+
def __assert_step_index(self, field: Optional[str],
|
|
303
|
+
step: Optional[str],
|
|
304
|
+
index: Optional[Union[int, str]]) -> None:
|
|
301
305
|
if field not in self.__defvalue.fields:
|
|
302
306
|
if step is not None or index is not None:
|
|
303
307
|
raise KeyError(
|
|
@@ -321,7 +325,11 @@ class Parameter:
|
|
|
321
325
|
if index == 'default':
|
|
322
326
|
raise KeyError('illegal index name: default is reserved')
|
|
323
327
|
|
|
324
|
-
def set(self, value,
|
|
328
|
+
def set(self, value,
|
|
329
|
+
field: str = 'value',
|
|
330
|
+
step: Optional[str] = None,
|
|
331
|
+
index: Optional[Union[int, str]] = None,
|
|
332
|
+
clobber: bool = True) -> Union[bool, List[NodeValue], NodeValue]:
|
|
325
333
|
'''
|
|
326
334
|
Sets a parameter field.
|
|
327
335
|
|
|
@@ -401,7 +409,10 @@ class Parameter:
|
|
|
401
409
|
|
|
402
410
|
return True
|
|
403
411
|
|
|
404
|
-
def add(self, value,
|
|
412
|
+
def add(self, value,
|
|
413
|
+
field: str = 'value',
|
|
414
|
+
step: Optional[str] = None,
|
|
415
|
+
index: Optional[Union[int, str]] = None) -> Union[bool, List[NodeValue], NodeValue]:
|
|
405
416
|
'''
|
|
406
417
|
Adds item(s) to a list.
|
|
407
418
|
|
|
@@ -448,7 +459,7 @@ class Parameter:
|
|
|
448
459
|
|
|
449
460
|
return True
|
|
450
461
|
|
|
451
|
-
def unset(self, step=None, index=None):
|
|
462
|
+
def unset(self, step: Optional[str] = None, index: Optional[Union[int, str]] = None) -> bool:
|
|
452
463
|
'''
|
|
453
464
|
Unsets a schema parameter.
|
|
454
465
|
|
|
@@ -490,13 +501,13 @@ class Parameter:
|
|
|
490
501
|
|
|
491
502
|
return True
|
|
492
503
|
|
|
493
|
-
def reset(self):
|
|
504
|
+
def reset(self) -> None:
|
|
494
505
|
"""
|
|
495
506
|
Resets a parameter back to its default state
|
|
496
507
|
"""
|
|
497
508
|
self.__node = {}
|
|
498
509
|
|
|
499
|
-
def getdict(self, include_default=True, values_only=False):
|
|
510
|
+
def getdict(self, include_default: bool = True, values_only: bool = False) -> Dict:
|
|
500
511
|
"""
|
|
501
512
|
Returns a schema dictionary.
|
|
502
513
|
|
|
@@ -555,7 +566,10 @@ class Parameter:
|
|
|
555
566
|
return dictvals
|
|
556
567
|
|
|
557
568
|
@classmethod
|
|
558
|
-
def from_dict(cls,
|
|
569
|
+
def from_dict(cls,
|
|
570
|
+
manifest: Dict,
|
|
571
|
+
keypath: Tuple[str, ...],
|
|
572
|
+
version: Optional[Tuple[int, ...]]) -> "Parameter":
|
|
559
573
|
'''
|
|
560
574
|
Create a new parameter based on the provided dictionary.
|
|
561
575
|
|
|
@@ -570,7 +584,10 @@ class Parameter:
|
|
|
570
584
|
param._from_dict(manifest, keypath, version)
|
|
571
585
|
return param
|
|
572
586
|
|
|
573
|
-
def _from_dict(self,
|
|
587
|
+
def _from_dict(self,
|
|
588
|
+
manifest: Dict,
|
|
589
|
+
keypath: Tuple[str, ...],
|
|
590
|
+
version: Optional[Tuple[int, ...]]) -> None:
|
|
574
591
|
'''
|
|
575
592
|
Copies the information from the manifest into this parameter.
|
|
576
593
|
|
|
@@ -632,7 +649,8 @@ class Parameter:
|
|
|
632
649
|
value = param.get()
|
|
633
650
|
param.set(value)
|
|
634
651
|
|
|
635
|
-
def gettcl(self, step=None,
|
|
652
|
+
def gettcl(self, step: Optional[str] = None,
|
|
653
|
+
index: Optional[Union[str, int]] = None) -> Optional[str]:
|
|
636
654
|
"""
|
|
637
655
|
Returns a tcl string for this parameter.
|
|
638
656
|
|
|
@@ -665,7 +683,10 @@ class Parameter:
|
|
|
665
683
|
except KeyError:
|
|
666
684
|
return self.__defvalue.gettcl()
|
|
667
685
|
|
|
668
|
-
def getvalues(self, return_defvalue=True, return_values=True)
|
|
686
|
+
def getvalues(self, return_defvalue: bool = True, return_values: bool = True) \
|
|
687
|
+
-> List[Tuple[Union[Any, NodeValue, NodeSetValue, NodeListValue],
|
|
688
|
+
Optional[str],
|
|
689
|
+
Optional[str]]]:
|
|
669
690
|
"""
|
|
670
691
|
Returns all values (global and pernode) associated with a particular parameter.
|
|
671
692
|
|
|
@@ -696,7 +717,7 @@ class Parameter:
|
|
|
696
717
|
|
|
697
718
|
return vals
|
|
698
719
|
|
|
699
|
-
def copy(self, key=None):
|
|
720
|
+
def copy(self, key: Optional[Tuple[str, ...]] = None) -> "Parameter":
|
|
700
721
|
"""
|
|
701
722
|
Returns a copy of this parameter.
|
|
702
723
|
|
|
@@ -707,14 +728,14 @@ class Parameter:
|
|
|
707
728
|
return copy.deepcopy(self)
|
|
708
729
|
|
|
709
730
|
# Utility functions
|
|
710
|
-
def is_list(self):
|
|
731
|
+
def is_list(self) -> bool:
|
|
711
732
|
"""
|
|
712
733
|
Returns true is this parameter is a list type
|
|
713
734
|
"""
|
|
714
735
|
|
|
715
736
|
return isinstance(self.__type, (list, set))
|
|
716
737
|
|
|
717
|
-
def is_empty(self):
|
|
738
|
+
def is_empty(self) -> bool:
|
|
718
739
|
'''
|
|
719
740
|
Utility function to check key for an empty value.
|
|
720
741
|
'''
|
|
@@ -724,7 +745,7 @@ class Parameter:
|
|
|
724
745
|
values = self.getvalues()
|
|
725
746
|
return all([value in empty for value, _, _ in values])
|
|
726
747
|
|
|
727
|
-
def is_set(self, step=None, index=None):
|
|
748
|
+
def is_set(self, step: Optional[str] = None, index: Optional[Union[str, int]] = None) -> bool:
|
|
728
749
|
'''
|
|
729
750
|
Returns whether a user has set a value for this parameter.
|
|
730
751
|
|
|
@@ -746,7 +767,8 @@ class Parameter:
|
|
|
746
767
|
index in self.__node[step] and \
|
|
747
768
|
self.__node[step][index]
|
|
748
769
|
|
|
749
|
-
def has_value(self, step=None,
|
|
770
|
+
def has_value(self, step: Optional[str] = None,
|
|
771
|
+
index: Optional[Union[str, int]] = None) -> bool:
|
|
750
772
|
'''
|
|
751
773
|
Returns whether the parameter as a value.
|
|
752
774
|
|
|
@@ -774,13 +796,17 @@ class Parameter:
|
|
|
774
796
|
return self.__defvalue.has_value
|
|
775
797
|
|
|
776
798
|
@property
|
|
777
|
-
def default(self):
|
|
799
|
+
def default(self) -> Union[NodeValue, NodeSetValue, NodeListValue]:
|
|
778
800
|
"""
|
|
779
801
|
Gets a copy of the default value.
|
|
780
802
|
"""
|
|
781
803
|
return self.__defvalue.copy()
|
|
782
804
|
|
|
783
|
-
def add_commandline_arguments(self,
|
|
805
|
+
def add_commandline_arguments(self,
|
|
806
|
+
argparser: argparse.ArgumentParser,
|
|
807
|
+
*keypath: str,
|
|
808
|
+
switchlist: Optional[Union[Set[str], List[str], str]] = None) \
|
|
809
|
+
-> Tuple[Optional[str], Optional[List[str]]]:
|
|
784
810
|
'''
|
|
785
811
|
Adds commandline arguments for this parameter.
|
|
786
812
|
|
|
@@ -874,13 +900,14 @@ class Parameter:
|
|
|
874
900
|
|
|
875
901
|
return dest, switches
|
|
876
902
|
|
|
877
|
-
def parse_commandline_arguments(self, value, *keypath)
|
|
903
|
+
def parse_commandline_arguments(self, value: str, *keypath: str) -> \
|
|
904
|
+
Tuple[Tuple[str, ...], Optional[str], Optional[str], str]:
|
|
878
905
|
"""
|
|
879
906
|
Parse and set the values provided form the commandline parser.
|
|
880
907
|
|
|
881
908
|
Args:
|
|
882
909
|
value (str): string from commandline
|
|
883
|
-
keypath (list of str):
|
|
910
|
+
keypath (list of str): keypath to this parameter
|
|
884
911
|
"""
|
|
885
912
|
num_free_keys = keypath.count('default')
|
|
886
913
|
|