Skip to content

Commit

Permalink
adds register_bases and add_datajoint_plus to vm
Browse files Browse the repository at this point in the history
  • Loading branch information
spapa013 committed Nov 22, 2021
1 parent 86005db commit 971b075
Showing 1 changed file with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
Configuration package/module for microns-materialization.
"""

import inspect
import traceback
from enum import Enum
from . import adapters
from . import externals

import traceback

from . import bases
try:
import datajoint as dj
except:
traceback.print_exc()
raise ImportError('DataJoint package not found.')
from microns_utils import config_utils

from enum import Enum

from microns_utils import config_utils

config_utils.enable_datajoint_flags()


def register_externals(schema_name:str):
"""
Registers the external stores for a schema_name in this module.
Expand All @@ -39,12 +39,27 @@ def register_adapters(schema_name:str, context=None):
config_utils.register_adapters(adapter_objects, context=context)


def register_bases(schema_name:str, module):
"""
Maps base classes to DataJoint tables.
"""
bases = config_mapping[SCHEMAS(schema_name)]["bases"]

if bases is not None:
for base in bases:
config_utils.register_bases(base, module)
return module


def create_vm(schema_name:str):
"""
Creates a virtual module after registering the external stores, and includes the adapter objects in the vm.
Creates a virtual module after registering the external stores, adapter objects, DatajointPlus and base classes.
"""
schema = SCHEMAS(schema_name)
return config_utils.create_vm(schema.value, external_stores=config_mapping[schema]["externals"], adapter_objects=config_mapping[schema]["adapters"])
vm = config_utils._create_vm(schema.value, external_stores=config_mapping[schema]["externals"], adapter_objects=config_mapping[schema]["adapters"])
config_utils.add_datajoint_plus(vm)
register_bases(schema_name, vm)
return vm


class SCHEMAS(Enum):
Expand All @@ -56,10 +71,12 @@ class SCHEMAS(Enum):
SCHEMAS.H01_MATERIALIZATION: {
"externals": externals.h01_materialization,
"adapters": adapters.h01_materialization_adapter_objects,
"bases": None
},
SCHEMAS.MINNIE65_MATERIALIZATION: {
"externals": externals.minnie65_materialization,
"adapters": adapters.minnie65_materialization_adapter_objects
"adapters": adapters.minnie65_materialization_adapter_objects,
"bases": None
},

}

0 comments on commit 971b075

Please sign in to comment.