siliconcompiler 0.25.0__cp39-cp39-win_amd64.whl → 0.26.1__cp39-cp39-win_amd64.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.
@@ -1,5 +1,5 @@
1
1
  # Version number following semver standard.
2
- version = '0.25.0'
2
+ version = '0.26.1'
3
3
 
4
4
  # Default server address for remote runs, if unspecified.
5
5
  default_server = 'https://server.siliconcompiler.com'
@@ -80,6 +80,9 @@ def main():
80
80
  chip.summary()
81
81
  except SiliconCompilerError:
82
82
  return 1
83
+ except Exception as e:
84
+ chip.logger.error(e)
85
+ return 1
83
86
 
84
87
  return 0
85
88
 
@@ -5,9 +5,9 @@ import sys
5
5
 
6
6
  from siliconcompiler import Chip
7
7
  from siliconcompiler import SiliconCompilerError
8
- from siliconcompiler.remote.client import (cancel_job, check_progress, delete_job,
9
- remote_ping, remote_run_loop, configure,
10
- _remote_ping)
8
+ from siliconcompiler.remote.client import cancel_job, check_progress, delete_job, \
9
+ remote_ping, remote_run_loop, _remote_ping
10
+ from siliconcompiler.remote.client import configure_server, configure_whitelist, configure_print
11
11
  from siliconcompiler.scheduler import _finalize_run
12
12
  from siliconcompiler.flowgraph import _get_flowgraph_entry_nodes, _get_flowgraph_node_outputs, \
13
13
  nodes_to_execute
@@ -27,6 +27,14 @@ To generate a configuration file, use:
27
27
  sc-remote -configure -server https://example.com
28
28
  sc-remote -configure -server https://example.com:1234
29
29
 
30
+ to add or remove directories from upload whitelist, these
31
+ also support globbing:
32
+ sc-remote -configure -add ./fine_to_upload
33
+ sc-remote -configure -remove ./no_longer_okay_to_upload
34
+
35
+ to display the full configuration of the credentials file
36
+ sc-remote -configure -list
37
+
30
38
  To check an ongoing job's progress, use:
31
39
  sc-remote -cfg <stepdir>/outputs/<design>.pkg.json
32
40
 
@@ -49,9 +57,20 @@ To delete a job, use:
49
57
  '-configure': {'action': 'store_true',
50
58
  'help': 'create configuration file for the remote',
51
59
  'sc_print': False},
52
- '-server': {'help': 'address of server for configure',
60
+ '-server': {'help': 'address of server for configure (only valid with -configure)',
53
61
  'metavar': '<server>',
54
62
  'sc_print': False},
63
+ '-add': {'help': 'path to add to the upload whitelist (only valid with -configure)',
64
+ 'metavar': '<path>',
65
+ 'nargs': '+',
66
+ 'sc_print': False},
67
+ '-remove': {'help': 'path to remove from the upload whitelist (only valid with -configure)',
68
+ 'metavar': '<path>',
69
+ 'nargs': '+',
70
+ 'sc_print': False},
71
+ '-list': {'help': 'print the current configuration (only valid with -configure)',
72
+ 'action': 'store_true',
73
+ 'sc_print': False},
55
74
  '-reconnect': {'action': 'store_true',
56
75
  'help': 'reconnect to a running job on the remote',
57
76
  'sc_print': False},
@@ -88,11 +107,23 @@ To delete a job, use:
88
107
  f'{", ".join(["-"+e for e in cfg_only])}')
89
108
 
90
109
  if args['configure']:
91
- try:
92
- configure(chip, server=args['server'])
93
- except ValueError as e:
94
- chip.logger.error(e)
95
- return 1
110
+ if args['list']:
111
+ configure_print(chip)
112
+ return 0
113
+
114
+ if not args['add'] and not args['remove']:
115
+ try:
116
+ configure_server(chip, server=args['server'])
117
+ except ValueError as e:
118
+ chip.logger.error(e)
119
+ return 1
120
+ else:
121
+ try:
122
+ configure_whitelist(chip, add=args['add'], remove=args['remove'])
123
+ except ValueError as e:
124
+ chip.logger.error(e)
125
+ return 1
126
+
96
127
  return 0
97
128
 
98
129
  # Main logic.
