Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def print_default():
config = tiledb.Config()
print("\nDefault settings:")
for p in config.items():
print("\"%s\" : \"%s\"" % (p[0], p[1]))
def main():
config = tiledb.Config()
# Print the default config parameters
print("Default settings:\n{0!r}".format(config))
# Set values
config["vfs.s3.connect_timeout_ms"] = 5000
config["vfs.s3.endpoint_override"] = "localhost:88880"
# Get values
tile_cache_size = config["sm.tile_cache_size"]
print("\nTile cache size: ", tile_cache_size)
# Print only the s3 settings
print("\nVFS S3 settings:")
for p, v in config.items(prefix="vfs.s3."):
print("{0!r} : {1!r}".format(p, v))
def execute(cls, ctx, op):
tiledb_config = tiledb.Config(op.tiledb_config)
uri = op.tiledb_uri
key = op.tiledb_key
tiledb.consolidate(config=tiledb_config, uri=uri, key=key)
ctx[op.outputs[0].key] = ctx[op.inputs[0].key]
def open(uri, mode='r', key=None, attr=None, config=None, ctx=None):
"""
Open a TileDB array at the given URI
:param uri: any TileDB supported URI
:param key: encryption key, str or None
:param str mode: (default 'r') Open the array object in read 'r' or write 'w' mode
:param attr: attribute name to select from a multi-attribute array, str or None
:param config: TileDB config dictionary, dict or None
:return: open TileDB {Sparse,Dense}Array object
"""
if ctx and config:
raise ValueError("Received extra Ctx or Config argument: either one may be provided, but not both")
if config:
cfg = tiledb.Config(config)
ctx = tiledb.Ctx(cfg)
if ctx is None:
ctx = default_ctx()
return tiledb.Array.load_typed(uri, mode, key, None, attr, ctx)
def save_load_config():
# Save to file
config = tiledb.Config()
config["sm.tile_cache_size"] = 0
config.save("tiledb_config.txt")
# Load from file
config_load = tiledb.Config.load("tiledb_config.txt")
print("\nTile cache size after loading from file: %s" % str(config_load["sm.tile_cache_size"]))
def empty_like(uri, arr, config=None, key=None, tile=None, ctx=None):
"""
Create and return an empty, writeable DenseArray with schema based on
a NumPy-array like object.
:param uri: array URI
:param arr: NumPy ndarray, or shape tuple
:param config: (optional, deprecated) configuration to apply to *new* Ctx
:param key: (optional) encryption key, if applicable
:param tile: (optional) tiling of generated array
:param ctx: (optional) TileDB Ctx
:return:
"""
if config is not None:
warnings.warn(DeprecationWarning("'config' keyword argument is deprecated; use 'ctx'"))
cfg = tiledb.Config(config)
ctx = tiledb.Ctx(cfg)
elif ctx is None:
ctx = default_ctx()
if arr is ArraySchema:
schema = arr
else:
schema = schema_like(arr, tile=tile, ctx=ctx)
tiledb.DenseArray.create(uri, key=key, schema=schema)
return tiledb.DenseArray(uri, mode='w', key=key, ctx=ctx)
def set_get_config():
config = tiledb.Config()
# Set value
config["vfs.s3.connect_timeout_ms"] = 5000
# Get value
tile_cache_size = config["sm.tile_cache_size"]
print("Tile cache size: %s" % str(tile_cache_size))
def set_get_config_ctx_vfs():
# Create config object
config = tiledb.Config()
# Set/get config to/from ctx
ctx = tiledb.Ctx(config)
config_ctx = ctx.config()
# Set/get config to/from VFS
vfs = tiledb.VFS(config)
config_vfs = vfs.config()
def iter_config_with_prefix():
config = tiledb.Config()
# Print only the S3 settings.
print("\nVFS S3 settings:")
for p in config.items("vfs.s3."):
print("\"%s\" : \"%s\"" % (p[0], p[1]))