creates example data set
17259
def example():
    """"""
    J,v = multidict({1:16, 2:19, 3:23, 4:28})
    a = {(1,1):2,    (1,2):3,    (1,3):4,    (1,4):5,
         (2,1):3000, (2,2):3500, (2,3):5100, (2,4):7200,
         }
    I,b = multidict({1:7, 2:10000})
    return I,J,v,a,b
648249
def build_dataset(filename, max_lines=-1):
    """"""
    encodings = dict(list(map(reversed, enumerate(string.printable))))
    digitize = lambda char: encodings[char] if char in encodings else len(encodings)
    encode_line = lambda line: np.array(list(map(digitize, line)))
    nonblank_line = lambda line: len(line) > 2

    with open(filename) as f:
        lines = f.readlines()

    encoded_lines = list(map(encode_line, list(filter(nonblank_line, lines))[:max_lines]))
    num_outputs = len(encodings) + 1

    return encoded_lines, num_outputs
816804
def display_dataset(self):
        """"""
        header = self.dataset.header

        self.parent.setWindowTitle(basename(self.filename))
        short_filename = short_strings(basename(self.filename))
        self.idx_filename.setText(short_filename)
        self.idx_s_freq.setText(str(header['s_freq']))
        self.idx_n_chan.setText(str(len(header['chan_name'])))
        start_time = header['start_time'].strftime('%b-%d %H:%M:%S')
        self.idx_start_time.setText(start_time)
        end_time = (header['start_time'] +
                    timedelta(seconds=header['n_samples'] / header['s_freq']))
        self.idx_end_time.setText(end_time.strftime('%b-%d %H:%M:%S'))
