Workflow Data Directory in tool development

The Workflow Data Directory environment variable points to your project files during tool development so you can read and process input data within the sandboxed environment.

Access the files within your project using the WORKFLOW\_DATA\_DIRECTORY directory.
import os

def run_tool(config, args):
    # ✅ Get workflow data directory from environment variable
    workflow_data_dir = os.environ.get('WORKFLOW_DATA_DIRECTORY', '/workflow_data')
    
    # ✅ Read project file
    input_file = os.path.join(workflow_data_dir, 'data', 'input.csv')
    
    if not os.path.exists(input_file):
        return {"error": f"Input file not found: {input_file}"}
    
    # Read and process the file
    with open(input_file, 'r') as f:
        data = f.read()
    
    # ✅ Write output to artifact file directory (relative path)
    output_file = "processed_output.csv"
    with open(output_file, 'w') as f:
        f.write(data)
    
    return "Processing complete"