add work_dir attribute and ensure the working dir exists