def __init__(self, model="inception-v3", layer="penultimate",
                 server_url='api.garaza.io:443'):
        super().__init__(server_url)
        model_settings = self._get_model_settings_confidently(model, layer)
        self._model = model
        self._layer = layer
        self._target_image_size = model_settings['target_image_size']

        cache_file_path = self._cache_file_blueprint.format(model, layer)
        self._cache_file_path = join(cache_dir(), cache_file_path)
        self._cache_dict = self._init_cache()

        self._session = cachecontrol.CacheControl(
            requests.session(),
            cache=cachecontrol.caches.FileCache(
                join(cache_dir(), __name__ + ".ImageEmbedder.httpcache"))
        )

        # attribute that offers support for cancelling the embedding
        # if ran in another thread
        self.cancelled = False
        self.machine_id = \
            QSettings().value('error-reporting/machine-id', '', type=str)  \
            or str(uuid.getnode())
        self.session_id = None
 def __init__(self):
     self._session = cachecontrol.CacheControl(
         requests.session(),
         cache=cachecontrol.caches.FileCache(
             join(cache_dir(), __name__ + ".ImageEmbedder.httpcache")
         ),
     )
예제 #3
0
 def clear_caches(self):  # pylint: disable=import-outside-toplevel
     from Orange.misc import environ
     log.info("Clearing caches")
     self._rm_tree(environ.cache_dir())
     log.info("Clearing data")
     self._rm_tree(environ.data_dir(versioned=True))
     self._rm_tree(environ.data_dir(versioned=False))
예제 #4
0
파일: nyt.py 프로젝트: seyyaw/orange3-text
 def _cache_init(self):
     """ Initialize cache in Orange environment buffer dir. """
     path = os.path.join(environ.cache_dir(), "nytcache")
     try:
         if not os.path.exists(path):
             os.makedirs(path)
         self.cache_path = os.path.join(path, "query_cache")
     except OSError as e:
         warnings.warn('Could not initialize NYT cache: {}'.format(str(e)), RuntimeWarning)
예제 #5
0
 def __init__(self):
     self.cache_dir = os.path.join(cache_dir(), 'ontology')
     if not os.path.isdir(self.cache_dir):
         os.makedirs(self.cache_dir)
     self.similarities = dict()
     try:
         with open(os.path.join(self.cache_dir, 'sims.pkl'), 'rb') as file:
             self.similarities = pickle.load(file)
     except IOError:
         self.similarities = dict()
     self.embeddings = dict()
    def __init__(self, model, layer, server_url='api.biolab.si:8080'):
        super().__init__(server_url)
        model_settings = self._get_model_settings_confidently(model, layer)
        self._model = model
        self._layer = layer
        self._target_image_size = model_settings['target_image_size']

        cache_file_path = self._cache_file_blueprint.format(model, layer)
        self._cache_file_path = join(cache_dir(), cache_file_path)
        self._cache_dict = self._init_cache()

        self._session = cachecontrol.CacheControl(
            requests.session(),
            cache=cachecontrol.caches.FileCache(
                join(cache_dir(), __name__ + ".ImageEmbedder.httpcache"))
        )

        # attribute that offers support for cancelling the embedding
        # if ran in another thread
        self.cancelled = False
예제 #7
0
def cache_dir():
    """
    Return the Orange application cache directory. If the directory path
    does not yet exists then create it.
    """
    path = os.path.join(environ.cache_dir(), "canvas")
    try:
        os.makedirs(path, exist_ok=True)
    except OSError:
        pass
    return path
예제 #8
0
파일: config.py 프로젝트: tojojames/orange3
def cache_dir():
    """Return the application cache directory. If the directory path
    does not yet exists then create it.

    """
    from Orange.misc import environ
    path = os.path.join(environ.cache_dir(), "canvas")

    if not os.path.isdir(path):
        os.makedirs(path, exist_ok=True)
    return path
    def __init__(self, model, layer,
                 server_url='api.biolab.si', server_port=8080):
        super().__init__(server_url, server_port)
        model_settings = self._get_model_settings_confidently(model, layer)

        self._model = model
        self._layer = layer
        self._target_image_size = model_settings['target_image_size']

        cache_file_path = self._cache_file_blueprint.format(model, layer)
        self._cache_file_path = join(cache_dir(), cache_file_path)
        self._cache_dict = self._init_cache()
