Skip to main content

satif_ai.transform

atransform

async def atransform(
sdif: SDIFPath,
output_target_files: Dict[FilePath, str] | List[FilePath] | FilePath,
instructions: Optional[str] = None,
output_path: FilePath = Path("."),
*,
transformation_code: Optional[str] = None,
transformation_builder: Optional[AsyncTransformationBuilder] = None,
code_executor: Optional[CodeExecutor] = None,
mcp_server: Optional[FastMCP] = None,
mcp_client: Optional[Client] = None,
llm_model: str = "o4-mini",
schema_only: bool = False,
representer_kwargs: Optional[Dict[str,
Any]] = None) -> TransformationResult

Asynchronously transforms an SDIF (Standard Data Interchange Format) input using an AI-generated or provided transformation code.

This function orchestrates the process of:

  1. Optionally generating transformation code using an AI model via a TransformationBuilder if transformation_code is not provided. explicitly passed.
  2. Executing the transformation code using a CodeTransformer and a CodeExecutor.
  3. Exporting the results to the specified output.

Arguments:

  • sdif - Path to the input SDIF file or an SDIFDatabase object.

  • output_target_files - A dictionary mapping original example file paths (or string identifiers) to their desired agent-facing filenames, or a list of output example file paths, or a single output file path. These are used by the AI to understand the target format and structure, and also by the CodeTransformer to determine output filenames if the transformation result keys match.

  • instructions - Optional. Natural language instructions for the AI to generate the transformation code. Used if transformation_code is None.

  • transformation_code0 - Path to the directory where transformation outputs will be saved.

  • transformation_code - Optional. Pre-existing Python code for the transformation. If None, code will be generated by the transformation_code2.

  • transformation_code2 - Optional. An transformation_code4 instance responsible for generating the transformation code if transformation_code is not provided. If None, a transformation_code6 is instantiated.

  • transformation_code7 - Optional. A CodeExecutor instance for running the transformation code. If None, a transformation_code9 is used.

  • CodeTransformer0 - Optional. A CodeTransformer1 server instance for the AI code builder. Defaults to the global CodeTransformer2 instance if transformation_code2 is None and a new transformation_code6 is being created.

  • CodeTransformer5 - Optional. A user-provided CodeTransformer6 instance. If provided when transformation_code2 is None, it will be used by the internally created transformation_code6. The caller is responsible for managing the lifecycle of a provided client.

  • CodeTransformer9 - The language model to use for code generation (e.g., "o4-mini"). Used if transformation_code2 is None.

  • CodeExecutor1 - If True, the transformation aims to match only the schema (headers) of the output_target_files, and input samples may be omitted or marked as empty for the AI. This is useful for structural transformations without processing actual data rows.

  • CodeExecutor3 - Optional dictionary of keyword arguments to pass to the representer when analyzing output_target_files.

Returns:

A CodeExecutor5 object containing the path to the output and the transformation code used.