Beispiel #1
0
def bootstrap_pyon(logging_config_override=None, pyon_cfg=None):
    """
    This function initializes the core elements of the Pyon framework in a controlled way.
    It does not initialize the ION container or the ION system.
    @param logging_config_override  A dict to initialize the Python logging subsystem (None loads default files)
    @param pyon_cfg   A DotDict with the fully loaded pyon configuration to merge into CFG (None loads default files)
    """
    log.info("pyon.bootstrap (bootstrap_pyon) executing...")

    # Make sure Pyon is only initialized only once
    global pyon_initialized
    if pyon_initialized:
        log.warn("WARNING -- bootstrap_pyon() called again!")
        return

    # ENVIRONMENT. Check we are called in an expected environment (files, directories, etc)
    assert_environment()

    # LOGGING. Initialize logging from config
    if not logutil.is_logging_configured():
        logutil.configure_logging(
            logutil.DEFAULT_LOGGING_PATHS,
            logging_config_override=logging_config_override)

    # YAML patch: OrderedDicts instead of dicts
    from pyon.util.yaml_ordered_dict import apply_yaml_patch
    apply_yaml_patch()

    # CONFIG. Initialize pyon global configuration from local files
    set_config(pyon_cfg)
    log.debug("CFG set to %s", CFG)

    # OBJECTS. Object and message definitions.
    from pyon.core.registry import IonObjectRegistry
    global _obj_registry
    _obj_registry = IonObjectRegistry()

    # SERVICES. Service definitions
    # TODO: change the following to read service definitions from directory and import selectively
    from pyon.ion.service import IonServiceRegistry
    import interface.services
    global _service_registry
    _service_registry = IonServiceRegistry()
    _service_registry.load_service_mods(interface.services)
    _service_registry.build_service_map()

    # RESOURCES. Load and initialize definitions
    from pyon.ion import resource
    resource.load_definitions()

    # Fix a weird bug on Ubuntu that resets time.sleep to un-monkey patched version on import threading
    from gevent import monkey
    monkey.patch_time()

    # Set initialized flag
    pyon_initialized = True
    log.debug("Pyon initialized OK")
Beispiel #2
0
def bootstrap_pyon(logging_config_override=None, pyon_cfg=None):
    """
    This function initializes the core elements of the Pyon framework in a controlled way.
    It does not initialize the ION container or the ION system.
    @param logging_config_override  A dict to initialize the Python logging subsystem (None loads default files)
    @param pyon_cfg   A DotDict with the fully loaded pyon configuration to set as CFG (None loads default files)
    """
    print "pyon: pyon.bootstrap (bootstrap_pyon) executing..."

    # Make sure Pyon is only initialized only once
    global pyon_initialized
    if pyon_initialized:
        print "pyon: WARNING -- bootstrap_pyon() called again!"
        return

    # ENVIRONMENT. Check we are called in an expected environment (files, directories, etc)
    assert_environment()

    # LOGGING. Initialize logging from config
    load_logging_config(logging_config_override=logging_config_override)

    # YAML patch: OrderedDicts instead of dicts
    from pyon.util.yaml_ordered_dict import apply_yaml_patch
    apply_yaml_patch()

    # CONFIG. Initialize pyon global configuration from local files
    set_config(pyon_cfg)

    # OBJECTS. Object and message definitions.
    from pyon.core.registry import IonObjectRegistry
    global _obj_registry
    _obj_registry = IonObjectRegistry()

    # SERVICES. Service definitions
    from pyon.service.service import IonServiceRegistry
    global _service_registry
    _service_registry = IonServiceRegistry()
    _service_registry.load_service_mods('interface/services')
    _service_registry.build_service_map()

    # INTERCEPTORS.
    # TODO: Is
    from pyon.net.endpoint import instantiate_interceptors
    instantiate_interceptors(CFG.interceptor)

    # RESOURCES. Load and initialize definitions
    from pyon.ion import resource
    resource.load_definitions()

    # Set initialized flag
    pyon_initialized = True
Beispiel #3
0
 def setUp(self):
     # TODO: Change the hacky hardcoded path once we have path management
     self.registry = IonObjectRegistry()
Beispiel #4
0
 def setUp(self):
     self.patch_cfg('pyon.core.bootstrap.CFG', {'container': {'objects': {'validate': {'setattr': True}}}})
     self.registry = IonObjectRegistry()
Beispiel #5
0
@file ion/services/dm/utility/granule/taxonomy.py
@author David Stuebe
@author Don Brittain
@author Tim Giguere
@brief https://confluence.oceanobservatories.org/display/CIDev/R2+Construction+Data+Model
'''

import yaml
from pyon.core.object import ion_serializer, IonObjectDeserializer
from pyon.core.registry import IonObjectRegistry

from interface.objects import Taxonomy
from pyon.util.log import log

# Create an IonObjectDeserializer used in the prototype loads method...
ior = IonObjectRegistry()
ion_deserializer = IonObjectDeserializer(obj_registry=ior)


class TaxyTool(object):
    """
    @brief Wraps up a Taxonomy (IONObject) in a class which uses that information
    Definition of the Taxonomy Ion Resource:
    Taxonomy: !Extends_InformationResource
      map: {}

    The map is a dictionary which contains handles as keys and name sets as values.

    A name set is a set of objects which can be hashed for inverse lookup and should be serializable for transport and persistence

    In practice they are strings for nicknames and Taxonomy Description objects for complex definitions