예제 #10
0
class CachedNodeInfoTable:
    LIST = os.path.join(cache_dir(), 'owmonroedata', 'nodes_info_list.pickle')
    TABLES = os.path.join(cache_dir(), 'owmonroedata', 'tables.pickle')
    os.makedirs(os.path.dirname(LIST), exist_ok=True)

    @classmethod
    def _load(cls, file):
        with open(file, 'rb') as f:
            return pickle.load(f)

    @classmethod
    def _dump(cls, obj, file):
        with open(file, 'wb') as f:
            pickle.dump(obj, f, protocol=pickle.HIGHEST_PROTOCOL)

    @classmethod
    def load_list(cls):
        return cls._load(cls.LIST)

    @classmethod
    def dump_list(cls, lst):
        cls._dump(lst, cls.LIST)

    @classmethod
    def load_tables(cls):
        return cls._load(cls.TABLES)

    @classmethod
    def dump_tables(cls, lst):
        cls._dump(lst, cls.TABLES)

    @classmethod
    def clear(cls):
        for file in (cls.LIST, cls.TABLES):
            try:
                os.remove(file)
            except FileNotFoundError:
                pass
    def __init__(self, model, model_settings):
        self.model = model
        self._load_model()

        self._target_image_size = model_settings["target_image_size"]

        self._session = cachecontrol.CacheControl(
            requests.session(),
            cache=cachecontrol.caches.FileCache(
                join(cache_dir(), __name__ + ".ImageEmbedder.httpcache")))

        self.cancelled = False

        self._image_loader = ImageLoader()
        self._cache = EmbedderCache(model)
    def __init__(self,
                 model,
                 layer,
                 server_url='api.biolab.si',
                 server_port=8080):
        super().__init__(server_url, server_port)
        model_settings = self._get_model_settings_confidently(model, layer)

        self._model = model
        self._layer = layer
        self._target_image_size = model_settings['target_image_size']

        cache_file_path = self._cache_file_blueprint.format(model, layer)
        self._cache_file_path = join(cache_dir(), cache_file_path)
        self._cache_dict = self._init_cache()
    def __init__(self, model, model_settings, layer):
        self.model = model
        self.layer = layer
        self._load_model()

        self._target_image_size = model_settings["target_image_size"]

        self._session = cachecontrol.CacheControl(
            requests.session(),
            cache=cachecontrol.caches.FileCache(
                join(cache_dir(), __name__ + ".ImageEmbedder.httpcache"))
        )

        self.cancelled = False

        self._image_loader = ImageLoader()
        self._cache = EmbedderCache(model, layer)
예제 #14
0
    def __init__(self, email, progress_callback=None, error_callback=None):

        Entrez.email = email

        self.record_id_list = None  # Ids of the records available.
        self.search_record_count = 0  # Number of records.
        self.search_record_web_env = None  # BioPython history param.
        self.search_record_query_key = None  # BioPython history param.

        self.progress_callback = progress_callback
        self.error_callback = error_callback
        self.stop_signal = False

        self.cache_path = None
        cache_folder = os.path.join(environ.cache_dir(), 'pubmedcache')

        if not os.path.exists(cache_folder):
            os.makedirs(cache_folder)
        self.cache_path = os.path.join(cache_folder, 'query_cache')
import warnings

from Orange.misc import environ

warnings.warn("'{}' is deprecated please do not import it".format(__name__),
              DeprecationWarning,
              stacklevel=2)

buffer_dir = environ.cache_dir()
widget_settings_dir = environ.widget_settings_dir()
from AnyQt.QtWidgets import QLineEdit
from AnyQt.QtWidgets import QSizePolicy as Policy
from AnyQt.QtCore import pyqtSignal

from Orange.misc import environ
from Orange.data import Table
from Orange.widgets.widget import OWWidget
from Orange.widgets import gui, settings
from Orange.widgets.utils.concurrent import ThreadExecutor, Task
from ..resolwe import ResolweAPI, to_orange_table, ResolweCredentialsException, ResolweServerException

error_red = 'QWidget { background-color:#FFCCCC;}'

#  Support cache with requests_cache module
cache_path = os.path.join(environ.cache_dir(), "resolwe")
try:
    os.makedirs(cache_path)
except OSError:
    pass
cache_file = os.path.join(cache_path, 'vaccinesurvey_cache')
#  cache successful requests for one hour
requests_cache.install_cache(cache_name=cache_file,
                             backend='sqlite',
                             expire_after=3600)


class OWImportSamples(OWWidget):
    name = "Import Samples"
    icon = "icons/import.svg"
    want_main_area = False
