Support generation of random object IDs
@@ -52,9 +52,13 @@ class KgtkInfoTable(object):
def make_object_id(self, prefix, *keys):
"""Create a unique object ID starting with 'prefix' and based on 'keys'.
+ If no 'keys' are supplied, append a new random UUID to 'prefix'.
"""
# we only use this during DB updates, so the import overhead should be negligible:
import shortuuid
+ if len(keys) == 0:
+ return prefix + shortuuid.random(22)
+ else:
return prefix + shortuuid.uuid(r'_/^^\_'.join(map(str, keys)))
@lru_cache(maxsize=None)