@@ -0,0 +1,192 @@
1
+ # Copyright 2023 Silicon Compiler Authors. All Rights Reserved.
2
+ import argparse
3
+ import sys
4
+ import os
5
+ import importlib
6
+ from inspect import getmembers, isfunction, getfullargspec
7
+ from siliconcompiler._metadata import version
8
+ from siliconcompiler.schema import utils
9
+
10
+
11
+ __default_source_file = "make.py"
12
+
13
+
14
+ def __process_file(path):
15
+ if not os.path.exists(path):
16
+ return {}, None, None
17
+ mod_name = 'scmake'
18
+ spec = importlib.util.spec_from_file_location(mod_name, path)
19
+ make = importlib.util.module_from_spec(spec)
20
+ sys.modules[mod_name] = make
21
+ syspath = sys.path.copy()
22
+ sys.path.insert(0, os.getcwd())
23
+ spec.loader.exec_module(make)
24
+ sys.path = syspath
25
+
26
+ args = {}
27
+ for name, func in getmembers(make, isfunction):
28
+ if name.startswith('_'):
29
+ continue
30
+
31
+ # generate doc
32
+ docstring = utils.trim(func.__doc__)
33
+ if not docstring:
34
+ docstring = f"run \"{name}\""
35
+ short_help = docstring.splitlines()[0]
36
+
37
+ func_spec = getfullargspec(func)
38
+
39
+ func_args = {}
40
+ for arg in func_spec.args:
41
+ arg_type = str
42
+ if arg in func_spec.annotations:
43
+ arg_type = func_spec.annotations[arg]
44
+ func_args[arg] = arg_type
45
+
46
+ args[name] = {
47
+ "function": func,
48
+ "help": short_help,
49
+ "full_help": docstring,
50
+ "args": func_args
51
+ }
52
+
53
+ if args:
54
+ default_arg = list(args.keys())[0]
55
+ else:
56
+ default_arg = None
57
+
58
+ default_arg = getattr(make, '__scdefault', default_arg)
59
+
60
+ module_help = utils.trim(make.__doc__)
61
+
62
+ return args, default_arg, module_help
63
+
64
+
65
+ def main():
66
+ progname = "smake"
67
+ description = f"""-----------------------------------------------------------
68
+ SC app that provides an Makefile like interface to python
69
+ configuration files. This utility app will analyze a file
70
+ "{__default_source_file}" or the file specified with --file to determine
71
+ the available targets.
72
+
73
+ To view the help, use:
74
+ smake --help
75
+
76
+ or view the help for a specific target:
77
+ smake --help <target>
78
+
79
+ To run a target, use:
80
+ smake <target>
81
+
82
+ or run a target from a file other than "{__default_source_file}":
83
+ smake --file <file> <target>
84
+
85
+ or run a target in a different directory:
86
+ smake --directory <directory> <target>
87
+
88
+ To run a target with supported arguments, use:
89
+ smake <target> --flow asicflow
90
+ -----------------------------------------------------------"""
91
+
92
+ # handle source file identification before arg parse
93
+ source_file = __default_source_file
94
+ file_args = ('--file', '-f')
95
+ for file_arg in file_args:
96
+ if file_arg in sys.argv:
97
+ source_file_idx = sys.argv.index(file_arg) + 1
98
+ if source_file_idx < len(sys.argv):
99
+ source_file = sys.argv[source_file_idx]
100
+ else:
101
+ source_file = None
102
+ break
103
+
104
+ # handle directory identification before arg parse
105
+ source_dir = os.getcwd()
106
+ dir_args = ('--directory', '-C')
107
+ for file_arg in dir_args:
108
+ if file_arg in sys.argv:
109
+ source_dir_idx = sys.argv.index(file_arg) + 1
110
+ if source_dir_idx < len(sys.argv):
111
+ source_dir = sys.argv[source_dir_idx]
112
+ else:
113
+ source_dir = None
114
+ break
115
+
116
+ if source_dir:
117
+ if not os.path.isdir(source_dir):
118
+ print(f"Unable to change directory to {source_dir}")
119
+ return 1
120
+
121
+ os.chdir(source_dir)
122
+
123
+ make_args = {}
124
+ default_arg = None
125
+ module_help = None
126
+ if source_file:
127
+ make_args, default_arg, module_help = __process_file(source_file)
128
+
129
+ if module_help:
130
+ description += \
131
+ f"\n\n{module_help}\n\n-----------------------------------------------------------"
132
+
133
+ parser = argparse.ArgumentParser(
134
+ progname,
135
+ description=description,
136
+ formatter_class=argparse.RawDescriptionHelpFormatter)
137
+
138
+ parser.add_argument(
139
+ *file_args,
140
+ metavar='<file>',
141
+ help=f'Use file as makefile, default is {__default_source_file}')
142
+
143
+ parser.add_argument(
144
+ *dir_args,
145
+ metavar='<directory>',
146
+ help='Change to directory <directory> before reading the makefile.')
147
+
148
+ parser.add_argument(
149
+ '--version', '-v',
150
+ action='version',
151
+ version=version)
152
+
153
+ targetparsers = parser.add_subparsers(
154
+ dest='target',
155
+ metavar='<target>',
156
+ help='Target to execute')
157
+
158
+ for arg, info in make_args.items():
159
+ subparse = targetparsers.add_parser(
160
+ arg,
161
+ description=info['full_help'],
162
+ help=info['help'])
163
+
164
+ for subarg, subarg_type in info['args'].items():
165
+ subparse.add_argument(
166
+ f'--{subarg}',
167
+ dest=f'sub_{subarg}',
168
+ metavar=f'<{subarg}>',
169
+ type=subarg_type)
170
+
171
+ args = parser.parse_args()
172
+ target = args.target
173
+ if not target:
174
+ target = default_arg
175
+
176
+ if not os.path.isfile(source_file):
177
+ print(f"Unable to load {source_file}")
178
+ return 1
179
+
180
+ call_args = {}
181
+ args_vars = vars(args)
182
+ for arg in make_args[target]["args"]:
183
+ if f'sub_{arg}' in args_vars and args_vars[f'sub_{arg}'] is not None:
184
+ call_args[arg] = args_vars[f'sub_{arg}']
185
+ make_args[target]["function"](**call_args)
186
+
187
+ return 0
188
+
189
+
190
+ #########################
191
+ if __name__ == "__main__":
192
+ sys.exit(main())