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.0.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.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: scic_framework-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 ac62e39d62c6ea4793e781a4b380ee03179cfd30523650de2214a35d10ed24d8
MD5 f882b5570ececb05b4fcf4815905166a
BLAKE2b-256 a9f48c255d8bea4e7e55e78e2cb11fd962d7dd96474c8f9b754e851d516f9c03

See more details on using hashes here.

File details

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

File metadata

  • Download URL: scic_framework-0.2.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f6674f9910bc447a457a8385777a3808cfe7f81859da6220855ee037d278332
MD5 d0e4f843cc1671c68c02f1b322d617aa
BLAKE2b-256 96f48bb1f7a4933ca8533e9aaaa90dbde57660c25c29e4ccedcd904955eee001

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