dreaMake.dev
S3Flow · Documentation
Deutsch · English
Contents

Python node

The Python node processes files with your Python code. Use it to change text, CSV content or metadata, and to filter files out. It has one required input, objects, and one output, files (diamond). Connect the output to Upload. It cannot be muted.

Python code runs during planning, before you confirm the S3 changes. Connect the input to List, Filter or Merge. An active Copy, Move, Upload or Download node cannot precede it.

The node passes results to the next node. It does not write to S3 itself. Your code is saved with the workflow. Share the workflow to share the code.

Safety

Python code runs on your computer. Only run code you trust. The code can read or write files and make connections itself. A separate process is not a sandbox. The app gives the process no credentials, no S3 access and no environment variables containing secrets.

When you open a foreign workflow with Python code, Flow contains Python code appears. Foreign means that the workflow and its Python code have no matching local proof of origin. This includes downloads, workflows from other computers and older files without proof of origin.

  1. Select View only to review the code first.
  2. Click Review Python code… to open the first Python node.
  3. Review all other Python nodes too.
  4. Select Allow Python code… if you trust the code.
  5. Confirm with Allow code for this opening.

With View only, tests and workflow runs stay blocked. Allowing code does not start a run. Permission applies only to the current code until you close the workflow. The warning appears again when you reopen it. Changes to Python code or added Python nodes revoke permission. Saving under another name does not make foreign code your own.

Python is included in S3Flow. You do not need to install Python. Use only the Python standard library. Extra packages and pip are not supported.

Function and metadata

S3Flow calls this function once per file:

def transform(obj, src, dst):
    return obj
Parameter Content
obj Dictionary containing the file metadata.
src Binary stream for reading the content.
dst Binary stream for writing new content.

The keys in obj describe the input. Credentials are not included.

Key Type S3 input Local file and sample file
bucket str Bucket name ""
key str Full key, such as in/2026/a.csv Relative path; filename only in tests
size int Input size in bytes File size in bytes
last_modified str ISO 8601, such as 2026-11-21T22:08:47+00:00 Modification time in UTC, possibly with microseconds
etag str Storage identifier, including quotation marks, such as "9b2c…5328" or "…-3" for multipart ""
profile str Profile name of the run ""
content_type str Object Content-Type Inferred from the extension, otherwise ""
metadata dict[str, str] User metadata without x-amz-meta- {}

Only changes to key, content_type and metadata take effect. Upload uses the Content-Type and user metadata. metadata replaces all previous user metadata. Add information through obj["metadata"]. Changes to other keys are ignored. Additional keys are not passed on.

The new key must not be empty, end with / or contain NUL. It must use at most 1,024 UTF-8 bytes. content_type must be ASCII text. For metadata, keys and values must be ASCII text, with at most 2,048 characters in total. Invalid values cause the file to be skipped.

The next node builds the target key from its prefix and the relative path. For this path, it removes the source prefix from List from the new key. If that prefix is absent, it uses the whole new key. Duplicate target keys stop the next node with Target keys collide..

The return value must be a dictionary or None. A dictionary may contain only JSON values and use at most 2 MB. Other return values cause a Python error.

After a transformation, size and etag still describe the input. The actual output size is the number of bytes written. Storage assigns a new ETag only on upload. In a test, After ▸ Metadata shows the output size; etag stays "".

Example: change line endings from CRLF to LF:

def transform(obj, src, dst):
    for line in src:
        dst.write(line.replace(b"\r\n", b"\n"))
    return obj

src supplies bytes. dst.write() accepts bytes. Use io.TextIOWrapper and csv from the standard library to process text and CSV.

Edit and test code

  1. Add Modify ▸ Python to the workflow.
  2. Connect the input to a compatible output.
  3. Select the Python node.
  4. Click Edit code… in the Inspector.
  5. Write the function in the code field.
  6. Click Choose sample file….
  7. Select a local sample file.
  8. Click Run test.
  9. Compare Before and After, under Content and Metadata on each side.
  10. Click Apply to apply the code to the workflow.

The test uses the current code and limits. It does not change the sample file or run other nodes. Your code can still access files and connections itself. Cancel test cancels the test. Cancel discards changes in the editor.

Sample metadata — not an S3 object identifies the sample metadata. The key matches the filename. Size and modification date come from the file. Bucket, profile and ETag have the value "". content_type comes from the extension; metadata is {}.

The preview shows at most the first 64 KiB on each side. Text uses UTF-8; invalid bytes are visibly replaced. Binary data appears as hexadecimal values. The preview does not change the content. Content unchanged means that nothing was written to dst. Filtered out — returned None means that the file is not passed on.

Output and details shows output from print() and, for errors, a traceback with lines from your code. Errors show the type, message and code line where available. After you change the code, sample file or limits, the test result is out of date. Run the test again. A successful test confirms only this example.