528505
private void constructExample() {
		add(new WHeading(HeadingLevel.H2, "Examples showing TabSet Type property."));
		add(new WHeading(HeadingLevel.H3, "Tabs at the top"));
		WTabSet tabset0 = new SampleWTabset();
		add(tabset0);

		add(new WHeading(HeadingLevel.H3, "Tabs at the top with explicit TYPE"));
		/* Explicitly setting TYPE_TOP is superfluous */
		WTabSet tabset1 = new SampleWTabset(WTabSet.TYPE_TOP);
		add(tabset1);

		add(new WHeading(HeadingLevel.H3, "Tabs on the LEFT"));
		WTabSet tabset1a = new SampleWTabset(WTabSet.TYPE_LEFT);
		add(tabset1a);

		add(new WHeading(HeadingLevel.H3, "Tabs on the RIGHT"));
		WTabSet tabset1b = new SampleWTabset(WTabSet.TYPE_RIGHT);
		add(tabset1b);

		add(new WHeading(HeadingLevel.H3, "ACCORDION tabs"));
		WTabSet tabset1c = new SampleWTabset(TabSetType.ACCORDION);
		add(tabset1c);

		add(new WHorizontalRule());

		/* Content height */
		add(new WHeading(HeadingLevel.H2, "Examples showing content height property."));
		add(new WHeading(HeadingLevel.H3, "Tall content."));
		WTabSet htabset1 = new SampleWTabset();
		htabset1.setContentHeight(TALL_CONTENT);
		add(htabset1);

		WTabSet htabset1a = new SampleWTabset(WTabSet.TYPE_LEFT);
		htabset1a.setContentHeight(TALL_CONTENT);
		add(htabset1a);

		WTabSet htabset1b = new SampleWTabset(WTabSet.TYPE_RIGHT);
		htabset1b.setContentHeight(TALL_CONTENT);
		add(htabset1b);

		WTabSet htabset1c = new SampleWTabset(TabSetType.ACCORDION);
		htabset1c.setContentHeight(TALL_CONTENT);
		add(htabset1c);

		add(new WHeading(HeadingLevel.H3, "Short content."));
		WTabSet htabset1d = new SampleWTabset();
		htabset1d.setContentHeight(SHORT_CONTENT);
		add(htabset1d);

		WTabSet htabset1e = new SampleWTabset(WTabSet.TYPE_LEFT);
		htabset1e.setContentHeight(SHORT_CONTENT);
		add(htabset1e);

		WTabSet htabset1f = new SampleWTabset(WTabSet.TYPE_RIGHT);
		htabset1f.setContentHeight(SHORT_CONTENT);
		add(htabset1f);

		WTabSet htabset1g = new SampleWTabset(TabSetType.ACCORDION);
		htabset1g.setContentHeight(SHORT_CONTENT);
		add(htabset1g);

		add(new WHorizontalRule());
		add(new WHeading(HeadingLevel.H2, "Examples showing disabled property."));

		/* NOTE: WTabSet does not currently implement SubordinateTarget therefore one cannot create a subordinate
		 * control to disable/enable a WTabSet.
		 */
		WTabSet disabledTabset = new SampleWTabset();
		disabledTabset.setDisabled(true);
		add(disabledTabset);


		add(new WHeading(HeadingLevel.H2, "Examples showing accordion's single property."));
		WTabSet singleOpenAccordionabset = new SampleWTabset(WTabSet.TYPE_ACCORDION);
		singleOpenAccordionabset.setSingle(true);
		add(singleOpenAccordionabset);

		add(new WHorizontalRule());

		/* NOTE: no example of the hidden property because WTabSet is not a subordinate target. This is inconsistent
		 * with the schema. */
		add(new WHeading(HeadingLevel.H2, "Setting the initially active tab"));
		add(new WHeading(HeadingLevel.H3,
				"Server side with tabs on the left, with second tab initially active."));
		WTabSet tabset3 = new WTabSet(WTabSet.TYPE_LEFT);
		tabset3.setContentHeight("10em");
		tabset3.addTab(new WText("Some content should go in here."), "First tab",
				WTabSet.TAB_MODE_SERVER, 'i');

		WPanel largeContent2 = new WPanel();
		largeContent2.setLayout(new FlowLayout(Alignment.VERTICAL));
		largeContent2.add(new WText(LONG_TEXT));
		largeContent2.add(new WText(LONG_TEXT));
		largeContent2.add(new WText(LONG_TEXT));
		tabset3.addTab(largeContent2, "Second tab which is much longer", WTabSet.TAB_MODE_SERVER,
				'e');

		WImage image = new WImage("/image/success.png", "success");
		image.setCacheKey("eg-image-tab");
		WDecoratedLabel tabLabel = new WDecoratedLabel(image, new WText("Third tab"), null);

		tabset3.addTab(new WText("The tab button for this tab has an image!"), tabLabel,
				WTabSet.TAB_MODE_SERVER, 'h');

		// Set 2nd tab active
		tabset3.setActiveIndex(1);
		add(tabset3);

		add(new WHeading(HeadingLevel.H3,
				"Client side with tabs on the right and the third tab initially active."));
		WText thirdContent = new WText("Some more content should go into here.");
		WTabSet tabset4 = new WTabSet(WTabSet.TYPE_RIGHT);
		tabset4.setContentHeight("10em");
		tabset4.addTab(new WText("Some content should go into here."), "First tab",
				WTabSet.TAB_MODE_CLIENT);
		tabset4.addTab(new WText(LONG_TEXT), "Second tab which is longer", WTabSet.TAB_MODE_CLIENT);
		tabset4.addTab(thirdContent, "Third tab", WTabSet.TAB_MODE_CLIENT);

		// Set 3rd tab active
		tabset4.setActiveTab(thirdContent);
		add(tabset4);

		add(new WHeading(HeadingLevel.H3, "Client side with showing lots of tabs."));
		add(new ExplanatoryText(
				"This will effectively show what happens when tabs need to wrap. You should do everything possible to avoid this situation."));
		WTabSet tabset5 = new WTabSet();
		tabset5.addTab(new WText("Tab 1."), "First tab", WTabSet.TAB_MODE_CLIENT);
		tabset5.addTab(new WText("Tab 2."), "Second tab", WTabSet.TAB_MODE_CLIENT);
		tabset5.addTab(new WText("Tab 3."), "Third tab", WTabSet.TAB_MODE_CLIENT);
		tabset5.addTab(new WText("Tab 4."), "Fourth tab", WTabSet.TAB_MODE_CLIENT);
		tabset5.addTab(new WText("Tab 5."), "Fifth tab", WTabSet.TAB_MODE_CLIENT);
		tabset5.addTab(new WText("Tab 6."), "Sixth tab", WTabSet.TAB_MODE_CLIENT);
		tabset5.addTab(new WText("Tab 7."), "Seventh tab", WTabSet.TAB_MODE_CLIENT);
		tabset5.addTab(new WText("Tab 8."), "Eighth tab", WTabSet.TAB_MODE_CLIENT);
		tabset5.addTab(new WText("Tab 9."), "Nineth tab", WTabSet.TAB_MODE_CLIENT);
		tabset5.addTab(new WText("Tab 10."), "Tenth tab", WTabSet.TAB_MODE_CLIENT);
		tabset5.addTab(new WText("Tab 11."), "Eleventh tab", WTabSet.TAB_MODE_CLIENT);
		tabset5.addTab(new WText("Tab 12."), "Twelfth tab", WTabSet.TAB_MODE_CLIENT);
		tabset5.addTab(new WText("Tab 13."), "Thirteenth tab", WTabSet.TAB_MODE_CLIENT);
		tabset5.addTab(new WText("Tab 14."), "Fourteenth tab", WTabSet.TAB_MODE_CLIENT);
		tabset5.addTab(new WText("Tab 15."), "Fifteenth tab", WTabSet.TAB_MODE_CLIENT);
		add(tabset5);

		add(new WHorizontalRule());

		add(new WHeading(HeadingLevel.H2, "Using WSubordinateControl"));
		WTabSet targetTabset = new SampleWTabset();
		add(targetTabset);

		WFieldLayout layout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
		add(layout);
		final WCheckBox disabledControllerCb = new WCheckBox();
		final WCheckBox hiddenControllerCb = new WCheckBox();
		layout.addField("disable tabset", disabledControllerCb);
		layout.addField("hide tabset", hiddenControllerCb);


		// Build & add the subordinate
		SubordinateBuilder builder = new SubordinateBuilder();
		builder.condition().equals(hiddenControllerCb, String.valueOf(true));
		builder.whenTrue().hide(targetTabset);
		builder.whenFalse().show(targetTabset);
		add(builder.build());

		builder = new SubordinateBuilder();
		builder.condition().equals(disabledControllerCb, String.valueOf(true));
		builder.whenTrue().disable(targetTabset);
		builder.whenFalse().enable(targetTabset);
		add(builder.build());

	}
882990
def _create_examples(self, lines, set_type):
        """"""
        examples = []
        for (i, line) in enumerate(lines):
            if i == 0:
                continue
            guid = "%s-%s" % (set_type, i)
            text_a = line[3]
            text_b = line[4]
            label = line[0]
            examples.append(
                InputExample(guid=guid, text_a=text_a, text_b=text_b, label=label))
        return examples
326999
def generate_data(self, data_dir, tmp_dir, task_id=-1):
    """"""
    filepath_fns = {
        problem.DatasetSplit.TRAIN: self.training_filepaths,
        problem.DatasetSplit.EVAL: self.dev_filepaths,
        problem.DatasetSplit.TEST: self.test_filepaths,
    }

    # We set shuffled=True as we don't want to shuffle on disk later.
    split_paths = [(split["split"], filepath_fns[split["split"]](
        data_dir, split["shards"], shuffled=True))
                   for split in self.dataset_splits]
    all_paths = []
    for _, paths in split_paths:
      all_paths.extend(paths)

    if self.is_generate_per_split:
      for split, paths in split_paths:
        generator_utils.generate_files(
            self.generate_encoded_samples(data_dir, tmp_dir, split),
            paths,
            cycle_every_n=self.total_number_of_frames // len(paths))
    else:
      generator_utils.generate_files(
          self.generate_encoded_samples(data_dir, tmp_dir,
                                        problem.DatasetSplit.TRAIN),
          all_paths,
          cycle_every_n=self.total_number_of_frames // len(all_paths))
657498
def generate_matching_datasets(self, data_slug):
        """"""
        tag = Tag.objects.filter(slug=data_slug)
        try:
            return tag[0].dataset_set.all().order_by('-uploaded_by')
        except IndexError:
            return None
936300
def fill_with_sample_data(self):
        """"""
        # replace these sample data with another dataset later
        # this function is deprecated as soon as a common file format for this
        # type of data will be available
        self.p01 = np.array([[0.576724636119866,  0.238722774405744,  0.166532122130638,  0.393474644666218],
                             [0.303345245644811,  0.0490956843857575, 0.0392403031072856, 0.228441890034704]])

        self.p10 = np.array([[0.158217002255554,  0.256581140990052,  0.557852226779526,  0.422638238585814],
                             [0.0439831163244427, 0.0474928027621488, 0.303675296728195,  0.217512052135178]])

        self.pxx = np.array([[0.265058361624580,  0.504696084604205,  0.275615651089836,  0.183887116747968],
                             [0.652671638030746,  0.903411512852094,  0.657084400164519,  0.554046057830118]])

        self.wxx = np.array([[[0.188389148850583, 0.0806836453984190, 0.0698113025807722, 0.0621499191745602],
                              [0.240993281622128, 0.0831019646519721, 0.0415130545715575, 0.155284541403192]],
                             [[0.190128959522795, 0.129220679033862,  0.0932213021787505, 0.193080698516532],
                              [0.196379692358065, 0.108549414860949,  0.0592714297292217, 0.0421945385836429]],
                             [[0.163043672107111, 0.152063537378127,  0.102823783410167,  0.0906028835221283],
                              [0.186579466868095, 0.189705690316132,  0.0990207345993082, 0.107831389238912]],
                             [[0.197765724699431, 0.220046257566978,  0.177876233348082,  0.261288786454262],
                              [0.123823472714948, 0.220514673922285,  0.102486496386323,  0.101975538893918]],
                             [[0.114435243444815, 0.170857634762767,  0.177327072603662,  0.135362730582518],
                              [0.0939211776723413,0.174291820501902,  0.125275822078525,  0.150842841725936]],
                             [[0.0988683809545079, 0.152323481100248, 0.185606883566286, 0.167242856061538],
                              [0.0760275616817939, 0.127275603247149,  0.202466168603738,  0.186580243138018]],
                             [[0.0473688704207573, 0.0948047647595988, 0.193333422312280,  0.0902721256884624],
                              [0.0822753470826286, 0.0965608324996108, 0.369966294031327,  0.255290907016382]]])
880159
def _generate_examples(self, archive):
    """"""
    prefix_len = len("SUN397")
    with tf.Graph().as_default():
      with utils.nogpu_session() as sess:
        for filepath, fobj in archive:
          if (filepath.endswith(".jpg") and
              filepath not in _SUN397_IGNORE_IMAGES):
            # Note: all files in the tar.gz are in SUN397/...
            filename = filepath[prefix_len:]
            # Example:
            # From filename: /c/car_interior/backseat/sun_aenygxwhhmjtisnf.jpg
            # To class: /c/car_interior/backseat
            label = "/".join(filename.split("/")[:-1])
            image = _process_image_file(fobj, sess, filepath)
            yield {
                "file_name": filename,
                "image": image,
                "label": label,
            }
1086042
public static void main(String[] args) {
    SparkSession spark = SparkSession
      .builder()
      .appName("Java Spark SQL user-defined Datasets aggregation example")
      .getOrCreate();

    // $example on:typed_custom_aggregation$
    Encoder<Employee> employeeEncoder = Encoders.bean(Employee.class);
    String path = "examples/src/main/resources/employees.json";
    Dataset<Employee> ds = spark.read().json(path).as(employeeEncoder);
    ds.show();
    // +-------+------+
    // |   name|salary|
    // +-------+------+
    // |Michael|  3000|
    // |   Andy|  4500|
    // | Justin|  3500|
    // |  Berta|  4000|
    // +-------+------+

    MyAverage myAverage = new MyAverage();
    // Convert the function to a `TypedColumn` and give it a name
    TypedColumn<Employee, Double> averageSalary = myAverage.toColumn().name("average_salary");
    Dataset<Double> result = ds.select(averageSalary);
    result.show();
    // +--------------+
    // |average_salary|
    // +--------------+
    // |        3750.0|
    // +--------------+
    // 
    spark.stop();
  }
1312170
def dataset(self):
        """"""
        # Create a new Tablib Dataset.
        data = tablib.Dataset()

        # If the RecordCollection is empty, just return the empty set
        # Check number of rows by typecasting to list
        if len(list(self)) == 0:
            return data

        # Set the column names as headers on Tablib Dataset.
        first = self[0]

        data.headers = first.keys()
        for row in self.all():
            row = _reduce_datetimes(row.values())
            data.append(row)

        return data
67058
def generate_dataset(number_items=1000):
    
    data = []
    names = get_names()
    totalnames = len(names)
    #init random seeder
    random.seed()
    #calculate items
#    names = random.sample(names, number_items)
    for i in range(number_items):
        data.append({"name":names[random.randint(0,totalnames-1)],
                     "age":random.randint(1,100),
                     "description":li_words(50, False)})
    return data
799991
def _dataset_line(args):
  
  if args['command'] == 'list':
    filter_ = args['filter'] if args['filter'] else '*'
    context = google.datalab.Context.default()
    if args['project']:
      context = google.datalab.Context(args['project'], context.credentials)
    return _render_list([str(dataset) for dataset in bigquery.Datasets(context)
                         if fnmatch.fnmatch(str(dataset), filter_)])

  elif args['command'] == 'create':
    try:
      bigquery.Dataset(args['name']).create(friendly_name=args['friendly'])
    except Exception as e:
      print('Failed to create dataset %s: %s' % (args['name'], e))

  elif args['command'] == 'delete':
    try:
      bigquery.Dataset(args['name']).delete()
    except Exception as e:
      print('Failed to delete dataset %s: %s' % (args['name'], e))
162352
def create_preprocessed_dataset(path_to_data, outputpath, preprocessing_queue):
    """"""
    # Log everything
    logging.info("Data soure %s", path_to_data)
    logging.info("Output will be stored in %s", outputpath)
    tmp = "Preprocessing Queue:\n"
    for preprocessing_class in preprocessing_queue:
        tmp += str(preprocessing_class) + "\n"
    logging.info(tmp)
    # Load from pickled file
    if not os.path.isfile(path_to_data):
        logging.info(("'%s' does not exist. Please either abort this script "
                      "or update the data location."), path_to_data)
        raw_dataset_path = utils.choose_raw_dataset()
        # Get project-relative path
        raw_dataset_path = "raw-datasets" + \
                           raw_dataset_path.split("raw-datasets")[1]
        print(raw_dataset_path)
        sys.exit()  # TODO: Update model!
    logging.info("Start loading data...")
    loaded = pickle.load(open(path_to_data, "rb"))
    raw_datasets = loaded['handwriting_datasets']
    logging.info("Start applying preprocessing methods")
    start_time = time.time()
    for i, raw_dataset in enumerate(raw_datasets):
        if i % 10 == 0 and i > 0:
            utils.print_status(len(raw_datasets), i, start_time)
        # Do the work
        raw_dataset['handwriting'].preprocessing(preprocessing_queue)
    sys.stdout.write("\r%0.2f%% (done)\033[K\n" % (100))
    print("")
    pickle.dump({'handwriting_datasets': raw_datasets,
                 'formula_id2latex': loaded['formula_id2latex'],
                 'preprocessing_queue': preprocessing_queue},
                open(outputpath, "wb"),
                2)
1107476
def create(cls, train_ds, valid_ds, test_ds=None, path:PathOrStr='.', no_check:bool=False, bs=64, val_bs:int=None,
               num_workers:int=0, device:torch.device=None, collate_fn:Callable=data_collate,
               dl_tfms:Optional[Collection[Callable]]=None, bptt:int=70, backwards:bool=False, **dl_kwargs) -> DataBunch:
        ""
        datasets = cls._init_ds(train_ds, valid_ds, test_ds)
        val_bs = ifnone(val_bs, bs)
        datasets = [LanguageModelPreLoader(ds, shuffle=(i==0), bs=(bs if i==0 else val_bs), bptt=bptt, backwards=backwards)
                    for i,ds in enumerate(datasets)]
        val_bs = bs
        dls = [DataLoader(d, b, shuffle=False, **dl_kwargs) for d,b in zip(datasets, (bs,val_bs,val_bs,val_bs)) if d is not None]
        return cls(*dls, path=path, device=device, dl_tfms=dl_tfms, collate_fn=collate_fn, no_check=no_check)
203023
def create(self):
        """"""
        b0 = QGroupBox('Dataset')
        form = QFormLayout()
        b0.setLayout(form)

        open_rec = QPushButton('Open Dataset...')
        open_rec.clicked.connect(self.open_dataset)
        open_rec.setToolTip('Click here to open a new recording')
        self.idx_filename = open_rec
        self.idx_s_freq = QLabel('')
        self.idx_n_chan = QLabel('')
        self.idx_start_time = QLabel('')
        self.idx_end_time = QLabel('')

        form.addRow('Filename:', self.idx_filename)
        form.addRow('Sampl. Freq:', self.idx_s_freq)
        form.addRow('N. Channels:', self.idx_n_chan)
        form.addRow('Start Time: ', self.idx_start_time)
        form.addRow('End Time: ', self.idx_end_time)

        b1 = QGroupBox('View')
        form = QFormLayout()
        b1.setLayout(form)

        self.idx_start = QLabel('')
        self.idx_start.setToolTip('Start time in seconds from the beginning of'
                                  ' the recordings')
        self.idx_length = QLabel('')
        self.idx_length.setToolTip('Duration of the time window in seconds')
        self.idx_scaling = QLabel('')
        self.idx_scaling.setToolTip('Global scaling for all the channels')
        self.idx_distance = QLabel('')
        self.idx_distance.setToolTip('Visual distances between the traces of '
                                     'individual channels')

        form.addRow('Start Time:', self.idx_start)
        form.addRow('Length:', self.idx_length)
        form.addRow('Scaling:', self.idx_scaling)
        form.addRow('Distance:', self.idx_distance)

        layout = QVBoxLayout()
        layout.addWidget(b0)
        layout.addWidget(b1)

        self.setLayout(layout)
825174
def prepare_new_dataset():
    

    parser = argparse.ArgumentParser(
        description=(
            "Python client to Prepare a dataset"))
    parser.add_argument(
        "-u",
        help="username",
        required=False,
        dest="user")
    parser.add_argument(
        "-p",
        help="user password",
        required=False,
        dest="password")
    parser.add_argument(
        "-e",
        help="user email",
        required=False,
        dest="email")
    parser.add_argument(
        "-a",
        help="url endpoint with default http://localhost:8010",
        required=False,
        dest="url")
    parser.add_argument(
        "-f",
        help="file to use default ./examples/test-keras-dnn.json",
        required=False,
        dest="prepare_file")
    parser.add_argument(
        "-b",
        help=(
            "optional - path to CA bundle directory for "
            "client encryption over HTTP"),
        required=False,
        dest="ca_dir")
    parser.add_argument(
        "-c",
        help=(
            "optional - path to x509 certificate for "
            "client encryption over HTTP"),
        required=False,
        dest="cert_file")
    parser.add_argument(
        "-k",
        help=(
            "optional - path to x509 key file for "
            "client encryption over HTTP"),
        required=False,
        dest="key_file")
    parser.add_argument(
        "-s",
        help="silent",
        required=False,
        dest="silent",
        action="store_true")
    parser.add_argument(
        "-d",
        help="debug",
        required=False,
        dest="debug",
        action="store_true")
    args = parser.parse_args()

    user = ev(
        "API_USER",
        "user-not-set")
    password = ev(
        "API_PASSWORD",
        "password-not-set")
    email = ev(
        "API_EMAIL",
        "email-not-set")
    url = ev(
        "API_URL",
        "http://localhost:8010")
    prepare_file = ev(
        "DATAFILE",
        "prepare_file-not-set")
    ca_dir = os.getenv(
        "API_CA_BUNDLE_DIR",
        None)
    cert_file = os.getenv(
        "API_CERT_FILE",
        None)
    key_file = os.getenv(
        "API_KEY_FILE",
        None)
    verbose = bool(str(ev(
        "API_VERBOSE",
        "true")).lower() == "true")
    debug = bool(str(ev(
        "API_DEBUG",
        "false")).lower() == "true")

    if args.user:
        user = args.user
    if args.password:
        password = args.password
    if args.email:
        email = args.email
    if args.url:
        url = args.url
    if args.prepare_file:
        prepare_file = args.prepare_file
    if args.ca_dir:
        ca_dir = args.ca_dir
    if args.cert_file:
        cert_file = args.cert_file
    if args.key_file:
        key_file = args.key_file
    if args.silent:
        verbose = False
    if args.debug:
        debug = True

    usage = (
        "Please run with "
        "-u <username> "
        "-p <password> "
        "-a <AntiNex URL http://localhost:8010> "
        "-f <path to prepare file> "
        "-b <optional - path to CA bundle directory> "
        "-c <optional - path to x509 ssl certificate file> "
        "-k <optional - path to x509 ssl key file>")

    valid = True
    if not user or user == "user-not-set":
        log.error("missing user")
        valid = False
    if not password or password == "password-not-set":
        log.error("missing password")
        valid = False
    if not prepare_file or prepare_file == "prepare_file-not-set":
        log.error("missing prepare_file")
        valid = False
    else:
        if not os.path.exists(prepare_file):
            log.error(("did not find prepare_file={} on disk")
                      .format(
                        prepare_file))
            valid = False
    if not valid:
        log.error(usage)
        sys.exit(1)

    if verbose:
        log.info(("creating client user={} url={} file={}")
                 .format(
                    user,
                    url,
                    prepare_file))

    client = AIClient(
        user=user,
        email=email,
        password=password,
        url=url,
        ca_dir=ca_dir,
        cert_file=cert_file,
        key_file=key_file,
        verbose=verbose,
        debug=debug)

    if verbose:
        log.info(("loading request in prepare_file={}")
                 .format(
                    prepare_file))

    req_body = None
    with open(prepare_file, "r") as f:
        req_body = json.loads(f.read())

    if verbose:
        log.info("running prepare")

    prepare_was_started = False
    response = client.run_prepare(
        body=req_body)

    if response["status"] == SUCCESS:
        log.info(("prepare started with response={}")
                 .format(
                    response["data"]))
        prepare_was_started = True
    elif response["status"] == FAILED:
        log.error(("prepare failed with error='{}' with response={}")
                  .format(
                    response["error"],
                    response["data"]))
    elif response["status"] == ERROR:
        log.error(("prepare had an error='{}' with response={}")
                  .format(
                    response["error"],
                    response["data"]))
    elif response["status"] == LOGIN_FAILED:
        log.error(("prepare reported user was not able to log in "
                   "with an error='{}' with response={}")
                  .format(
                    response["error"],
                    response["data"]))

    if not prepare_was_started:
        sys.exit(1)

    if debug:
        log.info(("parsing response data={}")
                 .format(
                    response["data"]))
    else:
        if verbose:
            log.info("parsing data")

    prepare_data = response["data"]

    if not prepare_data:
        log.error(("missing prepare dictionary in response data={}")
                  .format(
                    response["data"]))
        sys.exit(1)

    prepare_id = prepare_data.get("id", None)
    prepare_status = prepare_data.get("status", None)

    log.info(("started prepare.id={} prepare.status={}")
             .format(
                prepare_id,
                prepare_status))

    prepare_results = client.wait_for_prepare_to_finish(
        prepare_id=prepare_id)

    if prepare_results["status"] != SUCCESS:
        log.error(("failed waiting for prepare.id={} to finish "
                   "error={} data={}")
                  .format(
                    prepare_id,
                    prepare_results["error"],
                    prepare_results["data"]))
        sys.exit(1)

    final_prepare = prepare_results["data"]

    log.info(("prepare={}")
             .format(
                ppj(final_prepare)))

    log.info(("prepare.id={} is done")
             .format(
                prepare_id))