def do_work(args):
    directory_ = args['directory']
    print "directory=%s" % directory_

    task_location = args['task_file']
    print "task_file=%s" % task_location
    
    # load task from pickled file, use regular pickle
    try:
        d = _os.path.dirname(_os.path.abspath(__file__))

        exec_dir = _os.mkdir(_os.path.join(d, 'gl_art-'))
        print "exec_dir=%s" % exec_dir
        metrics = {}
        path = _os.path.dirname(task_location)
        
        with open(task_location, 'rb') as task_file:
            task = _pickle.load(task_file)
        runner = _LocalExecutionEnvironment()

        if isinstance(task, Task):
            print "Running task: %s" % task.name
            runner.run_task(task, metrics=metrics, location=exec_dir)
        elif isinstance(task, Job):
            print "Running job: %s" % task.name
            runner.run_job(task, None)
        else:
            print "Unknown type of work, failing."
            exit(1)

        # write out task metrics to file, so session process can incorporate into client task
        with open(_os.path.join(path, 'metrics'), 'w') as f:
            f.writelines(str(metrics))

        #task = None
        # with open(task_location, 'rb') as task_file:
        #     task = _pickle.load(task_file)
        # session = Session(d)


        #print "Running task: %s " % task

        # call local_environment.run
        #le = execenv.LocalExecutionEnvironment()
        #le.run_stage(session, stage)
    except Exception as e:
        print "Exception: %s" % e
        exit(1)
        
        path = _os.path.dirname(serialized_job_location)
        job = _Job._deserialize(serialized_job_location)
        # sets a file path for local job to update task status
        status_path = _os.path.join(path, 'status')
        starttime = str(_datetime.datetime.now().isoformat())

        # write the start time of the job for local async 
        try:
            with open(_os.path.join(path, 'status'), 'w') as f:
                f.writelines(str(starttime + "\n"))
        except OSError:
            pass

        # Now use the local launcher to run the job in this thread, will be async w.r.t other thread.
        runner = _LocalExecutionEnvironment()
        runner.run_job(job, None, status_path=status_path)

        # save end time to status
        endtime = str(_datetime.datetime.now().isoformat())
        with open(_os.path.join(path, 'status'), 'a+') as f:
            f.writelines(str(endtime + "\n"))
        
        # write out job metrics to file, so session process can incorporate into client job
        with open(_os.path.join(path, 'metrics'), 'w') as f:
            f.writelines(str(job.metrics))

        # now that completed successfully write success exitcode to file, so client job can 
        # correctly report that execution completed successfully
        with open(_os.path.join(path, 'exitcode'), 'w') as f:
            f.write('0')