Exemplo n.º 1
0
def get_version(func, versions):
    func_text = inspect.getsource(func)
    func_hash = hash_fn(remove_human_lines(func_text))
    func_file = inspect.getfile(func)
    func_dir = get_func_dir_from_file(func_file)

    if '/' in func_file:
        func_file = func_file[func_file.rfind('/'):]

    func_versions = versions[(versions.function_name == func.__name__) |
                             (versions.contained_in == func_file)]
    if func_hash in func_versions.function_hash.values:
        this_version = func_versions.loc[func_versions.function_hash ==
                                         func_hash, 'version'].values[0]
        return func.__name__, func_file, this_version
    if func_versions.shape[0] == 0:
        this_version = 1
    else:
        this_version = func_versions.version.max() + 1
    versions = versions.append(dict(function_name=func.__name__,
                                    contained_in=func_file,
                                    function_hash=func_hash,
                                    version=this_version,
                                    datetime=datetime.now(),
                                    function_text=func_text),
                               ignore_index=True)
    joblib.dump(versions, f'{func_dir}/.giterator/function_versions.pkl')
    return func.__name__, func_file, this_version
Exemplo n.º 2
0
 def getBucket(self, key):
     return hash_fn(key) % self.num_buckets
 def getShardNameForKey(self, key):
     shardNum = hash_fn(key) % self.num_shards
     return self.shard_list[shardNum]
 def getShardNameForKey(self, key):
     val = hash_fn(key)
     key_slot = bisect_left(self.key_space, val) % len(self.key_space)
     shard_keyspace = self.key_space[key_slot]
     shard_name = self.key_space_to_shard[shard_keyspace]
     return shard_name
 def remove_shard_metadata(self, shard_name):
     for i in range(self.num_rounds):
         val = hash_fn(shard_name + str(i))
         self.key_space.remove(val)
         del self.key_space_to_shard[val]
 def add_shard_metadata(self, shard_name):
     for i in range(self.num_rounds):
         val = hash_fn(shard_name + str(i))
         idx = bisect_left(self.key_space, val)
         self.key_space.insert(idx, val)
         self.key_space_to_shard[val] = shard_name
Exemplo n.º 7
0
 def remove_shard_metadata(self, shard_name):
     val = hash_fn(shard_name)
     self.key_space.remove(val)
     del self.key_space_to_shard[val]
Exemplo n.º 8
0
 def add_shard_metadata(self, shard_name):
     val = hash_fn(shard_name)
     idx = bisect_left(self.key_space, val)
     self.key_space.insert(idx, val)
     self.key_space_to_shard[val] = shard_name