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:
- Optionally generating transformation code using an AI model via a
TransformationBuilder
iftransformation_code
is not provided. explicitly passed.- Executing the transformation code using a
CodeTransformer
and aCodeExecutor
.- Exporting the results to the specified output.
Arguments:
sdif
- Path to the input SDIF file or anSDIFDatabase
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 theCodeTransformer
to determine output filenames if the transformation result keys match.
instructions
- Optional. Natural language instructions for the AI to generate the transformation code. Used iftransformation_code
is None.
transformation_code
0 - 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 thetransformation_code
2.
transformation_code
2 - Optional. Antransformation_code
4 instance responsible for generating the transformation code iftransformation_code
is not provided. If None, atransformation_code
6 is instantiated.
transformation_code
7 - Optional. ACodeExecutor
instance for running the transformation code. If None, atransformation_code
9 is used.
CodeTransformer
0 - Optional. ACodeTransformer
1 server instance for the AI code builder. Defaults to the globalCodeTransformer
2 instance iftransformation_code
2 is None and a newtransformation_code
6 is being created.
CodeTransformer
5 - Optional. A user-providedCodeTransformer
6 instance. If provided whentransformation_code
2 is None, it will be used by the internally createdtransformation_code
6. The caller is responsible for managing the lifecycle of a provided client.
CodeTransformer
9 - The language model to use for code generation (e.g., "o4-mini"). Used iftransformation_code
2 is None.
CodeExecutor
1 - If True, the transformation aims to match only the schema (headers) of theoutput_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.
CodeExecutor
3 - Optional dictionary of keyword arguments to pass to the representer when analyzingoutput_target_files
.Returns:
A
CodeExecutor
5 object containing the path to the output and the transformation code used.