Example #1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--config', required=True)
    parser.add_argument('--span',
                        default=1.0,
                        type=float,
                        help='Parameter sweep range (should be even)')
    parser.add_argument('--delta',
                        default=0.1,
                        type=float,
                        help='Size of parameter sweep increments')
    parser.add_argument('--significant_digits',
                        default=1,
                        type=int,
                        help='Number of significant digits in beamx/beamy')
    args = parser.parse_args()

    significant_digits = args.significant_digits
    delta = args.delta
    span = args.span
    span_half = span / 2

    with open(args.config) as config_json:
        config = json.load(config_json)
        beamx = float(config['beamx'])
        beamy = float(config['beamy'])
        endpoint = config['endpoint']
        endpoint_local = config['endpoint_local']

    x_values = np.round(np.arange(beamx - span_half, beamx + span_half + delta,
                                  delta),
                        decimals=significant_digits)
    y_values = np.round(np.arange(beamy - span_half, beamy + span_half + delta,
                                  delta),
                        decimals=significant_digits)

    phil_data = list()
    phil_data2 = list()

    for x in x_values:
        for y in y_values:
            new_config = copy.deepcopy(config)
            new_config['beamx'] = x
            new_config['beamy'] = y
            new_config['suffix'] = get_random_str()
            phil_data.append(new_config)

    fxc = FuncXClient()
    fxc.throttling_enabled = False
    fxid_create_phil, fxid_stills_process, fxid_count_ints = get_function_ids(
        fxc)

    # Phil files
    print("Running funcx_create_phil")
    phil_batch = fxc.create_batch()
    for phil in phil_data:
        phil_batch.add(phil,
                       endpoint_id=endpoint_local,
                       function_id=fxid_create_phil)
    phil_job = fxc.batch_run(phil_batch)
    wait_batch(fxc, phil_job)

    # Stills process
    print("\nRunning funcx_stills_process")
    stills_batch = fxc.create_batch()
    for phil in phil_data:
        stills_batch.add(phil,
                         endpoint_id=endpoint,
                         function_id=fxid_stills_process)
    stills_job = fxc.batch_run(stills_batch)
    wait_batch(fxc, stills_job)

    # Count ints
    print("\nRunning funcx_count_ints")
    combined_df = pd.DataFrame()
    count_batch = fxc.create_batch()
    for phil in phil_data:
        count_batch.add(phil,
                        endpoint_id=endpoint,
                        function_id=fxid_count_ints)
    count_job = fxc.batch_run(count_batch)
    count_results = wait_batch(fxc, count_job)

    # Create CSV and heatmap
    for df in count_results:
        if combined_df.empty:
            combined_df = df[2]
        else:
            combined_df = pd.concat([combined_df, df[2]], axis=0)

    combined_df.sort_values(['X', 'Y'], ascending=[True, True], inplace=True)
    combined_df.to_csv("ints.csv", index=False)
    plot(combined_df)
Example #2
0
import xlwt
import time
import numpy as np
#from PIL import Image
start3 = time.time()
from funcx.sdk.client import FuncXClient

fxc = FuncXClient()
end3 = time.time()
exec_time3 = ((end3 - start3) * 1000)
print(exec_time3)
fxc.throttling_enabled = False
n = 2000
estimate = []


def matrix(ress):
    return ress


mat1 = ([1, 6, 5], [3, 4, 8], [2, 12, 3])
mat2 = ([3, 4, 6], [5, 6, 7], [6, 56, 7])
#overhead = []
start1 = time.time()
hello_function = fxc.register_function(matrix)
#ress = np.dot(mat1,mat2)
end1 = time.time()
registertime = ((end1 - start1) * 1000)
print("The register time is:", registertime)
index = 1
book = xlwt.Workbook()