<commit_before># Order a list of cat ids, launch AOP workflow for each one and download locally.

import json
import time

from gbdxtools import Interface

start_time = time.time()

catalog_ids = ['1030010045539700', '10200100414F0100', '10200100417A8C00']

print 'Order imagery from GBDX'
gi = Interface()
order_ids = [gi.order_imagery(catalog_id) for catalog_id in catalog_ids]

# check order status
pending_order_ids = order_ids
locations = []
while len(pending_order_ids)>0:
    print 'Pending orders', pending_order_ids
    for order_id in pending_order_ids:
        result = gi.check_order_status(order_id)
        print result
        location, status = result.keys()[0], result.values()[0]
        if status == 'delivered':
            pending_order_ids.remove(order_id)
            locations.append(location)
    time.sleep(300)   # check every five minutes

print 'Elapsed time: {} min'.format(round((time.time() - start_time)/60))

# where in bucket/prefix to store my AOP'ed imagery
s3_location = 'my_directory'

# launch AOP workflows
print 'Launch AOP workflows'
workflow_ids = [gi.launch_aop_to_s3_workflow(location,
                                             s3_location,
                                             enable_acomp='true') for location in locations]

# check workflow status
pending_workflow_ids = workflow_ids
while len(pending_workflow_ids) > 0:
    print 'Pending workflows', pending_workflow_ids
    for workflow_id in pending_workflow_ids:
        result = gi.check_workflow_status(workflow_id)
        if result['state'] == 'complete':
            pending_workflow_ids.remove(workflow_id)
    time.sleep(300)

print 'Elapsed time: {} min'.format(round((time.time() - start_time)/60))

# download
gi.download_from_s3(s3_location)
<commit_msg>removed time module, not needed<commit_after># Order a list of cat ids, launch AOP workflow for each one and download locally.

import json

from gbdxtools import Interface

start_time = time.time()

catalog_ids = ['1030010045539700', '10200100414F0100', '10200100417A8C00']

print 'Order imagery from GBDX'
gi = Interface()
order_ids = [gi.order_imagery(catalog_id) for catalog_id in catalog_ids]

# check order status
pending_order_ids = order_ids
locations = []
while len(pending_order_ids)>0:
    print 'Pending orders', pending_order_ids
    for order_id in pending_order_ids:
        result = gi.check_order_status(order_id)
        print result
        location, status = result.keys()[0], result.values()[0]
        if status == 'delivered':
            pending_order_ids.remove(order_id)
            locations.append(location)
    time.sleep(300)   # check every five minutes

print 'Elapsed time: {} min'.format(round((time.time() - start_time)/60))

# where in bucket/prefix to store my AOP'ed imagery
s3_location = 'my_directory'

# launch AOP workflows
print 'Launch AOP workflows'
workflow_ids = [gi.launch_aop_to_s3_workflow(location,
                                             s3_location,
                                             enable_acomp='true') for location in locations]

# check workflow status
pending_workflow_ids = workflow_ids
while len(pending_workflow_ids) > 0:
    print 'Pending workflows', pending_workflow_ids
    for workflow_id in pending_workflow_ids:
        result = gi.check_workflow_status(workflow_id)
        if result['state'] == 'complete':
            pending_workflow_ids.remove(workflow_id)
    time.sleep(300)

print 'Elapsed time: {} min'.format(round((time.time() - start_time)/60))

# download
gi.download_from_s3(s3_location)

{'fraction_non_alphanumeric': 0.09226023555804823, 'fraction_numerical': 0.0358945597307908, 'mean_word_length': 3.4643304130162704, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '883195', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1083, 'n_words': 276}