The six templates

  1. Select a template under Template….
  2. Click Insert template.
  3. Confirm replacement of the current code if asked.
  4. Read the comments at the start of the template.
  5. Adjust the stated assumptions to match your files.
  6. Test the template with a suitable sample file.

Selection alone does not change any code. You can undo template insertion.

CSV templates expect a header (HAS_HEADER = True). They read utf-8-sig, removing a BOM, and write UTF-8 without a BOM. Defaults: DELIMITER = ";", LF line endings, quotation marks only where needed. COLUMNS = None processes all columns. Otherwise, COLUMNS contains names from the header. Missing names cause the file to be skipped with an error. The header is preserved except when reordering.

Template Defaults and behavior
Convert encoding to UTF-8 SOURCE_ENCODING = "cp1252". Invalid bytes cause an error. Output has no BOM; line endings are preserved.
Change line endings (CRLF/LF) NEWLINE = b"\n"; for CRLF: b"\r\n". Replaces CRLF and LF. A lone CR and a final line without a line ending are preserved.
Decimal comma → point (CSV) COLUMNS = None. Converts only -?digits,digits, such as -12,50 → -12.50. Thousands separators stay unchanged.
Reorder columns (CSV) COLUMNS = ["id", "name", "date"]. Outputs exactly these columns in this order. Other columns are removed. Short rows are padded with "".
Replace null fields (CSV) COLUMNS = None, NULL_MARKERS = {"NULL", "null", "None", "NaN", "N/A"}, REPLACEMENT = "". Compares after trimming surrounding whitespace. Empty fields are preserved.
Float → integer (CSV) COLUMNS = None, ROUNDING = decimal.ROUND_HALF_UP: 2.5 → 3, -2.5 → -3. decimal.ROUND_DOWN truncates. Converts only -?digits.digits; exponents and decimal commas stay unchanged.

Four templates have a fixed node counterpart that needs no Python code: Convert encoding to UTF-8 → Change encoding, Change line endings (CRLF/LF) → Convert line endings, Decimal comma → point (CSV) → Swap decimal separator, Reorder columns (CSV) → CSV columns. One difference: CSV columns skips the file when a column is missing; the template pads short rows with "". See File nodes: process files. When it fits, use the fixed node.

Streaming, disk space and limits

S3Flow processes one file at a time. Streams allow processing in chunks. Read and write in chunks or line by line. A call such as src.read() without a size loads the entire content into memory itself. A single very long line can also use a lot of memory.

S3Flow writes new content to temporary files on disk. The next node reads the result from there. For S3 sources, allow space for input and output. S3Flow downloads the input first and checks available space for the input before downloading. Local files are read in place; these need space only for output. Files are in a s3flow-python-* subfolder of the system temporary folder (TMPDIR or /tmp on Linux, %TEMP% on Windows). Also keep space free for all results still waiting for further processing. Output can be larger than input. S3Flow removes temporary files after the run, including after errors or cancellation. Cleanup errors are shown.

Set the limits in the Inspector:

Setting Default Effect
Time limit per file 30 s Limits processing of one file in the Python code. If exceeded, S3Flow ends the process and skips the file.
Size limit per file 500 MB Limits the input size. Larger files are skipped with a message.

Allowed values are whole numbers from 1 to 3,600 seconds and from 1 to 100,000 MB. Other values block the run. There is no unlimited value. 1 MB is 1,000,000 bytes. A file of exactly 500,000,000 bytes is within the default limit. The size limit does not limit output. The time limit is not a deadline for the whole workflow.

The time limit measures wall-clock time from start to end of the Python process for each file. It includes Python startup, compilation, imports, transform and flushing/closing dst. Download, size and disk-space checks, subsequent nodes, preview and waiting for other files are excluded. Exactly the limit is allowed. S3Flow checks every 50 ms. If exceeded, it ends the process and its child processes and deletes partial output. Tests use the same measurement.

Errors and report

Python errors, exceeded limits and insufficient disk space cause the affected file to be skipped. Other files continue to be processed. Incomplete output never goes to the next node. There is no automatic retry. Structure, planning, S3 and other fatal runtime errors can still stop the entire run.

At the end, the log area shows Python results. For each Python node, n passed on · n filtered out · n skipped shows the number of files passed on, filtered out and skipped. The table has the columns Node, File, Result, Reason and Line. Completed with … skipped files indicates skipped files even if the node otherwise succeeded.

  1. Expand the Python node entry.
  2. For files with Result = Skipped, read File, Reason and Line where available.
  3. Double-click the file entry to open the editor at the error line, if a line is given.
  4. Fix the cause.
  5. Test the change before the next run.

For insufficient space, free disk space first. After cancellation, the report heading shows Run cancelled. Results cover processed files only. The report then covers only files already processed. Completed changes remain. S3Flow does not roll them back.

Return to Workflows and node editor.