add readonly tracking to Chip
@@ -85,6 +85,10 @@ class Chip:
self.error("""SiliconCompiler must be run from a directory that exists.
If you are sure that your working directory is valid, try running `cd $(pwd)`.""", fatal=True)
+ # Indicates that the chip object is marked as read only and should not
+ # allow modifications to schema
+ self._readonly = False
+
self.schema = Schema()
# The 'status' dictionary can be used to store ephemeral config values.
@@ -825,6 +829,9 @@ If you are sure that your working directory is valid, try running `cd $(pwd)`.""
if keypath == ['option', 'loglevel'] and field == 'value':
self.logger.setLevel(value)
+ if self._readonly:
+ raise SiliconCompilerError("Chip object is read only.")
+
try:
if not self.schema.set(
*keypath, value, field=field, clobber=clobber, step=step, index=index
@@ -854,6 +861,9 @@ If you are sure that your working directory is valid, try running `cd $(pwd)`.""
'''
self.logger.debug(f'Unsetting {keypath}')
+ if self._readonly:
+ raise SiliconCompilerError("Chip object is read only.")
+
if not self.schema.unset(*keypath, step=step, index=index):
self.logger.debug(f'Failed to unset value for {keypath}: parameter is locked')
@@ -885,6 +895,9 @@ If you are sure that your working directory is valid, try running `cd $(pwd)`.""
value = args[-1]
self.logger.debug(f'Appending value {value} to {keypath}')
+ if self._readonly:
+ raise SiliconCompilerError("Chip object is read only.")
+
try:
if not self.schema.add(*args, field=field, step=step, index=index):
# TODO: this message should be pushed down into Schema.add()
