Skip to main content

MSB Architecture

Python Version License Version

Mega-Super-Base (MSB) is an architecture for Python applications built around a single entry point. You describe your data as typed entities, you describe what may be done to them as operations, and everything reaches both through one orchestrator — a user, a GUI, another API, whatever drives the application.

A request is data, not a call:

{"operation": "configure", "obj": telescope, "attributes": {"set_diameter": 64.0}}

which is what lets the same code serve a dialog box, a script and a remote caller, and what lets a session be logged and replayed.

Features

  • Typed entities: attributes validated against their annotations, nested to any depth, including List, Dict, Tuple, Set, Union, Literal, Callable and Type[X].
  • Containers for collections: named, queryable, serializable, with bulk operations.
  • One entry point: a Manipulator registers operations and processes requests; the per-operation facades are sugar so you rarely write a request dictionary by hand.
  • Operations that write themselves: a handler is usually one call to _apply_methods, which applies everything a request names and reports each outcome.
  • Serialization: nested objects to any depth, restored by type, with cycles detected rather than followed. A JSON round trip is faithful except for Set, FrozenSet and Tuple fields, which is item B12 in the roadmap.
  • Logging that behaves: a dedicated msb_arch logger that stays silent until the application configures it.
  • Exceptions you can catch precisely: everything derives from MSBError, and also from the built-in it replaces, so except TypeError keeps working while except DuplicateNameError becomes possible.
  • No external dependencies: Python >= 3.12 and nothing else.

Installation

pip install msb_arch

Quick Start

Describe the data, describe the operations, drive both through the orchestrator.

from msb_arch import BaseContainer, BaseEntity, Manipulator, Super

# 1. the data
class Telescope(BaseEntity):
    diameter: float

    def get_diameter(self) -> float:
        return self.diameter

    def set_diameter(self, value: float) -> bool:
        self.diameter = value
        return True

class Telescopes(BaseContainer[Telescope]):
    pass

# 2. the operations
class Inspector(Super):
    OPERATION = "inspect"

    def _inspect(self, obj, attributes):
        return self._apply_methods(obj, attributes)

class Configurator(Super):
    OPERATION = "configure"

    def _configure(self, obj, attributes):
        return self._apply_methods(obj, attributes)

# 3. the entry point
class Observatory(Manipulator):
    pass

manipulator = Observatory(base_classes=[Telescope, Telescopes])
manipulator.register_operation(Inspector(manipulator))
manipulator.register_operation(Configurator(manipulator))

dishes = Telescopes(name="array")
dishes.add(Telescope(name="DSS14", diameter=70.0))
dish = dishes.get("DSS14")

manipulator.inspect(dish, get_diameter=None)      # 70.0
manipulator.configure(dish, set_diameter=64.0)
manipulator.inspect(dish, get_diameter=None)      # 64.0

dishes.to_dict()["items"]["DSS14"]["diameter"]    # 64.0

Two handlers of one line each serve every type: the orchestrator dispatches by operation and by the type of the object, so adding an entity adds no code to the operation layer.

Ask for several things at once and every outcome comes back, whatever the order:

manipulator.inspect(dish, get_diameter=None, get=["name", "isactive"])
# {'get_diameter': {'status': True, 'result': 64.0},
#  'get':          {'status': True, 'result': {'name': 'DSS14', 'isactive': True}}}

Run several requests as one batch:

manipulator.batch([
    {"operation": "configure", "obj": dish, "attributes": {"set_diameter": 70.0}},
    {"operation": "inspect", "obj": dish, "attributes": {"get_diameter": None}},
])

Architecture

Four modules, three layers.

Layer Module What lives there
Base — the data serializable.py, baseentity.py, basecontainer.py Validation, serialization, caching, ownership
Super — the operations super.py, project.py Handlers, method resolution, projects
Mega — the entry point manipulator.py Operation registry, request processing, facades, batches
Shared results.py, utils/ Result types, logging, validation helpers

Main classes:

  • Serializable — what an entity and a container have in common: annotated fields and their validation, name and isactive, to_dict, the cache. Use it in isinstance checks that should accept either.
  • BaseEntity — an object addressed by its attributes.
  • BaseContainer[T] — a named collection addressed by its items. A sibling of BaseEntity, not a subclass: an entity and a container mean different things by get, set and clear.
  • Super — an operation. Subclass it, name the operation, and write handlers as _<operation>_<type> or _<operation> for the fallback.
  • Project — a named collection of entities with a factory for creating them.
  • Manipulator — the entry point. Registers operations, processes requests, generates a facade per operation.
  • MethodResults — what an operation reports: every method it ran, mapped to its outcome.

Documentation

Testing

Unit, integration, performance and concurrency suites, run with pytest.

The tests import msb_arch rather than the source tree, so they exercise whatever is installed. Install the package first:

pip install -e .

Then run them:

pytest tests/

CI builds the wheel, installs it, checks that msb_arch resolves inside site-packages, and runs the same suites against it — so the distribution that ships is the one that was tested.

License

MSB is licensed under the MSB Software License for non-commercial and research use, allowing free use, modification, and distribution for non-commercial purposes with attribution.

For commercial use, a separate royalty-bearing license is required. Please contact almax1024@gmail.com for details.

Contacts

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

msb_arch-0.5.0.tar.gz (127.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

msb_arch-0.5.0-py3-none-any.whl (50.7 kB view details)

Uploaded Python 3

File details

Details for the file msb_arch-0.5.0.tar.gz.

File metadata

  • Download URL: msb_arch-0.5.0.tar.gz
  • Upload date:
  • Size: 127.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for msb_arch-0.5.0.tar.gz
Algorithm Hash digest
SHA256 d773fb7611777af3cc5631746b77bf845068531db59cf41ccab6b96613a364fa
MD5 0c5c9e79b5e782c70f2833f267ecd7c1
BLAKE2b-256 21ab436b8f5653fd0384c475454f7379dca2ec3e0cb6895d6f3f7f2f32d5daa4

See more details on using hashes here.

File details

Details for the file msb_arch-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: msb_arch-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 50.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for msb_arch-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b2f142f795e6992d311c7a3601d8aee9406d0903a3920795a5b816032a095fb3
MD5 84ceef2c422fa80b196f466b52927a35
BLAKE2b-256 0c01b7e2dd4658d59878be4f3f486e2214f2d3c3da52afc335c85fdd140c2f19

See more details on using hashes here.

Release history Release notifications | RSS feed

2.0.1

2 files

2.0.0

2 files

1.10.0

2 files

1.9.2

2 files

1.9.1

2 files

1.9.0

2 files

1.8.0

2 files

1.7.0

2 files

1.6.0

2 files

1.5.0

2 files

1.4.0

2 files

1.3.0

2 files

1.2.0

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

This release

0.5.0 This release

2 files

0.4.0

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page