예제 #17
0
파일: base.py 프로젝트: ycpengpeng/orange3
 def __init__(self,
              iterations=None,
              learning_rate=None,
              depth=None,
              l2_leaf_reg=None,
              model_size_reg=None,
              rsm=None,
              loss_function=None,
              border_count=None,
              feature_border_type=None,
              per_float_feature_quantization=None,
              input_borders=None,
              output_borders=None,
              fold_permutation_block=None,
              od_pval=None,
              od_wait=None,
              od_type=None,
              nan_mode=None,
              counter_calc_method=None,
              leaf_estimation_iterations=None,
              leaf_estimation_method=None,
              thread_count=None,
              random_seed=None,
              use_best_model=None,
              verbose=False,
              logging_level=None,
              metric_period=None,
              ctr_leaf_count_limit=None,
              store_all_simple_ctr=None,
              max_ctr_complexity=None,
              has_time=None,
              allow_const_label=None,
              classes_count=None,
              class_weights=None,
              one_hot_max_size=None,
              random_strength=None,
              name=None,
              ignored_features=None,
              train_dir=cache_dir(),
              custom_loss=None,
              custom_metric=None,
              eval_metric=None,
              bagging_temperature=None,
              save_snapshot=None,
              snapshot_file=None,
              snapshot_interval=None,
              fold_len_multiplier=None,
              used_ram_limit=None,
              gpu_ram_part=None,
              allow_writing_files=False,
              final_ctr_computation_mode=None,
              approx_on_full_history=None,
              boosting_type=None,
              simple_ctr=None,
              combinations_ctr=None,
              per_feature_ctr=None,
              task_type=None,
              device_config=None,
              devices=None,
              bootstrap_type=None,
              subsample=None,
              sampling_unit=None,
              dev_score_calc_obj_block_size=None,
              max_depth=None,
              n_estimators=None,
              num_boost_round=None,
              num_trees=None,
              colsample_bylevel=None,
              random_state=None,
              reg_lambda=None,
              objective=None,
              eta=None,
              max_bin=None,
              scale_pos_weight=None,
              gpu_cat_features_storage=None,
              data_partition=None,
              metadata=None,
              early_stopping_rounds=None,
              cat_features=None,
              grow_policy=None,
              min_data_in_leaf=None,
              min_child_samples=None,
              max_leaves=None,
              num_leaves=None,
              score_function=None,
              leaf_estimation_backtracking=None,
              ctr_history_unit=None,
              monotone_constraints=None,
              feature_weights=None,
              penalties_coefficient=None,
              first_feature_use_penalties=None,
              model_shrink_rate=None,
              model_shrink_mode=None,
              langevin=None,
              diffusion_temperature=None,
              posterior_sampling=None,
              boost_from_average=None,
              text_features=None,
              tokenizers=None,
              dictionaries=None,
              feature_calcers=None,
              text_processing=None,
              preprocessors=None):
     super().__init__(preprocessors=preprocessors)
     self.params = vars()
예제 #18
0
import warnings

from Orange.misc import environ

warnings.warn("'{}' is deprecated please do not import it"
              .format(__name__),
              DeprecationWarning, stacklevel=2)

buffer_dir = environ.cache_dir()
widget_settings_dir = environ.widget_settings_dir()
 def __init__(self):
     self._session = cachecontrol.CacheControl(
         requests.session(),
         cache=cachecontrol.caches.FileCache(
             join(cache_dir(), __name__ + ".ImageEmbedder.httpcache"))
     )
    def __init__(self, model, layer):
        # init the cache

        cache_file_path = self._cache_file_blueprint.format(model, layer)
        self._cache_file_path = join(cache_dir(), cache_file_path)
        self._cache_dict = self._init_cache()
예제 #21
0
import Orange.distance
import Orange.misc
from Orange.misc.environ import cache_dir
from Orange.widgets import gui, settings
from Orange.widgets.settings import SettingProvider
from Orange.widgets.utils.sql import check_sql_input
from Orange.canvas import report
from Orange.widgets.visualize.owscatterplotgraph import OWScatterPlotGraph, InteractiveViewBox
from Orange.widgets.widget import Msg, OWWidget, Input, Output
from Orange.widgets.utils.annotated_data import (create_annotated_table,
                                                 create_groups_table,
                                                 ANNOTATED_DATA_SIGNAL_NAME)

RE_FIND_INDEX = r"(^{} \()(\d{{1,}})(\)$)"

tsne_cache = os.path.join(cache_dir(), "tsne")
memory = Memory(tsne_cache, verbose=0, bytes_limit=1e8)
memory.reduce_size()

###
### TODO: When the next two functions are released in Orange, import from there


def get_indices(names, name):
    """
    Return list of indices which occur in a names list for a given name.
    :param names: list of strings
    :param name: str
    :return: list of indices
    """
    return [
    def __init__(self, model, layer):
        # init the cache

        cache_file_path = self._cache_file_blueprint.format(model, layer)
        self._cache_file_path = join(cache_dir(), cache_file_path)
        self._cache_dict = self._init_cache()