Skip to content

Commit

Permalink
Merge pull request #8 from spapa013/main
Browse files Browse the repository at this point in the history
v0.0.3 - adds register_bases and adds datajoint_plus to virtual_modules
  • Loading branch information
spapa013 authored Nov 22, 2021
2 parents 8fe2556 + c98e152 commit 6f057d9
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from microns_utils import version_utils

__version__ = version_utils.get_package_version(
__version__ = version_utils.check_package_version(
package='microns-coregistration-api',
check_if_latest=True,
check_if_latest_kwargs=dict(
owner='cajal',
repo='microns-coregistration',
source='tag',
)
)
)

check_latest_version_from_github = version_utils.latest_github_version_checker(owner='cajal', repo='microns-coregistration')
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
Configuration package/module for microns-coregistration.
"""

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 @@ -29,22 +29,27 @@ def register_externals(schema_name:str):
config_utils.register_externals(external_stores)


def register_adapters(schema_name:str, context=None):
def register_bases(schema_name:str, module):
"""
Imports the adapters for a schema_name into the global namespace.
Maps base classes to DataJoint tables.
"""
adapter_objects = config_mapping[SCHEMAS(schema_name)]["adapters"]

if adapter_objects is not None:
config_utils.register_adapters(adapter_objects, context=context)
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 @@ -57,21 +62,25 @@ class SCHEMAS(Enum):
config_mapping = {
SCHEMAS.MINNIE_EM: {
"externals": externals.minnie_em,
"adapters": None
"adapters": None,
"bases": None
},

SCHEMAS.MINNIE65_AUTO_MATCH: {
"externals": externals.minnie65_auto_match,
"adapters": None
"adapters": None,
"bases": None
},

SCHEMAS.MINNIE65_COREGISTRATION: {
"externals": externals.minnie65_coregistration,
"adapters": None
"adapters": None,
"bases": None
},

SCHEMAS.MINNIE65_MANUAL_MATCH: {
"externals": externals.minnie65_manual_match,
"adapters": None
"adapters": None,
"bases": None
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Adapters for DataJoint tables.
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Base classes for DataJoint tables.
"""
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Externals for DataJoint tables.
"""

from pathlib import Path
from microns_utils import config_utils

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from microns_utils import version_utils

__version__ = version_utils.get_package_version(
__version__ = version_utils.check_package_version(
package='microns-coregistration',
check_if_latest=True,
check_if_latest_kwargs=dict(
owner='cajal',
repo='microns-coregistration',
source='tag',
)
)
)

check_latest_version_from_github = version_utils.latest_github_version_checker(owner='cajal', repo='microns-coregistration')
2 changes: 1 addition & 1 deletion python/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.2"
__version__ = "0.0.3"

0 comments on commit 6f057d9

Please sign in to comment.