Find a running TensorBoard instance compatible with the cache key.

  Returns:
    A `TensorBoardInfo` object, or `None` if none matches the cache key.
15251
def _find_matching_instance(cache_key):
  
  infos = get_all()
  candidates = [info for info in infos if info.cache_key == cache_key]
  for candidate in sorted(candidates, key=lambda x: x.port):
    # TODO(@wchargin): Check here that the provided port is still live.
    return candidate
  return None
224108
def cache(self):
        
        if not self._cache:
            use_cache = getattr(settings, 'USE_DRF_INSTANCE_CACHE', True)
            if use_cache:
                from django.core.cache import cache
                self._cache = cache
        return self._cache
883911
def tryload_cache(dpath, fname, cfgstr, verbose=None):
    
    try:
        return load_cache(dpath, fname, cfgstr, verbose=verbose)
    except IOError:
        return None
484323
def get_instance(in_memory=False, config_path=None, config_name=None):
  
  global __conf

  if __conf is None:
    __conf = Configuration(in_memory=in_memory, custom_cfg_path=config_path, config_name=config_name)

  return __conf
51464
def get(self, key, default=None):
        
        try:
            result = self._loads(self._client.hget(self.key_prefix, key))
            assert result is not None
            return result
        except (AssertionError, KeyError):
            return default or self._default
933570
def _load_from_cache_if_available(self, key):
    
    if key in self._cache:
      entity = self._cache[key]  # May be None, meaning "doesn't exist".
      if entity is None or entity._key == key:
        # If entity's key didn't change later, it is ok.
        # See issue 13.  http://goo.gl/jxjOP
        raise tasklets.Return(entity)
118459
def load(self, context):
    
    try:
      # pylint: disable=g-import-not-at-top,unused-import
      import tensorflow
      # Available in TensorFlow 1.14 or later, so do import check
      # pylint: disable=g-import-not-at-top,unused-import
      from tensorflow.python.eager import profiler_client
    except ImportError:
      return
    # pylint: disable=g-import-not-at-top
    from tensorboard.plugins.profile.profile_plugin import ProfilePlugin
    return ProfilePlugin(context)
190990
def get_from_cache(key):
        

        try:
            value = cache.get(key)
            return json.loads(value), key if value else None
        except Exception as e:
            # todo should add log.error()
            return None
881955
def get(self, object_type, cache_key):
        
        if object_type not in self.mapping or self.disabled:
            return None
        cache = self.mapping[object_type]
        if cache_key in cache:
            log.debug("Cache HIT: [%s %s]" % (object_type.capitalize(), cache_key))
            return cache[cache_key]
        else:
            log.debug('Cache MISS: [%s %s]' % (object_type.capitalize(), cache_key))
114482
def get_cache_item(self):
        ''''''
        if settings.DEBUG:
            raise AttributeError('Caching disabled in DEBUG mode')
        return getattr(self.template, self.options['template_cache_key'])
937331
def get_value(self, node):
		
		if isinstance(node,tf.Tensor):
			return self._cache.get(node.name,None)
		elif isinstance(node,tf.Operation):
			return None
		else: # handle ascii, unicode strings
			return self._cache.get(node,None)
947885
def stop_tensorboard(args):
    ''''''
    experiment_id = check_experiment_id(args)
    experiment_config = Experiments()
    experiment_dict = experiment_config.get_all_experiments()
    config_file_name = experiment_dict[experiment_id]['fileName']
    nni_config = Config(config_file_name)
    tensorboard_pid_list = nni_config.get_config('tensorboardPidList')
    if tensorboard_pid_list:
        for tensorboard_pid in tensorboard_pid_list:
            try:
                cmds = ['kill', '-9', str(tensorboard_pid)]
                call(cmds)
            except Exception as exception:
                print_error(exception)
        nni_config.set_config('tensorboardPidList', [])
        print_normal('Stop tensorboard success!')
    else:
        print_error('No tensorboard configuration!')
1336012
def _get_cache(self):
        
        if not self._cache:
            self._cache = get_cache(self.app)
        return self._cache
