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
|
@@ -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, Union, List, Set
|
|
8
8
|
|
|
9
9
|
from .parameter import Parameter
|
|
10
10
|
from .baseschema import BaseSchema
|
|
@@ -17,7 +17,9 @@ class SafeSchema(BaseSchema):
|
|
|
17
17
|
'''
|
|
18
18
|
|
|
19
19
|
@staticmethod
|
|
20
|
-
def __is_dict_leaf(manifest: Dict,
|
|
20
|
+
def __is_dict_leaf(manifest: Dict,
|
|
21
|
+
keypath: List[str],
|
|
22
|
+
version: Optional[Tuple[int, ...]]) -> Optional[Parameter]:
|
|
21
23
|
try:
|
|
22
24
|
return Parameter.from_dict(manifest, keypath, version)
|
|
23
25
|
except: # noqa E722
|
|
@@ -31,26 +33,33 @@ class SafeSchema(BaseSchema):
|
|
|
31
33
|
|
|
32
34
|
return "SafeSchema"
|
|
33
35
|
|
|
34
|
-
def _from_dict(self, manifest: Dict,
|
|
36
|
+
def _from_dict(self, manifest: Dict,
|
|
37
|
+
keypath: Union[List[str], Tuple[str, ...]],
|
|
38
|
+
version: Optional[Tuple[int, ...]] = None) \
|
|
39
|
+
-> Tuple[Set[Tuple[str, ...]], Set[Tuple[str, ...]]]:
|
|
35
40
|
if not isinstance(manifest, dict):
|
|
36
|
-
return
|
|
41
|
+
return set(), set()
|
|
37
42
|
|
|
38
43
|
if "__meta__" in manifest:
|
|
39
44
|
del manifest["__meta__"]
|
|
40
45
|
|
|
41
46
|
for key, data in manifest.items():
|
|
42
|
-
obj = SafeSchema.__is_dict_leaf(data, keypath + [key], version)
|
|
47
|
+
obj = SafeSchema.__is_dict_leaf(data, list(keypath) + [key], version)
|
|
43
48
|
if not obj:
|
|
44
49
|
obj = SafeSchema()
|
|
45
|
-
obj._from_dict(data, keypath + [key], version)
|
|
50
|
+
obj._from_dict(data, list(keypath) + [key], version)
|
|
46
51
|
|
|
47
52
|
if key == "default":
|
|
48
53
|
self._BaseSchema__default = obj
|
|
49
54
|
else:
|
|
50
55
|
self._BaseSchema__manifest[key] = obj
|
|
51
56
|
|
|
57
|
+
return set(), set()
|
|
58
|
+
|
|
52
59
|
@classmethod
|
|
53
|
-
def from_manifest(cls,
|
|
60
|
+
def from_manifest(cls,
|
|
61
|
+
filepath: Union[None, str] = None,
|
|
62
|
+
cfg: Union[None, Dict] = None) -> "SafeSchema":
|
|
54
63
|
if filepath:
|
|
55
64
|
cfg = BaseSchema._read_manifest(filepath)
|
|
56
65
|
|
siliconcompiler/schema/utils.py
CHANGED
|
@@ -4,7 +4,7 @@ import sys
|
|
|
4
4
|
|
|
5
5
|
import os.path
|
|
6
6
|
|
|
7
|
-
from typing import Set, List
|
|
7
|
+
from typing import Set, List, Optional, Union
|
|
8
8
|
|
|
9
9
|
from siliconcompiler.schema import BaseSchema, EditableSchema, Parameter, Scope, PerNode
|
|
10
10
|
from siliconcompiler.schema.utils import trim
|
|
@@ -25,9 +25,9 @@ class CommandLineSchema(BaseSchema):
|
|
|
25
25
|
name: str,
|
|
26
26
|
type: str,
|
|
27
27
|
help: str,
|
|
28
|
-
switch: List[str] = None,
|
|
28
|
+
switch: Optional[Union[str, List[str]]] = None,
|
|
29
29
|
defvalue=None,
|
|
30
|
-
**kwargs):
|
|
30
|
+
**kwargs) -> None:
|
|
31
31
|
'''
|
|
32
32
|
Adds a parameter to the commandline definition.
|
|
33
33
|
|
|
@@ -69,13 +69,13 @@ class CommandLineSchema(BaseSchema):
|
|
|
69
69
|
|
|
70
70
|
@classmethod
|
|
71
71
|
def create_cmdline(cls,
|
|
72
|
-
progname: str = None,
|
|
73
|
-
description: str = None,
|
|
74
|
-
switchlist: Set[str] = None,
|
|
75
|
-
version: str = None,
|
|
72
|
+
progname: Optional[str] = None,
|
|
73
|
+
description: Optional[str] = None,
|
|
74
|
+
switchlist: Optional[Union[List[str], Set[str]]] = None,
|
|
75
|
+
version: Optional[str] = None,
|
|
76
76
|
print_banner: bool = True,
|
|
77
77
|
use_cfg: bool = False,
|
|
78
|
-
use_sources: bool = True):
|
|
78
|
+
use_sources: bool = True) -> BaseSchema:
|
|
79
79
|
"""
|
|
80
80
|
Creates an SC command line interface.
|
|
81
81
|
|
|
@@ -175,7 +175,7 @@ class CommandLineSchema(BaseSchema):
|
|
|
175
175
|
if keypath == ("option", "cfg"): # TODO: remove this when cfg is removed from schema
|
|
176
176
|
continue
|
|
177
177
|
|
|
178
|
-
param = keyschema.get(*keypath, field=None)
|
|
178
|
+
param: Parameter = keyschema.get(*keypath, field=None)
|
|
179
179
|
|
|
180
180
|
dest, switches = param.add_commandline_arguments(
|
|
181
181
|
parser,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import os.path
|
|
2
2
|
|
|
3
|
+
from typing import Dict, Union, Tuple, List, Optional, Set
|
|
4
|
+
|
|
3
5
|
from siliconcompiler.schema.baseschema import BaseSchema
|
|
4
6
|
from siliconcompiler.schema.editableschema import EditableSchema
|
|
5
7
|
from siliconcompiler.schema.parameter import Parameter, Scope
|
|
@@ -27,7 +29,10 @@ class DependencySchema(BaseSchema):
|
|
|
27
29
|
shorthelp="List of object dependencies",
|
|
28
30
|
help="List of named object dependencies included via add_dep()."))
|
|
29
31
|
|
|
30
|
-
def _from_dict(self, manifest
|
|
32
|
+
def _from_dict(self, manifest: Dict,
|
|
33
|
+
keypath: Union[List[str], Tuple[str, ...]],
|
|
34
|
+
version: Optional[Tuple[int, ...]] = None) \
|
|
35
|
+
-> Tuple[Set[Tuple[str, ...]], Set[Tuple[str, ...]]]:
|
|
31
36
|
'''
|
|
32
37
|
Internal helper to load schema from a dictionary manifest.
|
|
33
38
|
|
|
@@ -152,7 +157,7 @@ class DependencySchema(BaseSchema):
|
|
|
152
157
|
except graphviz.ExecutableNotFound as e:
|
|
153
158
|
raise RuntimeError(f'Unable to save flowgraph: {e}')
|
|
154
159
|
|
|
155
|
-
def __get_all_deps(self, seen:
|
|
160
|
+
def __get_all_deps(self, seen: Set[str]) -> List[NamedSchema]:
|
|
156
161
|
'''
|
|
157
162
|
Recursively traverses the dependency tree to generate a flat list.
|
|
158
163
|
|
|
@@ -184,7 +189,7 @@ class DependencySchema(BaseSchema):
|
|
|
184
189
|
|
|
185
190
|
return deps
|
|
186
191
|
|
|
187
|
-
def get_dep(self, name: str = None, hierarchy: bool = True) ->
|
|
192
|
+
def get_dep(self, name: Optional[str] = None, hierarchy: bool = True) -> List[NamedSchema]:
|
|
188
193
|
'''
|
|
189
194
|
Returns all dependencies associated with this object or a specific one if requested.
|
|
190
195
|
|
|
@@ -216,7 +221,7 @@ class DependencySchema(BaseSchema):
|
|
|
216
221
|
return self.__get_all_deps(set())
|
|
217
222
|
return list(self.__deps.values())
|
|
218
223
|
|
|
219
|
-
def has_dep(self, name: str) -> bool:
|
|
224
|
+
def has_dep(self, name: Union[NamedSchema, str]) -> bool:
|
|
220
225
|
'''
|
|
221
226
|
Checks if a specific dependency is present.
|
|
222
227
|
|
|
@@ -232,7 +237,7 @@ class DependencySchema(BaseSchema):
|
|
|
232
237
|
|
|
233
238
|
return name in self.__deps
|
|
234
239
|
|
|
235
|
-
def remove_dep(self, name: str) -> bool:
|
|
240
|
+
def remove_dep(self, name: Union[str, NamedSchema]) -> bool:
|
|
236
241
|
'''
|
|
237
242
|
Removes a previously registered module.
|
|
238
243
|
|
|
@@ -260,7 +265,7 @@ class DependencySchema(BaseSchema):
|
|
|
260
265
|
|
|
261
266
|
return True
|
|
262
267
|
|
|
263
|
-
def _populate_deps(self, module_map:
|
|
268
|
+
def _populate_deps(self, module_map: Dict[str, NamedSchema]) -> None:
|
|
264
269
|
'''
|
|
265
270
|
Internal method to populate the internal dependency dictionary.
|
|
266
271
|
|
|
@@ -281,6 +286,6 @@ class DependencySchema(BaseSchema):
|
|
|
281
286
|
if isinstance(self.__deps[module], DependencySchema):
|
|
282
287
|
self.__deps[module]._populate_deps(module_map)
|
|
283
288
|
|
|
284
|
-
def _reset_deps(self):
|
|
289
|
+
def _reset_deps(self) -> None:
|
|
285
290
|
'''Resets the internal dependency dictionary.'''
|
|
286
291
|
self.__deps = {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import contextlib
|
|
2
2
|
|
|
3
|
-
from typing import List, Tuple
|
|
3
|
+
from typing import List, Tuple, Optional, Union, Iterable
|
|
4
4
|
|
|
5
5
|
from siliconcompiler import utils
|
|
6
6
|
|
|
@@ -44,10 +44,10 @@ class FileSetSchema(PathSchema):
|
|
|
44
44
|
###############################################
|
|
45
45
|
def add_file(self,
|
|
46
46
|
filename: str,
|
|
47
|
-
fileset: str = None,
|
|
48
|
-
filetype: str = None,
|
|
47
|
+
fileset: Optional[str] = None,
|
|
48
|
+
filetype: Optional[str] = None,
|
|
49
49
|
clobber: bool = False,
|
|
50
|
-
dataroot: str = None) -> List[str]:
|
|
50
|
+
dataroot: Optional[str] = None) -> List[str]:
|
|
51
51
|
"""
|
|
52
52
|
Adds files to a fileset.
|
|
53
53
|
|
|
@@ -121,8 +121,8 @@ class FileSetSchema(PathSchema):
|
|
|
121
121
|
|
|
122
122
|
###############################################
|
|
123
123
|
def get_file(self,
|
|
124
|
-
fileset: str = None,
|
|
125
|
-
filetype: str = None):
|
|
124
|
+
fileset: Optional[str] = None,
|
|
125
|
+
filetype: Optional[str] = None) -> List[str]:
|
|
126
126
|
"""Returns a list of files from one or more filesets.
|
|
127
127
|
|
|
128
128
|
Args:
|
|
@@ -159,7 +159,7 @@ class FileSetSchema(PathSchema):
|
|
|
159
159
|
return filelist
|
|
160
160
|
|
|
161
161
|
###############################################
|
|
162
|
-
def has_file(self, fileset: str = None, filetype: str = None) -> bool:
|
|
162
|
+
def has_file(self, fileset: Optional[str] = None, filetype: Optional[str] = None) -> bool:
|
|
163
163
|
"""Returns true if the fileset contains files.
|
|
164
164
|
|
|
165
165
|
Args:
|
|
@@ -225,7 +225,7 @@ class FileSetSchema(PathSchema):
|
|
|
225
225
|
with self._active(fileset=fileset):
|
|
226
226
|
yield
|
|
227
227
|
|
|
228
|
-
def copy_fileset(self, src_fileset: str, dst_fileset: str, clobber: bool = False):
|
|
228
|
+
def copy_fileset(self, src_fileset: str, dst_fileset: str, clobber: bool = False) -> None:
|
|
229
229
|
"""
|
|
230
230
|
Creates a new copy of a source fileset.
|
|
231
231
|
|
|
@@ -248,7 +248,7 @@ class FileSetSchema(PathSchema):
|
|
|
248
248
|
new_fs = self.get("fileset", src_fileset, field="schema").copy()
|
|
249
249
|
EditableSchema(self).insert("fileset", dst_fileset, new_fs, clobber=True)
|
|
250
250
|
|
|
251
|
-
def _assert_fileset(self, fileset: str) -> None:
|
|
251
|
+
def _assert_fileset(self, fileset: Union[None, Iterable[str], str]) -> None:
|
|
252
252
|
"""
|
|
253
253
|
Raises an error if the specified fileset does not exist.
|
|
254
254
|
|
|
@@ -257,6 +257,11 @@ class FileSetSchema(PathSchema):
|
|
|
257
257
|
LookupError: If the fileset is not found.
|
|
258
258
|
"""
|
|
259
259
|
|
|
260
|
+
if isinstance(fileset, (list, set, tuple)):
|
|
261
|
+
for fs in fileset:
|
|
262
|
+
self._assert_fileset(fs)
|
|
263
|
+
return
|
|
264
|
+
|
|
260
265
|
if not isinstance(fileset, str):
|
|
261
266
|
raise TypeError("fileset must be a string")
|
|
262
267
|
|
|
@@ -282,7 +287,7 @@ class FileSetSchema(PathSchema):
|
|
|
282
287
|
|
|
283
288
|
def _generate_doc(self, doc,
|
|
284
289
|
ref_root: str = "",
|
|
285
|
-
key_offset: Tuple[str] = None,
|
|
290
|
+
key_offset: Optional[Tuple[str, ...]] = None,
|
|
286
291
|
detailed: bool = True):
|
|
287
292
|
from ..schema.docs.utils import build_section
|
|
288
293
|
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import shutil
|
|
2
2
|
import sys
|
|
3
3
|
|
|
4
|
-
from typing import List, Tuple, TextIO
|
|
4
|
+
from typing import List, Tuple, TextIO, Union, Optional, TYPE_CHECKING
|
|
5
5
|
|
|
6
6
|
from siliconcompiler.schema import BaseSchema
|
|
7
7
|
from siliconcompiler.schema import EditableSchema, Parameter, PerNode, Scope
|
|
8
8
|
from siliconcompiler.schema.utils import trim
|
|
9
9
|
|
|
10
10
|
from siliconcompiler.utils import truncate_text, units
|
|
11
|
-
from siliconcompiler.schema_support.record import RecordTime
|
|
11
|
+
from siliconcompiler.schema_support.record import RecordTime, RecordSchema
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from pandas import DataFrame
|
|
16
|
+
from siliconcompiler import Flowgraph
|
|
12
17
|
|
|
13
18
|
|
|
14
19
|
class MetricSchema(BaseSchema):
|
|
@@ -111,7 +116,7 @@ class MetricSchema(BaseSchema):
|
|
|
111
116
|
Metric tracking the total amount of time spent from the beginning
|
|
112
117
|
of the run up to and including the current step and index.""")))
|
|
113
118
|
|
|
114
|
-
def clear(self, step, index):
|
|
119
|
+
def clear(self, step: str, index: Union[int, str]) -> None:
|
|
115
120
|
'''
|
|
116
121
|
Clears all saved metrics for a given step and index.
|
|
117
122
|
|
|
@@ -122,7 +127,11 @@ class MetricSchema(BaseSchema):
|
|
|
122
127
|
for metric in self.getkeys():
|
|
123
128
|
self.unset(metric, step=step, index=str(index))
|
|
124
129
|
|
|
125
|
-
def record(self,
|
|
130
|
+
def record(self,
|
|
131
|
+
step: str, index: Union[str, int],
|
|
132
|
+
metric: str,
|
|
133
|
+
value: Union[float, int],
|
|
134
|
+
unit: Optional[str] = None):
|
|
126
135
|
"""
|
|
127
136
|
Records a metric value for a specific step and index.
|
|
128
137
|
|
|
@@ -141,7 +150,7 @@ class MetricSchema(BaseSchema):
|
|
|
141
150
|
Returns:
|
|
142
151
|
The recorded value after any unit conversion.
|
|
143
152
|
"""
|
|
144
|
-
metric_unit = self.get(metric, field='unit')
|
|
153
|
+
metric_unit: Optional[str] = self.get(metric, field='unit')
|
|
145
154
|
|
|
146
155
|
if not metric_unit and unit:
|
|
147
156
|
raise ValueError(f"{metric} does not have a unit, but {unit} was supplied")
|
|
@@ -151,7 +160,7 @@ class MetricSchema(BaseSchema):
|
|
|
151
160
|
|
|
152
161
|
return self.set(metric, value, step=step, index=str(index))
|
|
153
162
|
|
|
154
|
-
def record_tasktime(self, step, index, record):
|
|
163
|
+
def record_tasktime(self, step: str, index: Union[str, int], record: RecordSchema):
|
|
155
164
|
"""
|
|
156
165
|
Records the task time for a given node based on start and end times.
|
|
157
166
|
|
|
@@ -173,7 +182,10 @@ class MetricSchema(BaseSchema):
|
|
|
173
182
|
|
|
174
183
|
return self.record(step, index, "tasktime", end_time-start_time, unit="s")
|
|
175
184
|
|
|
176
|
-
def record_totaltime(self,
|
|
185
|
+
def record_totaltime(self,
|
|
186
|
+
step: str, index: Union[str, int],
|
|
187
|
+
flow: "Flowgraph",
|
|
188
|
+
record: RecordSchema):
|
|
177
189
|
"""
|
|
178
190
|
Records the cumulative total time up to the end of a given node.
|
|
179
191
|
|
|
@@ -237,7 +249,7 @@ class MetricSchema(BaseSchema):
|
|
|
237
249
|
|
|
238
250
|
return self.record(step, index, "totaltime", total_time, unit="s")
|
|
239
251
|
|
|
240
|
-
def get_formatted_metric(self, metric: str, step: str, index: str) -> str:
|
|
252
|
+
def get_formatted_metric(self, metric: str, step: str, index: Union[int, str]) -> str:
|
|
241
253
|
'''
|
|
242
254
|
Retrieves and formats a metric for display.
|
|
243
255
|
|
|
@@ -264,10 +276,10 @@ class MetricSchema(BaseSchema):
|
|
|
264
276
|
self.get(metric, field="unit"))
|
|
265
277
|
|
|
266
278
|
def summary_table(self,
|
|
267
|
-
nodes: List[Tuple[str, str]] = None,
|
|
279
|
+
nodes: Optional[List[Tuple[str, str]]] = None,
|
|
268
280
|
column_width: int = 15,
|
|
269
281
|
formatted: bool = True,
|
|
270
|
-
trim_empty_metrics: bool = True):
|
|
282
|
+
trim_empty_metrics: bool = True) -> "DataFrame":
|
|
271
283
|
'''
|
|
272
284
|
Generates a summary of metrics as a pandas DataFrame.
|
|
273
285
|
|
|
@@ -289,11 +301,11 @@ class MetricSchema(BaseSchema):
|
|
|
289
301
|
from pandas import DataFrame
|
|
290
302
|
|
|
291
303
|
if not nodes:
|
|
292
|
-
|
|
304
|
+
unique_nodes = set()
|
|
293
305
|
for metric in self.getkeys():
|
|
294
|
-
for
|
|
295
|
-
|
|
296
|
-
nodes = list(sorted(
|
|
306
|
+
for _, step, index in self.get(metric, field=None).getvalues():
|
|
307
|
+
unique_nodes.add((step, index))
|
|
308
|
+
nodes = list(sorted(unique_nodes))
|
|
297
309
|
|
|
298
310
|
row_labels = list(self.getkeys())
|
|
299
311
|
sort_map = {metric: 0 for metric in row_labels}
|
|
@@ -352,10 +364,10 @@ class MetricSchema(BaseSchema):
|
|
|
352
364
|
return DataFrame(data, row_labels, column_labels)
|
|
353
365
|
|
|
354
366
|
def summary(self,
|
|
355
|
-
headers: List[Tuple[str, str]],
|
|
356
|
-
nodes: List[Tuple[str, str]] = None,
|
|
367
|
+
headers: List[Tuple[str, Optional[str]]],
|
|
368
|
+
nodes: Optional[List[Tuple[str, str]]] = None,
|
|
357
369
|
column_width: int = 15,
|
|
358
|
-
fd: TextIO = None) -> None:
|
|
370
|
+
fd: Optional[TextIO] = None) -> None:
|
|
359
371
|
'''
|
|
360
372
|
Prints a formatted summary of metrics to a file descriptor.
|
|
361
373
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Union, Dict, List, Tuple
|
|
1
|
+
from typing import Union, Dict, List, Tuple, Optional
|
|
2
2
|
|
|
3
3
|
from siliconcompiler.schema_support.pathschema import PathSchema
|
|
4
4
|
from siliconcompiler.schema import EditableSchema, Parameter, Scope, BaseSchema
|
|
@@ -196,7 +196,7 @@ class PackageSchema(PathSchema):
|
|
|
196
196
|
|
|
197
197
|
def _generate_doc(self, doc,
|
|
198
198
|
ref_root: str = "",
|
|
199
|
-
key_offset: Tuple[str] = None,
|
|
199
|
+
key_offset: Optional[Tuple[str, ...]] = None,
|
|
200
200
|
detailed: bool = True):
|
|
201
201
|
from ..schema.docs.utils import build_section
|
|
202
202
|
section = build_section("Package", f"{ref_root}-package")
|
|
@@ -3,7 +3,7 @@ import logging
|
|
|
3
3
|
|
|
4
4
|
import os.path
|
|
5
5
|
|
|
6
|
-
from typing import Tuple
|
|
6
|
+
from typing import Tuple, Union, List, Optional, Dict, Callable
|
|
7
7
|
|
|
8
8
|
from siliconcompiler.schema.baseschema import BaseSchema
|
|
9
9
|
from siliconcompiler.schema.editableschema import EditableSchema
|
|
@@ -19,9 +19,10 @@ class PathSchemaBase(BaseSchema):
|
|
|
19
19
|
Schema extension to add simpler find_files and check_filepaths
|
|
20
20
|
'''
|
|
21
21
|
|
|
22
|
-
def find_files(self, *keypath,
|
|
23
|
-
missing_ok=False,
|
|
24
|
-
step=None, index=None)
|
|
22
|
+
def find_files(self, *keypath: str,
|
|
23
|
+
missing_ok: bool = False,
|
|
24
|
+
step: Optional[str] = None, index: Optional[Union[int, str]] = None) \
|
|
25
|
+
-> Union[List[Optional[str]], Optional[str]]:
|
|
25
26
|
"""
|
|
26
27
|
Returns absolute paths to files or directories based on the keypath
|
|
27
28
|
provided.
|
|
@@ -59,7 +60,7 @@ class PathSchemaBase(BaseSchema):
|
|
|
59
60
|
collection_dir=collection_dir,
|
|
60
61
|
cwd=cwd)
|
|
61
62
|
|
|
62
|
-
def check_filepaths(self, ignore_keys=None):
|
|
63
|
+
def check_filepaths(self, ignore_keys: Optional[List[Tuple[str, ...]]] = None) -> bool:
|
|
63
64
|
'''
|
|
64
65
|
Verifies that paths to all files in manifest are valid.
|
|
65
66
|
|
|
@@ -82,8 +83,13 @@ class PathSchemaBase(BaseSchema):
|
|
|
82
83
|
collection_dir=collection_dir,
|
|
83
84
|
cwd=cwd)
|
|
84
85
|
|
|
85
|
-
def hash_files(self, *keypath
|
|
86
|
-
|
|
86
|
+
def hash_files(self, *keypath: str,
|
|
87
|
+
update: bool = True,
|
|
88
|
+
check: bool = True,
|
|
89
|
+
verbose: bool = True,
|
|
90
|
+
missing_ok: bool = False,
|
|
91
|
+
step: Optional[str] = None, index: Optional[Union[str, int]] = None) \
|
|
92
|
+
-> Union[Optional[str], List[Optional[str]]]:
|
|
87
93
|
'''Generates hash values for a list of parameter files.
|
|
88
94
|
|
|
89
95
|
Generates a hash value for each file found in the keypath. If existing
|
|
@@ -157,7 +163,8 @@ class PathSchemaBase(BaseSchema):
|
|
|
157
163
|
|
|
158
164
|
|
|
159
165
|
class PathSchemaSimpleBase(PathSchemaBase):
|
|
160
|
-
def find_files(self, *keypath, missing_ok=False)
|
|
166
|
+
def find_files(self, *keypath: str, missing_ok: bool = False) \
|
|
167
|
+
-> Union[List[Optional[str]], Optional[str]]:
|
|
161
168
|
"""
|
|
162
169
|
Returns absolute paths to files or directories based on the keypath
|
|
163
170
|
provided.
|
|
@@ -181,7 +188,12 @@ class PathSchemaSimpleBase(PathSchemaBase):
|
|
|
181
188
|
missing_ok=missing_ok,
|
|
182
189
|
step=None, index=None)
|
|
183
190
|
|
|
184
|
-
def hash_files(self, *keypath
|
|
191
|
+
def hash_files(self, *keypath: str,
|
|
192
|
+
update: bool = True,
|
|
193
|
+
check: bool = True,
|
|
194
|
+
verbose: bool = True,
|
|
195
|
+
missing_ok: bool = False) \
|
|
196
|
+
-> Union[List[Optional[str]], Optional[str]]:
|
|
185
197
|
'''Generates hash values for a list of parameter files.
|
|
186
198
|
|
|
187
199
|
Generates a hash value for each file found in the keypath. If existing
|
|
@@ -299,9 +311,9 @@ class PathSchema(PathSchemaBase):
|
|
|
299
311
|
return schema
|
|
300
312
|
|
|
301
313
|
def set_dataroot(self, name: str = "root",
|
|
302
|
-
path: str = None,
|
|
303
|
-
tag: str = None,
|
|
304
|
-
clobber: bool = False):
|
|
314
|
+
path: Optional[str] = None,
|
|
315
|
+
tag: Optional[str] = None,
|
|
316
|
+
clobber: bool = False) -> None:
|
|
305
317
|
"""Registers a data source by name, path, and optional version tag.
|
|
306
318
|
|
|
307
319
|
This method creates a reference to a data directory, which can be a local
|
|
@@ -374,13 +386,13 @@ class PathSchema(PathSchemaBase):
|
|
|
374
386
|
if not BaseSchema.valid(schema, "dataroot", name):
|
|
375
387
|
raise ValueError(f"{name} is not a recognized source")
|
|
376
388
|
|
|
377
|
-
path = BaseSchema.get(schema, "dataroot", name, "path")
|
|
378
|
-
tag = BaseSchema.get(schema, "dataroot", name, "tag")
|
|
389
|
+
path: str = BaseSchema.get(schema, "dataroot", name, "path")
|
|
390
|
+
tag: Optional[str] = BaseSchema.get(schema, "dataroot", name, "tag")
|
|
379
391
|
|
|
380
392
|
resolver = Resolver.find_resolver(path)
|
|
381
393
|
return resolver(name, schema._parent(root=True), path, tag).get_path()
|
|
382
394
|
|
|
383
|
-
def _find_files_dataroot_resolvers(self):
|
|
395
|
+
def _find_files_dataroot_resolvers(self) -> Dict[str, Union[str, Callable]]:
|
|
384
396
|
"""
|
|
385
397
|
Returns a dictionary of path resolvers data directory handling for find_files
|
|
386
398
|
|
|
@@ -402,7 +414,7 @@ class PathSchema(PathSchemaBase):
|
|
|
402
414
|
return resolver_map
|
|
403
415
|
|
|
404
416
|
@contextlib.contextmanager
|
|
405
|
-
def active_dataroot(self, dataroot: str = None):
|
|
417
|
+
def active_dataroot(self, dataroot: Optional[str] = None):
|
|
406
418
|
'''
|
|
407
419
|
Use this context to set the dataroot parameter on files and directory parameters.
|
|
408
420
|
|
|
@@ -426,7 +438,7 @@ class PathSchema(PathSchemaBase):
|
|
|
426
438
|
with self._active(dataroot=dataroot):
|
|
427
439
|
yield
|
|
428
440
|
|
|
429
|
-
def _get_active_dataroot(self, user_dataroot: str) -> str:
|
|
441
|
+
def _get_active_dataroot(self, user_dataroot: Optional[str]) -> Optional[str]:
|
|
430
442
|
"""Resolves and returns the active dataroot to use.
|
|
431
443
|
|
|
432
444
|
This method determines the appropriate dataroot based on a specific
|
|
@@ -475,7 +487,7 @@ class PathSchema(PathSchemaBase):
|
|
|
475
487
|
|
|
476
488
|
def _generate_doc(self, doc,
|
|
477
489
|
ref_root: str = "",
|
|
478
|
-
key_offset: Tuple[str] = None,
|
|
490
|
+
key_offset: Optional[Tuple[str, ...]] = None,
|
|
479
491
|
detailed: bool = True):
|
|
480
492
|
from ..schema.docs.utils import build_section, strong, build_table, build_list, \
|
|
481
493
|
code, para
|