Run Python

action_run_python · action · Utility · Disponibile · v1.1.0

Descrizione

Esegue codice Python in sandbox Docker isolata (memoria 512MB, CPU 1 core, no privileges, read-only FS). Libreria stdlib disponibile: matplotlib/numpy/pandas/scipy/plotly/pillow/sympy/openpyxl/tabulate + requests/httpx (quando allowNetwork=true). Output: { stdout, stderr, exitCode, durationMs, files[] (grafici/CSV salvati in output/ ritornati base64) }. Timeout configurabile (max 120s). Input/ctx esposti come dict Python via env var FLOWFORGE_INPUT. Network policy: • allowNetwork=false (default, raccomandato) → ZERO egress, sicurezza massima. Per chiamate HTTP, usa action_http_request come step separato (più ergonomico + audit nativo). • allowNetwork=true (opt-in) → egress Internet abilitato MA con SSRF block: cloud metadata 169.254.169.254 + RFC1918 (10/8, 172.16/12, 192.168/16) + loopback + Docker internal BLOCCATI a livello iptables. Audit log scrive ogni esecuzione con allowNetwork=true. Quota: 10 esec/min per tenant. Use case: data analysis su CSV, generazione grafici matplotlib per report, calcoli statistici/finanziari complessi, ML inference one-shot, manipolazione immagini PIL, API HTTP custom non coperte dai 216 nodi stdlib (allowNetwork=true), conversioni formati custom.

⚙️ Parametri di configurazione

Campi mostrati nell’editor quando si configura il nodo. Generati direttamente dal NodeDefconfigFields.

CampoTipoRequiredDefaultDescrizione
code
Codice Python
codesiimport json, os data = json.loads(os.environ.get("FLOWFORGE_INPUT", "{}")) print({"received_keys": list(data.keys()), "count": len(data)}) Codice Python. Input del nodo precedente disponibile in env var FLOWFORGE_INPUT (JSON string). Output stdout viene catturato e parsato come JSON se possibile, altrimenti tornato come stringa. Per output file (grafici/CSV) salva in cartella output/. Esempio: plt.savefig("output/chart.png"). Con allowNetwork=true: import requests; r=requests.get("https://api.esempio.it/x", timeout=10); print(r.json()).
timeoutMs
Timeout (ms)
numberno30000Tempo massimo esecuzione. Min 5000, max 120000. Default 30s.
parseStdoutJson
Parse stdout come JSON
booleannotrueSe on, prova a parsare stdout come JSON e ritorna l'oggetto strutturato. Se off o parsing fail, ritorna stdout come stringa.
allowNetwork
Abilita egress Internet (HTTP outbound)
booleannofalseOFF (default, raccomandato): nessun egress, sandbox massimamente isolata. ON (opt-in): il codice può chiamare API HTTP esterne (requests/httpx). SSRF block automatico verso cloud metadata (169.254.169.254) + RFC1918 + loopback + reti Docker interne. Ogni esecuzione con ON viene auditata nel log dedicato code-runner. Per task production-grade preferisci action_http_request (più ergonomico + circuit breaker per host).

💡 Esempio configurazione

Snippet JSON del nodo come compare nel workflow. I valori sono derivati daidefaultValue e dai parametri required.

{
  "id": "node-action_run_python-1",
  "defId": "action_run_python",
  "label": "Run Python",
  "config": {
    "code": "import json, os\n\ndata = json.loads(os.environ.get(\"FLOWFORGE_INPUT\", \"{}\"))\nprint({\"received_keys\": list(data.keys()), \"count\": len(data)})\n",
    "timeoutMs": 30000,
    "parseStdoutJson": true,
    "allowNetwork": false
  }
}

🔗 Nodi correlati nella stessa categoria

Pronto a usare Run Python?

Disponibile da subito in tutti i piani FlowForge. Provalo gratis senza carta di credito.

Inizia gratisSfoglia tutti i nodi