Skip to main content

Chassis 2024

Automatically sequence infrastructure initialization and teardown.

Installation

pip install chassis2024

Brief Explanation

(This is just a teaser. Read the github project pages for more details and a full tutorial.)

The idea of chassis2024 to make it so that you quickly reuse infrastructure.

"Infrastructure" here means things like:

  • writing a lock file for your program
  • reading config files
  • setting up a GUI system (like tkinter), and running a main loop
  • populating and processing argparse
  • reading a persistence file, and writing back to it when closing

I wanted to make it trivial to combine infrastructure like these, together.

The central challenge was making sure that infrastructure steps are followed in the correct order.

An Example: Hello, world!

Here's a "Hello, world!" program:

import sys

import chassis2024
import chassis2024.basicrun


CHASSIS2024_SPEC = {
    "INTERFACES": {"RUN": sys.modules[__name__]}
}


# interface: RUN
def run():
    print("Hello, world!")


if __name__ == "__main__":
    chassis2024.run()

Execution Nodes

Chassis 2024 infrastructure positions itself within an execution graph.

By default, the execution graph is very basic:

  • #1 CLEAR -- the program begins
  • #2 RESET -- the program is initialized
  • #3 ARGPARSE -- Command Line arguments are parsed
  • #4 CONNECT -- files are loaded, resources are connected
  • #5 ACTIVATE -- user interface systems are activated
  • #6 UP -- the program is running, main loop operations commense

This built-in system is fixed, but there is no default implementation, and it is very flexible, because Chassis 2024 infrastructure can extend the graph via module declarations.

An example from the chassis2024.argparse package:

CHASSIS2024_SPEC = {
    EXECUTES_GRAPH_NODES: [CLEAR_ARGPARSE, RESET_ARGPARSE, ARGPARSE],
    EXECUTION_GRAPH_SEQUENCES: [(CLEAR, CLEAR_ARGPARSE, RESET, RESET_ARGPARSE, ARGPARSE)],
    INTERFACES: {ARGPARSE: sys.modules[__name__]}
}

Interfaces

The infrastructure pieces glue to one another through "interfaces." Any object or module can be at the end of an interface, but only one thing can implement a given interface.

Similarly, each execution node can activate only one function.

More Complex Example


import sys

import chassis2024
import chassis2024.basicrun
import chassis2024.argparse
import chassis2024.basicjsonpersistence
from chassis2024.words import *
from chassis2024.argparse.words import *
from chassis2024.basicjsonpersistence.words import *


this_module = sys.modules[__name__]


CHASSIS2024_SPEC = {
    INTERFACES: {RUN: this_module,
                 ARGPARSE_CONFIGURE: this_module}
}

EXECUTION_SPEC = {
    BASICJSONPERSISTENCE: {
        SAVE_AT_EXIT: True,
        CREATE_FOLDER: False,
        FILEPATH: "./echo_persistence_data.json"
    }
}


# interface: ARGPARSE_CONFIGURE
def argparse_configure(parser):
    parser.add_argument("-e", "--echo",
                        help="input string to echo",
                        default=None)
    parser.add_argument("-r", "--repeat-last",
                        dest="repeat",
                        help="repeat the last used echo string",
                        action="store_true")
    chassis2024.basicjsonpersistence.argparse_configure(parser)

# interface: RUN
def run():
    argparser = chassis2024.interface(ARGPARSE, required=True)
    D = chassis2024.interface(PERSISTENCE_DATA, required=True).data()
    if argparser.args.echo is not None:
        print(argparser.args.echo)
        D["msg"] = argparser.args.echo  # saved automatically
    else:
        print(D.get("msg", "use -e to specify string to echo"))


if __name__ == "__main__":
    chassis2024.run()

Release files for chassis2024 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chassis2024 1.0.0
File Size Uploaded
chassis2024-1.0.0.tar.gz 14.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for chassis2024 1.0.0
File Interpreter ABI Platform
chassis2024-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.1 kB

Release files / chassis2024-1.0.0.tar.gz

Download URL chassis2024-1.0.0.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
74e746209a84011eb77abc0cbfef5885b00d758b6517096bb5e56f9391ff95cd
BLAKE2b-256 checksum
How to use checksums
75d0b3bc1a719fecaf7e1c503573c9850675956af2975f17d0a61bcb2a9eeaa6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / chassis2024-1.0.0-py3-none-any.whl

Download URL chassis2024-1.0.0-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
919adb9948053abf3b01f0a29884292657bd7e84080ed60709faea5396537e57
BLAKE2b-256 checksum
How to use checksums
53d49a32335eb60ce53f65228ab4bf9b23681db18b68f9f71dbf869ff4ab275e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release 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