def _make_artifact(self, artifact): proto_artifact = pb.ArtifactRecord() proto_artifact.type = artifact.type proto_artifact.name = artifact.name proto_artifact.digest = artifact.digest if artifact.distributed_id: proto_artifact.distributed_id = artifact.distributed_id if artifact.description: proto_artifact.description = artifact.description if artifact.metadata: proto_artifact.metadata = json.dumps(json_friendly_val(artifact.metadata)) # type: ignore proto_artifact.incremental_beta1 = artifact.incremental self._make_artifact_manifest(artifact.manifest, obj=proto_artifact.manifest) return proto_artifact
def _sanitize(self, key, val, allow_val_change=None): # Let jupyter change config freely by default if self._settings and self._settings._jupyter and allow_val_change is None: allow_val_change = True # We always normalize keys by stripping '-' key = key.strip("-") val = json_friendly_val(val) if not allow_val_change: if key in self._items and val != self._items[key]: raise config_util.ConfigError( ('Attempted to change value of key "{}" ' "from {} to {}\n" "If you really want to do this, pass" " allow_val_change=True to config.update()").format( key, self._items[key], val)) return key, val