how to get job results disco python

84 Views Asked by At

How to get job results from disco python?

I have tried disco jobs:

jmunsch@disco-master-5147:~$ disco jobs
KeyCount@5ca:2d323:53093
KeyCount@5ca:2bcb5:4f479

disco results:

jmunsch@disco-master-5147:~$ disco results "KeyCount@5ca:2bcb5:4f479"
dir://disco-node-9144/disco/disco-node-9144/1a/KeyCount@5ca:2bcb5:4f479/.disco/reduce-1001-1482183896238504.results

Here is the input:

jmunsch@disco-master-5147:~$ disco jobdict "KeyCount@5ca:2bcb5:4f479"
inputs  [ ... a bunch of inputs ... ]
pipeline    [[u'iter_pgs_item', u'split', False], [u'reduce', u'group_label', False]]
save_info   ddfs
worker  virtualenvworker
save_results    False
prefix  KeyCount
scheduler   {}
owner   jenkins@jenkins-4139

related:

1

There are 1 best solutions below

0
On

I opened a pull request, but basically this is one way to do it, I wanted to stream out the reduce results as len(2) tuples, as part of the bin/discocli.py:

@Disco.job_command
def results_get(program, jobname):
    """Usage: jobname

    Print out the data of a completed job.
    `disco jobs | xargs -IJOB_ID disco results_get JOB_ID`
    """
    status, results = program.disco.results(jobname)
    if sys.version_info[0] == 2:
        binary_type = str
    elif sys.version_info[0] == 3:
        binary_type = bytes
    if status == 'ready':
        for line in program.disco.result_iterator(results):
            if isinstance(line, binary_type):
                line = line.decode('utf-8')
            print(line)

See: