[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [HTCondor-users] Conditional output file transfer



On Thu, May 09, 2013 at 08:35:20PM +0100, Brian Candler wrote:
> Also, the starter post script needs to know the filename of the error file,
> which is different for each job.  If it gets $_CONDOR_JOB_AD in its
> environment then it could read and parse that file.  But it might be simpler
> if you could pass macros, e.g.
> 
> +PostCmd = cleanup.sh $RETURN $(error)

Ah, I was looking in 7.8 docs. I see that 7.9 has gained +PreArgs /
+PreArguments / +PostArgs / +PostArguments functionality. That solves this
issue, apart from the need to get the return code.

Anyway, since the jobs I'm running are wrapped in python I've just bundled
the functionality at the point where the job starts. A failure causes an
exception and the cleanup code is not run.

    ...
    if running():
        if report_hostname:
            import socket
            print("HTCONDOR: Running on %s" % socket.gethostname(), file=sys.stderr)
        run(*args, **kwargs)
        if remove_error:
            try:
                os.unlink(ad_attr('Err'))
            except KeyError, OSError:
                pass
        sys.exit(0)

Full source at https://github.com/candlerb/htcondor.py

Thanks again for the pointers!

Regards,

Brian.