# Path: dapbench/jython/util.py
# def generate_subset_requests(variable, partition_dict):
#     """
#     Yields callables which when called makes a subset request
#     to <variable> according to the partitions specified.
# 
#     Made threadsafe with a lock.
# 
#     """
# 
#     def gen():
#         for subset in partition_variable(variable, partition_dict):
#             yield DapVarSubset(variable, subset)
#     
#     return LockedIterator(gen())
# 
# Path: dapbench/jython/netcdf.py
# class Dataset(object):
#     def __init__(self, location):
#         self._ds = NetcdfDataset.openDataset(location)
#         self.variables = VariableDict(self._ds)
#         self.attributes = AttributeDict(self._ds)


import random
import data_urls
from net.grinder.script import Test
from net.grinder.script.Grinder import grinder
from dapbench.jython.util import generate_subset_requests
from dapbench.jython.netcdf import Dataset
"""
Ramp-up the number of slices to split the request into on each run.

This script uses a single 5GB file rather than selecting a random file
from a pool of 600MB files.

"""





partitions = [60, 120, 240, 480, 720, 1440]

server = 'pydap'
variable = 'ta'

dataset_url = '%s/%s' % (data_urls.DAP_BASES[server], 'ta_all.nc')

ds = Dataset(dataset_url)
variable = ds.variables[variable]


class Instrumented(object):
    next_test = 1
    def __init__(self, partition):
        self.test = Test(Instrumented.next_test, 
                         'Partition into %d slices' % partition)
        Instrumented.next_test += 1


# Path: dapbench/jython/util.py
# def generate_subset_requests(variable, partition_dict):
#     """
#     Yields callables which when called makes a subset request
#     to <variable> according to the partitions specified.
# 
#     Made threadsafe with a lock.
# 
#     """
# 
#     def gen():
#         for subset in partition_variable(variable, partition_dict):
#             yield DapVarSubset(variable, subset)
#     
#     return LockedIterator(gen())
# 
# Path: dapbench/jython/netcdf.py
# class Dataset(object):
#     def __init__(self, location):
#         self._ds = NetcdfDataset.openDataset(location)
#         self.variables = VariableDict(self._ds)
#         self.attributes = AttributeDict(self._ds)


# Path: grinder/bigfile_ramp.py
import random
import data_urls
from net.grinder.script import Test
from net.grinder.script.Grinder import grinder
from dapbench.jython.util import generate_subset_requests
from dapbench.jython.netcdf import Dataset

"""
Ramp-up the number of slices to split the request into on each run.

This script uses a single 5GB file rather than selecting a random file
from a pool of 600MB files.

"""





partitions = [60, 120, 240, 480, 720, 1440]

server = 'pydap'
variable = 'ta'

dataset_url = '%s/%s' % (data_urls.DAP_BASES[server], 'ta_all.nc')

ds = Dataset(dataset_url)
variable = ds.variables[variable]


class Instrumented(object):
    next_test = 1
    def __init__(self, partition):
        self.test = Test(Instrumented.next_test, 
                         'Partition into %d slices' % partition)
        Instrumented.next_test += 1


        self.requests = generate_subset_requests(variable, {'time': partition})