Skip to main content

Sistema de Control de Instruccion por Comandos

Project description

SCIC 0.2.0

SCIC (Sistema de Control de Instrucción por Comandos) registra, organiza, resuelve y ejecuta funciones Python mediante instrucciones textuales.

context1 context2 function parameters...

Una función se implementa una vez y puede consumirse desde CLI, WebGUI, DesktopGUI, API, SDK, scripts o automatizaciones.

Principios

  • El árbol sólo contiene Context y Executable.
  • Los nombres son únicos dentro de su contexto padre.
  • Una función registrada sigue siendo un callable Python ordinario.
  • Executable declara parámetros y resultados mediante DataValue.
  • Los contratos usan validación posicional explícita.
  • El registro compartido no contiene estado de navegación.
  • Cada consumidor utiliza su propia SCICSession.
  • Las interfaces controlan ayuda, presentación, progreso y procesos compuestos.
  • La API primaria de ejecución es asíncrona.

Dependencias

resourcetree >= 0.2.0, < 0.3.0
datavalue   >= 0.2.0, < 0.3.0

Instalación

python3 -m pip install .

Para desarrollo:

python3 -m pip install -e ".[test]"
pytest

Uso

from datavalue import ComplexData, PrimitiveData, ValidationMode
from scic import Executable, SCIC


def primitive(data_type, name, **constraints):
    return PrimitiveData(
        data_type=data_type,
        value=None,
        name=name,
        data_class=True,
        **constraints,
    )


def signature(name, *schemas):
    return ComplexData(
        data_type=list,
        value=None,
        name=name,
        possible_values=schemas,
        data_class=True,
        validation_mode=ValidationMode.POSITIONAL,
    )


def add(number_a: int, number_b: int) -> int:
    return number_a + number_b


scic = SCIC()
math = scic.create_context("math")

adapter = Executable(
    name="add",
    description="Suma dos enteros.",
    parameters=signature(
        "parameters",
        primitive(int, "number_a"),
        primitive(int, "number_b"),
    ),
    results=signature(
        "results",
        primitive(int, "sum"),
    ),
)

scic.register_function(
    adapter=adapter,
    function=add,
    context=math,
)

scic.freeze()
session = scic.create_session()

results = await session.execute(
    "math add 20 22"
)

assert results == [42]

Navegación relativa

await session.execute("math")
assert session.context_path == "scic/math"

results = await session.execute("add 10 5")
assert results == [15]

session.back()
session.reset()

El nombre de la raíz permite resolución absoluta sin modificar el contexto:

results = await session.execute(
    "scic math add 7 8"
)

Sesiones independientes

cli = scic.create_session()
browser_a = scic.create_session()
browser_b = scic.create_session()

cli.enter("math")
browser_a.enter("user")
browser_b.enter("text")

Todos comparten el mismo árbol y las mismas funciones, pero conservan su propio contexto activo.

Autodescripción

session.describe()
session.describe("math add")
session.list_context()
scic.export_tree()

La salida es estructurada. Cada consumidor decide si la transforma en texto, HTML, JSON, widgets o documentación.

Ejemplos

CLI:

python3 examples/cli.py

WebGUI con una sesión independiente por navegador:

python3 examples/webgui.py

Abrir:

http://localhost:8080

Límites intencionales

El núcleo no administra:

  • Presentación.
  • Permisos o roles.
  • Procesos interactivos compuestos.
  • Progreso.
  • HTTP.
  • Qt o HTML.
  • Persistencia.
  • Logging.
  • Ejecución remota.

Estas capacidades pertenecen a la aplicación o a sus consumidores.

Project details


Download files

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

Source Distribution

scic_framework-0.2.1.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

scic_framework-0.2.1-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file scic_framework-0.2.1.tar.gz.

File metadata

  • Download URL: scic_framework-0.2.1.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for scic_framework-0.2.1.tar.gz
Algorithm Hash digest
SHA256 e49fdc8a4d77d625aba28519ea27d05c50043f757c4817c147cccf5c2d548d4f
MD5 3f9450b67f4736fc6b14a40f408d2597
BLAKE2b-256 ee895b2c2fd8bd6156e95dcea1eeaf48d54bf0b9c9569c4ea243dff0ee0d52ae

See more details on using hashes here.

File details

Details for the file scic_framework-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: scic_framework-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for scic_framework-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d04b8d14f7f6aac5c5729625bd88f448164f4877fc8ce45cf0b7b5c67fbbc452
MD5 b711ce425dac28ee915f67948e6d504f
BLAKE2b-256 2afa75300c3d44cf1ed7faca655c07f4f29ad96fe9018e86a4abf2d1d945e935

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page