A lightweight runtime SDK for executing Python sparkit scripts
Project description
📦 sparkit Runtime SDK
Um runtime leve para execução de scripts Python sparkit com:
- 🧠 Geração automática de schema
- 🖥️ CLI profissional (flags, help, validação)
- 🔄 Compatível com stdin/stdout (modo pipeline)
- ⚡ Execução de funções ou classes
- Uso de @Input / @Output / @Run decoradores
🚀 Instalação
git clone https://github.com/kelwp/sparkit
cd sparkit
Ou apenas copie a pasta sparkit para a raiz do seu projeto.
⚡ Uso rápido
🔹 Exemplo com classe
from sparkitSDK import sparkit
class SampleMonitor(NodeBase):
ip: str
device_id: str | None = None
outputs_def = {
'meta': {'type': dict[str, str]},
'main': {'type': dict[str, int]}
}
def run(self):
self.outputs.set_data("main", {"msg": "OK"})
sparkit.set_stdout({"teste": 1})
self.outputs.set_data("meta", {"status": 1})
if __name__ == "__main__":
sparkit.run(SampleMonitor)
🔹 Executando via CLI
python script.py --ip 192.168.0.1
🔹 Saída
{
"stdout": {
"status": "ok",
"ip": "192.168.0.1"
},
"stderr": null
}
🧠 Modos de entrada
1. Flags (CLI moderna)
python script.py --ip 123
2. JSON inline
python script.py --input '{"ip":"123"}'
3. Arquivo JSON
python script.py --input-file data.json
4. stdin (modo pipeline)
echo '{"ip":"123"}' | python script.py
👉 Ideal para integração com automações e orquestradores.
📖 Help automático
python script.py --help
Exemplo:
sparkit Script CLI
Inputs:
--ip (string, required)
Other options:
--input '<json>'
--input-file <file>
--schema
--help
Outputs:
status (string)
ip (string)
🧬 Schema automático
python script.py --schema
Saída:
{
"schema": {
"inputs": [
{"name": "ip", "type": "string", "required": true}
],
"outputs": [
{"name": "status", "type": "string"},
{"name": "ip", "type": "string"}
]
}
}
⚙️ Tipos suportados
| Tipo | Exemplo CLI | Resultado |
|---|---|---|
| string | --name John |
"John" |
| number | --age 25 |
25 |
| boolean | --active true |
true |
| array | --tags '[1,2,3]' |
[1,2,3] |
| json | --data '{"a":1}' |
{ "a":1 } |
🧪 Execução com função
from runtime import sparkitRuntime
def handler(ip: str):
return {"status": "ok", "ip": ip}
if __name__ == "__main__":
sparkitRuntime().run(handler)
🔁 Estrutura de saída
Todo script retorna:
{
"stdout": {...},
"stderr": null
}
Ou em caso de erro:
{
"stdout": null,
"stderr": {
"type": "ValueError",
"message": "Missing required input: ip",
"traceback": "..."
}
}
🧩 Integração com sparkit
Esse runtime foi projetado para funcionar diretamente em pipelines:
- Recebe JSON via stdin
- Retorna JSON estruturado
- Possui schema introspectivo
👉 Ideal para:
- automações
- workflows
- agentes
- execução remota
🏗️ Arquitetura
-
sparkitRuntime- parsing CLI
- leitura de inputs
- execução
- geração de schema
- tratamento de erro
🔒 Validações
- Campos obrigatórios (
required) - Tipagem automática
- Erros estruturados
- Argumentos desconhecidos são rejeitados
💡 Filosofia
Esse SDK segue 3 princípios:
- Zero boilerplate
- CLI primeiro
- Compatível com pipelines
🚀 Roadmap
- Autocomplete (bash/zsh)
- Logs coloridos
- Plugins
- Execução assíncrona
- Cache de execução
🤝 Contribuição
Pull requests são bem-vindos!
📄 Licença
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sparkit-0.1.1.tar.gz.
File metadata
- Download URL: sparkit-0.1.1.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d61212d8f2daf724a5e786622a65aea8d285e0750c32559ee2360e51230bf3e5
|
|
| MD5 |
7fa071f457b29373f7affda017a87b8d
|
|
| BLAKE2b-256 |
66732b8121fe0775fcac204264601b0ebc4c6730bad5b8f1297e51d610c2cbaf
|
File details
Details for the file sparkit-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sparkit-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6761210ab8d7dcf30382fecea92ca1ec416db5e9c9fa06be9f1b94df79b6001d
|
|
| MD5 |
49fe9e9cb77a1f980df1e99c8694c522
|
|
| BLAKE2b-256 |
097b48c36080ea12fa54bbfb1ce4771662b679ecfeb5468e319e9325a39543e3
|