MCPcopy
hub / github.com/omkarcloud/botasaurus / get_random_items

Method get_random_items

botasaurus/cache.py:352–363  ·  view source on GitHub ↗
(func, n=5)

Source from the content-addressed store, hash-verified

350
351 @staticmethod
352 def get_random_items(func, n=5):
353 import random
354
355 hashes = Cache.get_items_hashes(func, None)
356 if n is not None:
357 hashes = random.sample(hashes, n)
358 else:
359 random.shuffle(hashes)
360
361 fn_name = getfnname(func)
362 paths = [relative_path(f'{Cache.cache_directory}{fn_name}/{r}.json') for r in hashes]
363 return _read_json_files(paths)
364 @staticmethod
365 def get_items_hashes(func, items=None):
366

Callers

nothing calls this directly

Calls 4

getfnnameFunction · 0.85
get_items_hashesMethod · 0.80
relative_pathFunction · 0.70
_read_json_filesFunction · 0.70

Tested by

no test coverage detected