def setup(): global _log, services _log = get_logger("doekbase.data_api.tests.shared") services = get_services() if services["redis_host"] is not None: cache.ObjectCache.cache_class = cache.RedisCache cache.ObjectCache.cache_params = {"redis_host": services["redis_host"], "redis_port": services["redis_port"]}
def setup(): global _log, services _log = get_logger('doekbase.data_api.tests.shared') services = get_services() if services["redis_host"] is not None: cache.ObjectCache.cache_class = cache.RedisCache cache.ObjectCache.cache_params = { 'redis_host': services["redis_host"], 'redis_port': services["redis_port"] }
## Imports # System import hashlib import logging import os import time import uuid # Third-party from dogpile.cache import make_region import redis # Local from doekbase.data_api.util import PerfCollector, get_logger _log = get_logger(__name__) ## Functions and Classes class Cache(object): def __init__(self): self.region = None def __getattr__(self, item): return getattr(self.region, item) class RedisCache(Cache): def __init__(self, **kwargs): super(self.__class__, self).__init__()
def setup(): global _log, services _log = get_logger('doekbase.data_api.tests.shared') services = get_services()
import qgrid qgrid.nbinstall() except ImportError: qgrid = None from jinja2 import Template # Seaborn graphing try: import seaborn as sns sns.set_style("whitegrid") except ImportError: sns = None # Local from doekbase.data_api.util import get_logger, log_start, log_end _log = get_logger('doekbase.data_api.display') _nbviewer = False def nbviewer_mode(value=None): """Get/set the global nbviewer-friendly mode. This is currently used to tell qgrid where to get its JavaScript from (local or a CDN). """ global _nbviewer if value is not None: _nbviewer = bool(value) return _nbviewer
# Imports # Stdlib import json try: import cStringIO as StringIO except ImportError: import StringIO as StringIO # Local import doekbase.workspace.client from . import thrift_service, ttypes from doekbase.data_api.util import get_logger, log_start, log_end from doekbase.data_api.rpc_util import thrift_validate _log = get_logger('baseobj.impl') class ObjectImpl(thrift_service.Iface): def __init__(self, services=None): print("IN ObjectImpl") if services is None or type(services) != type({}): raise TypeError("You must provide a service configuration " "dictionary! Found {0}".format(type(services))) elif not services.has_key("workspace_service_url"): raise KeyError("Expecting workspace_service_url key!") self.services = services self.ws_client = None self.ref = None def init(self, auth):
import os import re try: import cStringIO as StringIO except ImportError: import StringIO as StringIO # Local from doekbase.data_api.util import get_logger, log_start, log_end from doekbase.workspace.client import Workspace from doekbase.data_api.wsfile import WorkspaceFile from doekbase.data_api import cache from doekbase.data_api.util import PerfCollector, collect_performance # Logging _log = get_logger('doekbase.data_api.core') # Globals REF_PATTERN = re.compile("(.+/.+(/[0-9].+)?)|(ws\.[1-9][0-9]+\.[1-9][0-9]+)") g_ws_url = "https://ci.kbase.us/services/ws/" g_shock_url = "https://ci.kbase.us/services/shock-api/" g_handle_url = "https://ci.kbase.us/services/handle_service/" g_use_msgpack = True g_stats = PerfCollector('ObjectAPI') def fix_docs(cls): for name, func in vars(cls).items(): if func is not None and func.__doc__ is None:
__date__ = '9/30/15' # System import os import threading import time import unittest # Third-party from dogpile.cache.api import NO_VALUE # Local from doekbase.data_api import cache from doekbase.data_api import util from doekbase.data_api.core import ObjectAPI from . import shared _log = util.get_logger(__name__) # Uncomment this line to turn off DBM tests USE_DBM = False def setup(): shared.setup() class TestCache(unittest.TestCase): """Test the cache. """ dbm_path = None ## Setup / teardown @classmethod
import twisted.internet import twisted.web from thrift.transport import TTwisted from thrift.protocol import TBinaryProtocol # Local from doekbase.data_api.taxonomy.taxon.service import thrift_service from doekbase.data_api.taxonomy.taxon.service.interface import TaxonService from doekbase.data_api.util import get_logger DEFAULT_WS_URL = 'https://ci.kbase.us/services/ws/' DEFAULT_SHOCK_URL = 'https://ci.kbase.us/services/shock-api/' # set up a logger for Thrift messages _log = get_logger('taxon_service') def get_services_dict(ws=DEFAULT_WS_URL, shock=DEFAULT_SHOCK_URL): return {'workspace_service_url': ws, 'shock_service_url': shock} #TODO respond to kill signals #TODO on HUP reload of config def start_service(services = None, host = 'localhost', port = 9101): if services is None: services = get_services_dict() handler = TaxonService(services) processor = thrift_service.Processor(handler) pfactory = TBinaryProtocol.TBinaryProtocolFactory() resource = TTwisted.ThriftResource(processor, pfactory, pfactory)
import os import re try: import cStringIO as StringIO except ImportError: import StringIO as StringIO # Local from doekbase.data_api.util import get_logger, log_start, log_end from doekbase.workspace.client import Workspace from doekbase.data_api.wsfile import WorkspaceFile from doekbase.data_api import cache from doekbase.data_api.util import PerfCollector, collect_performance # Logging _log = get_logger('doekbase.data_api.core') # Globals REF_PATTERN = re.compile("(.+/.+(/[0-9].+)?)|(ws\.[1-9][0-9]+\.[1-9][0-9]+)") g_ws_url = "https://ci.kbase.us/services/ws/" g_shock_url = "https://ci.kbase.us/services/shock-api/" g_use_msgpack = True g_stats = PerfCollector('ObjectAPI') # Functions and Classes #: Name positional parts of WorkspaceInfo tuple WorkspaceInfo = namedtuple('WorkspaceInfo', [ 'id', # ws_id (int)
# Imports # Stdlib import json import logging import re # Local from doekbase.data_api.util import get_logger from doekbase.data_api.util import log_start, log_end from doekbase.data_api.util import get_auth_token from . import thrift_service, ttypes # Logging _log = get_logger('object_api') _log.setLevel(logging.DEBUG) # Constants NAMESPACE = 'Object' REF_PATTERN = re.compile("(.+/.+(/[0-9].+)?)|(ws\.[1-9][0-9]+\.[1-9][0-9]+)") # Classes and functions class ObjectAPI(object): """API layer over the autogenerated Thrift interface. This can handle both local and remote modes by use of alternate implementations of the `client` parameter.
except ImportError: qgrid = None from jinja2 import Template # Seaborn graphing try: import seaborn as sns sns.set_style("whitegrid") except ImportError: sns = None # Local from doekbase.data_api.util import get_logger, log_start, log_end _log = get_logger("doekbase.data_api.display") _nbviewer = False def nbviewer_mode(value=None): """Get/set the global nbviewer-friendly mode. This is currently used to tell qgrid where to get its JavaScript from (local or a CDN). """ global _nbviewer if value is not None: _nbviewer = bool(value) return _nbviewer
""" Service driver for Assembly API. """ # Imports # ------- # Local from doekbase.data_api import service_core from doekbase.data_api.sequence.assembly.service import thrift_service from doekbase.data_api.sequence.assembly.service.interface import \ AssemblyService from doekbase.data_api.util import get_logger _log = get_logger(__name__) def start_service(**kw): return service_core.start_service(AssemblyService, thrift_service, _log, **kw) stop_service = service_core.stop_service
__date__ = '9/30/15' # System import os import threading import time import unittest # Third-party from dogpile.cache.api import NO_VALUE # Local from doekbase.data_api import cache from doekbase.data_api import util from doekbase.data_api.core import ObjectAPI from . import shared _log = util.get_logger(__name__) # Uncomment this line to turn off DBM tests USE_DBM = False def setup(): shared.setup() class TestCache(unittest.TestCase): """Test the cache. """ dbm_path = None ## Setup / teardown
# Third-party from thrift.transport import TSocket from thrift.transport import TTransport from thrift.protocol import TJSONProtocol from thrift.server import THttpServer # Local from doekbase.data_api.taxonomy.taxon.service import thrift_service from doekbase.data_api.taxonomy.taxon.service.interface import TaxonService from doekbase.data_api.util import get_logger DEFAULT_WS_URL = 'https://ci.kbase.us/services/ws/' DEFAULT_SHOCK_URL = 'https://ci.kbase.us/services/shock-api/' _log = get_logger('thrift') # set up a logger for Thrift messages _log.setLevel(logging.DEBUG) def get_services_dict(ws=DEFAULT_WS_URL, shock=DEFAULT_SHOCK_URL): return {'workspace_service_url': ws, 'shock_service_url': shock} def taxon_service(): handler = TaxonService(services=get_services_dict()) processor = thrift_service.Processor(handler) pfactory = TJSONProtocol.TJSONProtocolFactory() server_address = ('127.0.0.1', 9090) server = THttpServer.THttpServer(processor, server_address, pfactory) return server
# Imports # Stdlib import json import logging import re # Local from doekbase.data_api.util import get_logger from doekbase.data_api.util import log_start, log_end from doekbase.data_api.util import get_auth_token from . import thrift_service, ttypes # Logging _log = get_logger('object_api') _log.setLevel(logging.DEBUG) # Constants NAMESPACE = 'Object' REF_PATTERN = re.compile("(.+/.+(/[0-9].+)?)|(ws\.[1-9][0-9]+\.[1-9][0-9]+)") # Classes and functions class ObjectAPI(object): """API layer over the autogenerated Thrift interface. This can handle both local and remote modes by use of alternate implementations of the `client` parameter. """