923678
def _get_keycachelike(self, keycache, keys, get_adds_dels, parentity, branch, turn, tick, *, forward):
        
        keycache_key = parentity + (branch,)
        keycache2 = keycache3 = None
        if keycache_key in keycache:
            keycache2 = keycache[keycache_key]
            if turn in keycache2:
                keycache3 = keycache2[turn]
                if tick in keycache3:
                    return keycache3[tick]
        if forward:
            # Take valid values from the past of a keycache and copy them forward, into the present.
            # Assumes that time is only moving forward, never backward, never skipping any turns or ticks,
            # and any changes to the world state are happening through allegedb proper, meaning they'll all get cached.
            # In LiSE this means every change to the world state should happen inside of a call to
            # ``Engine.next_turn`` in a rule.
            if keycache2 and keycache2.rev_gettable(turn):
                # there's a keycache from a prior turn in this branch. Get it
                if turn not in keycache2:
                    # since it's not this *exact* turn there might be changes...
                    old_turn = keycache2.rev_before(turn)
                    old_turn_kc = keycache2[turn]
                    added, deleted = get_adds_dels(
                        keys[parentity], branch, turn, tick, stoptime=(
                            branch, old_turn, old_turn_kc.end
                        )
                    )
                    ret = old_turn_kc[old_turn_kc.end].union(added).difference(deleted)
                    # assert ret == get_adds_dels(keys[parentity], branch, turn, tick)[0]  # slow
                    new_turn_kc = WindowDict()
                    new_turn_kc[tick] = ret
                    keycache2[turn] = new_turn_kc
                    return ret
                if not keycache3:
                    keycache3 = keycache2[turn]
                if tick not in keycache3:
                    if keycache3.rev_gettable(tick):
                        added, deleted = get_adds_dels(
                            keys[parentity], branch, turn, tick, stoptime=(
                                branch, turn, keycache3.rev_before(tick)
                            )
                        )
                        ret = keycache3[tick].union(added).difference(deleted)
                        # assert ret == get_adds_dels(keys[parentity], branch, turn, tick)[0]  # slow
                        keycache3[tick] = ret
                        return ret
                    else:
                        turn_before = keycache2.rev_before(turn)
                        tick_before = keycache2[turn_before].end
                        keys_before = keycache2[turn_before][tick_before]
                        added, deleted = get_adds_dels(
                            keys[parentity], branch, turn, tick, stoptime=(
                                branch, turn_before, tick_before
                            )
                        )
                        ret = keycache3[tick] = keys_before.union(added).difference(deleted)
                        # assert ret == get_adds_dels(keys[parentity], branch, turn, tick)[0]  # slow
                        return ret
                # assert kcturn[tick] == get_adds_dels(keys[parentity], branch, turn, tick)[0]  # slow
                return keycache3[tick]
            else:
                for (parbranch, parturn, partick) in self.db._iter_parent_btt(branch, turn, tick):
                    par_kc_key = parentity + (parbranch,)
                    if par_kc_key in keycache:
                        kcpkc = keycache[par_kc_key]
                        if parturn in kcpkc and kcpkc[parturn].rev_gettable(partick):
                            parkeys = kcpkc[parturn][partick]
                            break
                        elif kcpkc.rev_gettable(parturn-1):
                            partkeys = kcpkc[parturn-1]
                            parkeys = partkeys[partkeys.end]
                            break
                else:
                    parkeys = frozenset()
                keycache2 = SettingsTurnDict()
                added, deleted = get_adds_dels(
                    keys[parentity], branch, turn, tick, stoptime=(
                        parbranch, parturn, partick
                    )
                )
                ret = parkeys.union(added).difference(deleted)
                keycache2[turn] = {tick: ret}
                keycache[keycache_key] = keycache2
                # assert ret == get_adds_dels(keys[parentity], branch, turn, tick)[0]  # slow
                return ret
        ret = frozenset(get_adds_dels(keys[parentity], branch, turn, tick)[0])
        if keycache2:
            if keycache3:
                keycache3[tick] = ret
            else:
                keycache2[turn] = {tick: ret}
        else:
            kcc = SettingsTurnDict()
            kcc[turn] = {tick: ret}
            keycache[keycache_key] = kcc
        return ret
1214565
def get_cached_data(self, url):
        
        
        key = self.get_key_from_url(url)
        
        with self.conn as conn:
            cursor = conn.cursor()
            cursor.execute("SELECT * FROM ensembl WHERE key=? AND genome_build=?",
                (key, self.genome_build))
        row = cursor.fetchone()
        
        # if the data has been cached, check that it is not out of date, and
        # the data was generated from the same Ensembl API version
        if row is not None:
            api_version = row["api_version"]
            data = zlib.decompress(row["data"])
            if IS_PYTHON3:
                data = data.decode("utf-8")
            
            date = datetime.strptime(row["cache_date"], "%Y-%m-%d")
            diff = self.today - date
            
            if diff.days < 180 and self.api_version == api_version:
                return data
        
        return None
1008663
def _use_cache(self, key, options=None):
    
    flag = ContextOptions.use_cache(options)
    if flag is None:
      flag = self._cache_policy(key)
    if flag is None:
      flag = ContextOptions.use_cache(self._conn.config)
    if flag is None:
      flag = True
    return flag
1356397
def get(self, key, bucket):
        

        try:
            return self._cache[bucket][key]
        except (KeyError, TypeError):
            return None