MCPcopy Create free account
hub / github.com/Open-Bee/DataStudio / exists

Method exists

datastudio/utils/database.py:253–266  ·  view source on GitHub ↗

Check if image exists in cache. Args: image_path: Image path to check. Returns: bool: True if image exists.

(self, image_path: str)

Source from the content-addressed store, hash-verified

251 return shard_id, hex_digest.encode()
252
253 def exists(self, image_path: str) -> bool:
254 """Check if image exists in cache.
255
256 Args:
257 image_path: Image path to check.
258
259 Returns:
260 bool: True if image exists.
261 """
262 shard_id, key = self._get_shard_id_and_key(image_path)
263 env = self._get_env(shard_id)
264
265 with env.begin(write=False) as txn:
266 return txn.get(key) is not None
267
268 def put(self, image_path: str, img_bytes: bytes) -> bool:
269 """Write a single image to cache.

Callers 15

test_existsMethod · 0.95
_get_envMethod · 0.80
_open_read_envMethod · 0.80
parse_fileFunction · 0.80
_loadMethod · 0.80
_load_promptMethod · 0.80
saveMethod · 0.80
checkMethod · 0.80
test_save_cfgMethod · 0.80
test_export_csvMethod · 0.80

Calls 3

_get_shard_id_and_keyMethod · 0.95
_get_envMethod · 0.95
getMethod · 0.45

Tested by 15

test_existsMethod · 0.76
test_save_cfgMethod · 0.64
test_export_csvMethod · 0.64
test_export_jsonMethod · 0.64
test_save_jsonMethod · 0.64
test_save_jsonlMethod · 0.64