Using Workflow Data Directory in Tool Development

To access the files within your project, you must use 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"