refactor: Moved contracts + fixes

main
Sofus Albert Høgsbro Rose 2024-04-17 18:36:11 +02:00
parent 6a41683576
commit 8dece384ad
Signed by: so-rose
GPG Key ID: AD901CB0F3701434
56 changed files with 143 additions and 90 deletions

View File

@ -1,21 +1,16 @@
"""Provides for the linking and/or appending of geometry nodes trees from vendored libraries included in Blender maxwell.""" """Provides for the linking and/or appending of geometry nodes trees from vendored libraries included in Blender maxwell."""
import enum import enum
import typing as typ
from pathlib import Path from pathlib import Path
import bpy import bpy
import typing_extensions as typx
from .. import info from blender_maxwell import contracts as ct
from blender_maxwell.utils import logger from blender_maxwell.utils import logger
log = logger.get(__name__) from .. import info
ImportMethod: typ.TypeAlias = typx.Literal['append', 'link'] log = logger.get(__name__)
BLOperatorStatus: typ.TypeAlias = set[
typx.Literal['RUNNING_MODAL', 'CANCELLED', 'FINISHED', 'PASS_THROUGH', 'INTERFACE']
]
#################### ####################
@ -26,6 +21,7 @@ class GeoNodes(enum.StrEnum):
The value of this StrEnum is both the name of the .blend file containing the GeoNodes group, and of the GeoNodes group itself. The value of this StrEnum is both the name of the .blend file containing the GeoNodes group, and of the GeoNodes group itself.
""" """
# Node Previews # Node Previews
## Input ## Input
InputConstantPhysicalPol = '_input_constant_physical_pol' InputConstantPhysicalPol = '_input_constant_physical_pol'
@ -134,7 +130,6 @@ GN_PARENT_PATHS: dict[GeoNodes, Path] = {
GeoNodes.SimulationSimGridAxisManual: GN_INTERNAL_SIMULATIONS_PATH, GeoNodes.SimulationSimGridAxisManual: GN_INTERNAL_SIMULATIONS_PATH,
GeoNodes.SimulationSimGridAxisUniform: GN_INTERNAL_SIMULATIONS_PATH, GeoNodes.SimulationSimGridAxisUniform: GN_INTERNAL_SIMULATIONS_PATH,
GeoNodes.SimulationSimGridAxisArray: GN_INTERNAL_SIMULATIONS_PATH, GeoNodes.SimulationSimGridAxisArray: GN_INTERNAL_SIMULATIONS_PATH,
# Structures # Structures
GeoNodes.PrimitiveBox: GN_STRUCTURES_PRIMITIVES_PATH, GeoNodes.PrimitiveBox: GN_STRUCTURES_PRIMITIVES_PATH,
GeoNodes.PrimitiveRing: GN_STRUCTURES_PRIMITIVES_PATH, GeoNodes.PrimitiveRing: GN_STRUCTURES_PRIMITIVES_PATH,
@ -147,7 +142,7 @@ GN_PARENT_PATHS: dict[GeoNodes, Path] = {
#################### ####################
def import_geonodes( def import_geonodes(
geonodes: GeoNodes, geonodes: GeoNodes,
import_method: ImportMethod, import_method: ct.BLImportMethod,
) -> bpy.types.GeometryNodeGroup: ) -> bpy.types.GeometryNodeGroup:
"""Given a (name of a) GeoNodes group packaged with Blender Maxwell, link/append it to the current file, and return the node group. """Given a (name of a) GeoNodes group packaged with Blender Maxwell, link/append it to the current file, and return the node group.
@ -159,10 +154,7 @@ def import_geonodes(
Returns: Returns:
A GeoNodes group available in the current .blend file, which can ex. be attached to a 'GeoNodes Structure' node. A GeoNodes group available in the current .blend file, which can ex. be attached to a 'GeoNodes Structure' node.
""" """
if ( if import_method == 'link' and geonodes in bpy.data.node_groups:
import_method == 'link'
and geonodes in bpy.data.node_groups
):
return bpy.data.node_groups[geonodes] return bpy.data.node_groups[geonodes]
filename = geonodes filename = geonodes
@ -273,7 +265,7 @@ class AppendGeoNodes(bpy.types.Operator):
def invoke(self, context: bpy.types.Context, _): def invoke(self, context: bpy.types.Context, _):
return self.execute(context) return self.execute(context)
def execute(self, context: bpy.types.Context) -> BLOperatorStatus: def execute(self, context: bpy.types.Context) -> ct.BLOperatorStatus:
"""Initializes the while-dragging modal handler, which executes custom logic when the mouse button is released. """Initializes the while-dragging modal handler, which executes custom logic when the mouse button is released.
Runs in response to drag_handler of a `UILayout.template_asset_view`. Runs in response to drag_handler of a `UILayout.template_asset_view`.
@ -296,7 +288,7 @@ class AppendGeoNodes(bpy.types.Operator):
def modal( def modal(
self, context: bpy.types.Context, event: bpy.types.Event self, context: bpy.types.Context, event: bpy.types.Event
) -> BLOperatorStatus: ) -> ct.BLOperatorStatus:
"""When LMB is released, creates a GeoNodes Structure node. """When LMB is released, creates a GeoNodes Structure node.
Runs in response to events in the node editor while dragging an asset from the side panel. Runs in response to events in the node editor while dragging an asset from the side panel.

View File

@ -0,0 +1,33 @@
from . import addon
from .bl import (
BLClass,
BLColorRGBA,
BLEnumID,
BLIconSet,
BLImportMethod,
BLKeymapItem,
BLModifierType,
BLNodeTreeInterfaceID,
BLOperatorStatus,
KeymapItemDef,
ManagedObjName,
PresetName,
SocketName,
)
__all__ = [
'addon',
'BLClass',
'BLColorRGBA',
'BLEnumID',
'BLIconSet',
'BLImportMethod',
'BLKeymapItem',
'BLModifierType',
'BLNodeTreeInterfaceID',
'BLOperatorStatus',
'KeymapItemDef',
'ManagedObjName',
'PresetName',
'SocketName',
]

View File

@ -3,20 +3,16 @@ from pathlib import Path
import bpy import bpy
PATH_ADDON_ROOT = Path(__file__).resolve().parent PATH_ADDON_ROOT = Path(__file__).resolve().parent.parent
####################
# - Addon Info
####################
with (PATH_ADDON_ROOT / 'pyproject.toml').open('rb') as f: with (PATH_ADDON_ROOT / 'pyproject.toml').open('rb') as f:
PROJ_SPEC = tomllib.load(f) PROJ_SPEC = tomllib.load(f)
## bl_info is filled with PROJ_SPEC when packing the .zip. ## bl_info is filled with PROJ_SPEC when packing the .zip.
ADDON_NAME = PROJ_SPEC['project']['name'] NAME = PROJ_SPEC['project']['name']
ADDON_VERSION = PROJ_SPEC['project']['version'] VERSION = PROJ_SPEC['project']['version']
#################### ####################
# - Asset Info # - Assets
#################### ####################
PATH_ASSETS = PATH_ADDON_ROOT / 'assets' PATH_ASSETS = PATH_ADDON_ROOT / 'assets'
@ -33,7 +29,17 @@ DEFAULT_PATH_DEPS = PATH_ADDON_ROOT / '.addon_dependencies'
#################### ####################
ADDON_CACHE = PATH_ADDON_ROOT / '.addon_cache' ADDON_CACHE = PATH_ADDON_ROOT / '.addon_cache'
ADDON_CACHE.mkdir(exist_ok=True) ADDON_CACHE.mkdir(exist_ok=True)
## TODO: Addon preferences?
####################
# - Addon Prefs Info
####################
def prefs() -> bpy.types.AddonPreferences | None:
if (addon := bpy.context.preferences.addons.get(NAME)) is None:
return None
return addon.preferences
#################### ####################
# - Logging Info # - Logging Info
@ -47,13 +53,3 @@ DEFAULT_LOG_PATH.touch(exist_ok=True)
PATH_BOOTSTRAP_LOG_LEVEL = PATH_ADDON_ROOT / '.bootstrap_log_level' PATH_BOOTSTRAP_LOG_LEVEL = PATH_ADDON_ROOT / '.bootstrap_log_level'
with PATH_BOOTSTRAP_LOG_LEVEL.open('r') as f: with PATH_BOOTSTRAP_LOG_LEVEL.open('r') as f:
BOOTSTRAP_LOG_LEVEL = int(f.read().strip()) BOOTSTRAP_LOG_LEVEL = int(f.read().strip())
####################
# - Addon Prefs Info
####################
def addon_prefs() -> bpy.types.AddonPreferences | None:
if (addon := bpy.context.preferences.addons.get(ADDON_NAME)) is None:
return None
return addon.preferences

View File

@ -23,6 +23,7 @@ SocketName = typx.Annotated[
#################### ####################
# - Blender Enums # - Blender Enums
#################### ####################
BLImportMethod: typ.TypeAlias = typx.Literal['append', 'link']
BLModifierType: typ.TypeAlias = typx.Literal['NODES', 'ARRAY'] BLModifierType: typ.TypeAlias = typx.Literal['NODES', 'ARRAY']
BLNodeTreeInterfaceID: typ.TypeAlias = str BLNodeTreeInterfaceID: typ.TypeAlias = str
@ -58,13 +59,13 @@ BLOperatorStatus: typ.TypeAlias = set[
#################### ####################
# - Addon Types # - Addon Types
#################### ####################
KeymapItemDef: typ.TypeAlias = typ.Any ## TODO: Better Type
ManagedObjName = typx.Annotated[ ManagedObjName = typx.Annotated[
str, str,
pyd.StringConstraints( pyd.StringConstraints(
pattern=r'^[a-z_]+$', pattern=r'^[a-z_]+$',
), ),
] ]
KeymapItemDef: typ.TypeAlias = typ.Any ## TODO: Better Type
#################### ####################
# - Blender Strings # - Blender Strings

View File

@ -13,6 +13,7 @@ import sympy as sp
from blender_maxwell.utils import extra_sympy_units as spux from blender_maxwell.utils import extra_sympy_units as spux
from blender_maxwell.utils import logger as _logger from blender_maxwell.utils import logger as _logger
from . import contracts as ct from . import contracts as ct
from . import sockets from . import sockets

View File

@ -1,12 +1,17 @@
from blender_maxwell.contracts import ( from blender_maxwell.contracts import (
BLClass,
BLColorRGBA, BLColorRGBA,
BLEnumID, BLEnumID,
BLIconSet, BLIconSet,
BLKeymapItem,
BLModifierType, BLModifierType,
BLNodeTreeInterfaceID, BLNodeTreeInterfaceID,
BLOperatorStatus,
KeymapItemDef,
ManagedObjName, ManagedObjName,
PresetName, PresetName,
SocketName, SocketName,
addon,
) )
from .bl_socket_desc_map import BL_SOCKET_DESCR_TYPE_MAP from .bl_socket_desc_map import BL_SOCKET_DESCR_TYPE_MAP
@ -35,14 +40,19 @@ from .tree_types import TreeType
from .unit_systems import UNITS_BLENDER, UNITS_TIDY3D from .unit_systems import UNITS_BLENDER, UNITS_TIDY3D
__all__ = [ __all__ = [
'BLClass',
'BLColorRGBA', 'BLColorRGBA',
'BLEnumID', 'BLEnumID',
'BLIconSet', 'BLIconSet',
'BLKeymapItem',
'BLModifierType', 'BLModifierType',
'BLNodeTreeInterfaceID', 'BLNodeTreeInterfaceID',
'BLOperatorStatus',
'KeymapItemDef',
'ManagedObjName', 'ManagedObjName',
'PresetName', 'PresetName',
'SocketName', 'SocketName',
'addon',
'Icon', 'Icon',
'TreeType', 'TreeType',
'SocketType', 'SocketType',
@ -58,13 +68,13 @@ __all__ = [
'NodeCategory', 'NodeCategory',
'NODE_CAT_LABELS', 'NODE_CAT_LABELS',
'ManagedObjType', 'ManagedObjType',
'FlowKind',
'CapabilitiesFlow',
'ValueFlow',
'ArrayFlow',
'LazyValueFlow',
'LazyArrayRangeFlow',
'ParamsFlow',
'InfoFlow',
'FlowEvent', 'FlowEvent',
'ArrayFlow',
'CapabilitiesFlow',
'FlowKind',
'InfoFlow',
'LazyArrayRangeFlow',
'LazyValueFlow',
'ParamsFlow',
'ValueFlow',
] ]

View File

@ -1,5 +1,4 @@
import enum import enum
import typing as typ
import typing_extensions as typx import typing_extensions as typx

View File

@ -12,6 +12,7 @@ import sympy.physics.units as spu
import typing_extensions as typx import typing_extensions as typx
from blender_maxwell.utils import extra_sympy_units as spux from blender_maxwell.utils import extra_sympy_units as spux
from .socket_types import SocketType from .socket_types import SocketType

View File

@ -1,6 +1,7 @@
import sympy.physics.units as spu import sympy.physics.units as spu
from blender_maxwell.utils import extra_sympy_units as spux from blender_maxwell.utils import extra_sympy_units as spux
from .socket_types import SocketType as ST # noqa: N817 from .socket_types import SocketType as ST # noqa: N817
SOCKET_UNITS = { SOCKET_UNITS = {

View File

@ -4,6 +4,7 @@ import sympy.physics.units as spu
from blender_maxwell.utils import extra_sympy_units as spux from blender_maxwell.utils import extra_sympy_units as spux
from blender_maxwell.utils.pydantic_sympy import SympyExpr from blender_maxwell.utils.pydantic_sympy import SympyExpr
from .socket_types import SocketType as ST # noqa: N817 from .socket_types import SocketType as ST # noqa: N817
from .socket_units import SOCKET_UNITS from .socket_units import SOCKET_UNITS

View File

@ -10,6 +10,7 @@ import numpy as np
import typing_extensions as typx import typing_extensions as typx
from blender_maxwell.utils import logger from blender_maxwell.utils import logger
from .. import contracts as ct from .. import contracts as ct
from . import base from . import base

View File

@ -5,6 +5,7 @@ import bpy
import numpy as np import numpy as np
from blender_maxwell.utils import logger from blender_maxwell.utils import logger
from .. import contracts as ct from .. import contracts as ct
from . import base from . import base
from .managed_bl_collection import managed_collection, preview_collection from .managed_bl_collection import managed_collection, preview_collection

View File

@ -3,9 +3,9 @@
import typing as typ import typing as typ
import bpy import bpy
import typing_extensions as typx
from blender_maxwell.utils import analyze_geonodes, logger from blender_maxwell.utils import analyze_geonodes, logger
from .. import bl_socket_map from .. import bl_socket_map
from .. import contracts as ct from .. import contracts as ct
from . import base from . import base

View File

@ -4,6 +4,7 @@ import typing as typ
import bpy import bpy
from blender_maxwell.utils import logger from blender_maxwell.utils import logger
from . import contracts as ct from . import contracts as ct
log = logger.get(__name__) log = logger.get(__name__)

View File

@ -1,4 +1,4 @@
from . import extract_data, viz, math from . import extract_data, math, viz
BL_REGISTER = [ BL_REGISTER = [
*extract_data.BL_REGISTER, *extract_data.BL_REGISTER,

View File

@ -2,9 +2,8 @@ import typing as typ
import bpy import bpy
import jax.numpy as jnp import jax.numpy as jnp
import sympy.physics.units as spu
from blender_maxwell.utils import jarray, logger from blender_maxwell.utils import logger
from ... import contracts as ct from ... import contracts as ct
from ... import sockets from ... import sockets
@ -249,15 +248,15 @@ class ExtractDataNode(base.MaxwellSimNode):
elif self.active_socket_set == 'Field Data': # noqa: RET505 elif self.active_socket_set == 'Field Data': # noqa: RET505
xarr = getattr(input_sockets['Field Data'], props['field_data__component']) xarr = getattr(input_sockets['Field Data'], props['field_data__component'])
return jarray.JArray.from_xarray( #return jarray.JArray.from_xarray(
xarr, # xarr,
dim_units={ # dim_units={
'x': spu.um, # 'x': spu.um,
'y': spu.um, # 'y': spu.um,
'z': spu.um, # 'z': spu.um,
'f': spu.hertz, # 'f': spu.hertz,
}, # },
) #)
elif self.active_socket_set == 'Flux Data': elif self.active_socket_set == 'Flux Data':
flux_data = self._compute_input('Flux Data') flux_data = self._compute_input('Flux Data')

View File

@ -1,4 +1,4 @@
from . import map_math, filter_math, reduce_math, operate_math from . import filter_math, map_math, operate_math, reduce_math
BL_REGISTER = [ BL_REGISTER = [
*map_math.BL_REGISTER, *map_math.BL_REGISTER,

View File

@ -1,8 +1,6 @@
import functools
import typing as typ import typing as typ
import bpy import bpy
import jax
import jax.numpy as jnp import jax.numpy as jnp
from blender_maxwell.utils import logger from blender_maxwell.utils import logger

View File

@ -1,9 +1,9 @@
import typing as typ import typing as typ
import bpy import bpy
import jax.numpy as jnp
from blender_maxwell.utils import logger from blender_maxwell.utils import logger
from ... import contracts as ct from ... import contracts as ct
from ... import managed_objs, sockets from ... import managed_objs, sockets
from .. import base, events from .. import base, events

View File

@ -4,6 +4,7 @@ import typing as typ
from types import MappingProxyType from types import MappingProxyType
from blender_maxwell.utils import logger from blender_maxwell.utils import logger
from .. import contracts as ct from .. import contracts as ct
log = logger.get(__name__) log = logger.get(__name__)

View File

@ -3,6 +3,7 @@ import typing as typ
import bpy import bpy
from blender_maxwell.utils import sci_constants as constants from blender_maxwell.utils import sci_constants as constants
from .... import contracts as ct from .... import contracts as ct
from .... import sockets from .... import sockets
from ... import base, events from ... import base, events

View File

@ -6,6 +6,7 @@ import tidy3d as td
import tidy3d.plugins.dispersion as td_dispersion import tidy3d.plugins.dispersion as td_dispersion
from blender_maxwell.utils import logger from blender_maxwell.utils import logger
from .... import contracts as ct from .... import contracts as ct
from .... import managed_objs, sockets from .... import managed_objs, sockets
from ... import base, events from ... import base, events

View File

@ -7,6 +7,7 @@ import sympy.physics.units as spu
from blender_maxwell.utils import extra_sympy_units as spux from blender_maxwell.utils import extra_sympy_units as spux
from blender_maxwell.utils import logger from blender_maxwell.utils import logger
from blender_maxwell.utils import sci_constants as constants from blender_maxwell.utils import sci_constants as constants
from ... import contracts as ct from ... import contracts as ct
from ... import sockets from ... import sockets
from .. import base, events from .. import base, events

View File

@ -1,9 +1,10 @@
import typing as typ import typing as typ
from pathlib import Path from pathlib import Path
from blender_maxwell.utils import logger
from ...... import info from ...... import info
from ......services import tdcloud from ......services import tdcloud
from blender_maxwell.utils import logger
from .... import contracts as ct from .... import contracts as ct
from .... import sockets from .... import sockets
from ... import base, events from ... import base, events

View File

@ -1,4 +1,3 @@
import typing as typ
import bpy import bpy
import scipy as sc import scipy as sc
@ -7,6 +6,7 @@ import sympy.physics.units as spu
import tidy3d as td import tidy3d as td
from blender_maxwell.utils import extra_sympy_units as spuex from blender_maxwell.utils import extra_sympy_units as spuex
from ... import contracts as ct from ... import contracts as ct
from ... import managed_objs, sockets from ... import managed_objs, sockets
from .. import base, events from .. import base, events

View File

@ -3,9 +3,10 @@ import typing as typ
import sympy as sp import sympy as sp
import tidy3d as td import tidy3d as td
from .....assets.import_geonodes import GeoNodes, import_geonodes
from blender_maxwell.utils import extra_sympy_units as spux from blender_maxwell.utils import extra_sympy_units as spux
from blender_maxwell.utils import logger from blender_maxwell.utils import logger
from .....assets.import_geonodes import GeoNodes, import_geonodes
from ... import contracts as ct from ... import contracts as ct
from ... import managed_objs, sockets from ... import managed_objs, sockets
from .. import base, events from .. import base, events

View File

@ -3,9 +3,10 @@ import typing as typ
import sympy as sp import sympy as sp
import tidy3d as td import tidy3d as td
from .....assets.import_geonodes import GeoNodes, import_geonodes
from blender_maxwell.utils import extra_sympy_units as spux from blender_maxwell.utils import extra_sympy_units as spux
from blender_maxwell.utils import logger from blender_maxwell.utils import logger
from .....assets.import_geonodes import GeoNodes, import_geonodes
from ... import contracts as ct from ... import contracts as ct
from ... import managed_objs, sockets from ... import managed_objs, sockets
from .. import base, events from .. import base, events

View File

@ -4,6 +4,7 @@ import bpy
import sympy as sp import sympy as sp
from blender_maxwell.utils import logger from blender_maxwell.utils import logger
from ... import contracts as ct from ... import contracts as ct
from ... import sockets from ... import sockets
from .. import base, events from .. import base, events

View File

@ -1,4 +1,3 @@
import typing as typ
import bpy import bpy
import numpy as np import numpy as np
@ -6,6 +5,7 @@ import sympy.physics.units as spu
import tidy3d as td import tidy3d as td
from blender_maxwell.utils import extra_sympy_units as spuex from blender_maxwell.utils import extra_sympy_units as spuex
from .... import contracts as ct from .... import contracts as ct
from .... import managed_objs, sockets from .... import managed_objs, sockets
from ... import base, events from ... import base, events

View File

@ -3,6 +3,7 @@ import typing as typ
import tidy3d as td import tidy3d as td
from blender_maxwell.utils import analyze_geonodes, logger from blender_maxwell.utils import analyze_geonodes, logger
from ... import bl_socket_map, managed_objs, sockets from ... import bl_socket_map, managed_objs, sockets
from ... import contracts as ct from ... import contracts as ct
from .. import base, events from .. import base, events

View File

@ -1,4 +1,5 @@
from blender_maxwell.utils import logger from blender_maxwell.utils import logger
from .. import contracts as ct from .. import contracts as ct
from . import basic, blender, maxwell, number, physical, tidy3d, vector from . import basic, blender, maxwell, number, physical, tidy3d, vector
from .scan_socket_defs import scan_for_socket_defs from .scan_socket_defs import scan_for_socket_defs

View File

@ -8,6 +8,7 @@ import sympy as sp
import typing_extensions as typx import typing_extensions as typx
from blender_maxwell.utils import logger, serialize from blender_maxwell.utils import logger, serialize
from .. import contracts as ct from .. import contracts as ct
log = logger.get(__name__) log = logger.get(__name__)

View File

@ -4,6 +4,7 @@ import sympy.physics.units as spu
import tidy3d as td import tidy3d as td
from blender_maxwell.utils.pydantic_sympy import ConstrSympyExpr from blender_maxwell.utils.pydantic_sympy import ConstrSympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -4,6 +4,7 @@ import bpy
import sympy as sp import sympy as sp
from blender_maxwell.utils.pydantic_sympy import SympyExpr from blender_maxwell.utils.pydantic_sympy import SympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -2,6 +2,7 @@ import bpy
import sympy as sp import sympy as sp
from blender_maxwell.utils.pydantic_sympy import SympyExpr from blender_maxwell.utils.pydantic_sympy import SympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -1,6 +1,7 @@
import bpy import bpy
from blender_maxwell.utils.pydantic_sympy import SympyExpr from blender_maxwell.utils.pydantic_sympy import SympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -2,6 +2,7 @@ import bpy
import sympy.physics.units as spu import sympy.physics.units as spu
from blender_maxwell.utils.pydantic_sympy import SympyExpr from blender_maxwell.utils.pydantic_sympy import SympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -2,6 +2,7 @@ import bpy
import sympy.physics.units as spu import sympy.physics.units as spu
from blender_maxwell.utils.pydantic_sympy import SympyExpr from blender_maxwell.utils.pydantic_sympy import SympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -2,6 +2,7 @@ import bpy
import sympy.physics.units as spu import sympy.physics.units as spu
from blender_maxwell.utils.pydantic_sympy import SympyExpr from blender_maxwell.utils.pydantic_sympy import SympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -4,6 +4,7 @@ import sympy as sp
from blender_maxwell.utils import extra_sympy_units as spux from blender_maxwell.utils import extra_sympy_units as spux
from blender_maxwell.utils import logger from blender_maxwell.utils import logger
from blender_maxwell.utils.pydantic_sympy import SympyExpr from blender_maxwell.utils.pydantic_sympy import SympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -5,6 +5,7 @@ import sympy.physics.units as spu
from blender_maxwell.utils import extra_sympy_units as spux from blender_maxwell.utils import extra_sympy_units as spux
from blender_maxwell.utils import logger from blender_maxwell.utils import logger
from blender_maxwell.utils.pydantic_sympy import SympyExpr from blender_maxwell.utils.pydantic_sympy import SympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -2,6 +2,7 @@ import bpy
import sympy.physics.units as spu import sympy.physics.units as spu
from blender_maxwell.utils.pydantic_sympy import SympyExpr from blender_maxwell.utils.pydantic_sympy import SympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -5,6 +5,7 @@ import sympy as sp
import sympy.physics.units as spu import sympy.physics.units as spu
from blender_maxwell.utils.pydantic_sympy import SympyExpr from blender_maxwell.utils.pydantic_sympy import SympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -4,6 +4,7 @@ import sympy.physics.optics.polarization as spo_pol
import sympy.physics.units as spu import sympy.physics.units as spu
from blender_maxwell.utils.pydantic_sympy import SympyExpr from blender_maxwell.utils.pydantic_sympy import SympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -3,6 +3,7 @@ import sympy as sp
import sympy.physics.units as spu import sympy.physics.units as spu
from blender_maxwell.utils.pydantic_sympy import SympyExpr from blender_maxwell.utils.pydantic_sympy import SympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -2,6 +2,7 @@ import bpy
import sympy.physics.units as spu import sympy.physics.units as spu
from blender_maxwell.utils.pydantic_sympy import SympyExpr from blender_maxwell.utils.pydantic_sympy import SympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -4,6 +4,7 @@ import bpy
import sympy.physics.units as spu import sympy.physics.units as spu
from blender_maxwell.utils.pydantic_sympy import SympyExpr from blender_maxwell.utils.pydantic_sympy import SympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -1,6 +1,7 @@
import bpy import bpy
from blender_maxwell.utils.pydantic_sympy import SympyExpr from blender_maxwell.utils.pydantic_sympy import SympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -2,6 +2,7 @@ import bpy
import sympy.physics.units as spu import sympy.physics.units as spu
from blender_maxwell.utils.pydantic_sympy import SympyExpr from blender_maxwell.utils.pydantic_sympy import SympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -2,6 +2,7 @@ import bpy
import sympy as sp import sympy as sp
from blender_maxwell.utils.pydantic_sympy import ConstrSympyExpr from blender_maxwell.utils.pydantic_sympy import ConstrSympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -2,6 +2,7 @@ import bpy
import sympy as sp import sympy as sp
from blender_maxwell.utils.pydantic_sympy import ConstrSympyExpr from blender_maxwell.utils.pydantic_sympy import ConstrSympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -2,6 +2,7 @@ import bpy
import sympy as sp import sympy as sp
from blender_maxwell.utils.pydantic_sympy import ConstrSympyExpr from blender_maxwell.utils.pydantic_sympy import ConstrSympyExpr
from ... import contracts as ct from ... import contracts as ct
from .. import base from .. import base

View File

@ -4,9 +4,10 @@ from pathlib import Path
import bpy import bpy
from ... import registration
from blender_maxwell.utils import pydeps, simple_logger from blender_maxwell.utils import pydeps, simple_logger
from ... import registration
log = simple_logger.get(__name__) log = simple_logger.get(__name__)

View File

@ -4,9 +4,10 @@ from pathlib import Path
import bpy import bpy
from .. import registration
from blender_maxwell.utils import logger as _logger from blender_maxwell.utils import logger as _logger
from .. import registration
log = _logger.get(__name__) log = _logger.get(__name__)

View File

@ -12,33 +12,20 @@ from pathlib import Path
import bpy import bpy
from . import contracts as ct
from .nodeps.utils import simple_logger from .nodeps.utils import simple_logger
log = simple_logger.get(__name__) log = simple_logger.get(__name__)
# TODO: More types for these things!
DelayedRegKey: typ.TypeAlias = str DelayedRegKey: typ.TypeAlias = str
BLClass: typ.TypeAlias = (
bpy.types.Panel
| bpy.types.UIList
| bpy.types.Menu
| bpy.types.Header
| bpy.types.Operator
| bpy.types.KeyingSetInfo
| bpy.types.RenderEngine
| bpy.types.AssetShelf
| bpy.types.FileHandler
)
BLKeymapItem: typ.TypeAlias = typ.Any ## TODO: Better Type
KeymapItemDef: typ.TypeAlias = typ.Any ## TODO: Better Type
#################### ####################
# - Globals # - Globals
#################### ####################
BL_KEYMAP: bpy.types.KeyMap | None = None BL_KEYMAP: bpy.types.KeyMap | None = None
REG__CLASSES: list[BLClass] = [] REG__CLASSES: list[ct.BLClass] = []
REG__KEYMAP_ITEMS: list[BLKeymapItem] = [] REG__KEYMAP_ITEMS: list[ct.BLKeymapItem] = []
DELAYED_REGISTRATIONS: dict[DelayedRegKey, typ.Callable[[Path], None]] = {} DELAYED_REGISTRATIONS: dict[DelayedRegKey, typ.Callable[[Path], None]] = {}
@ -51,7 +38,7 @@ EVENT__DEPS_SATISFIED: DelayedRegKey = 'on_deps_satisfied'
#################### ####################
# - Class Registration # - Class Registration
#################### ####################
def register_classes(bl_register: list[BLClass]) -> None: def register_classes(bl_register: list[ct.BLClass]) -> None:
"""Registers a Blender class, allowing it to hook into relevant Blender features. """Registers a Blender class, allowing it to hook into relevant Blender features.
Caches registered classes in the module global `REG__CLASSES`. Caches registered classes in the module global `REG__CLASSES`.
@ -150,8 +137,8 @@ def unregister_keymap_items():
#################### ####################
def delay_registration( def delay_registration(
delayed_reg_key: DelayedRegKey, delayed_reg_key: DelayedRegKey,
classes_cb: typ.Callable[[Path], list[BLClass]], classes_cb: typ.Callable[[Path], list[ct.BLClass]],
keymap_item_defs_cb: typ.Callable[[Path], list[KeymapItemDef]], keymap_item_defs_cb: typ.Callable[[Path], list[ct.KeymapItemDef]],
) -> None: ) -> None:
"""Delays the registration of Blender classes that depend on certain Python dependencies, for which neither the location nor validity is yet known. """Delays the registration of Blender classes that depend on certain Python dependencies, for which neither the location nor validity is yet known.

View File

@ -4,13 +4,11 @@ from types import MappingProxyType
import jax import jax
import jax.numpy as jnp import jax.numpy as jnp
import pandas as pd
# import jaxtyping as jtyp # import jaxtyping as jtyp
import sympy.physics.units as spu import sympy.physics.units as spu
import xarray import xarray
from . import extra_sympy_units as spux
from . import logger from . import logger
log = logger.get(__name__) log = logger.get(__name__)