Example usage for java.util.zip DataFormatException DataFormatException

List of usage examples for java.util.zip DataFormatException DataFormatException

Introduction

In this page you can find the example usage for java.util.zip DataFormatException DataFormatException.

Prototype

public DataFormatException(String s) 

Source Link

Document

Constructs a DataFormatException with the specified detail message.

Usage

From source file:org.openml.apiconnector.io.OpenmlConnector.java

/**
 * Uploads a run/*w  ww .  j  a v  a2s  .  c o  m*/
 * 
 * @param description
 *            - An XML file describing the run. See documentation at
 *            openml.org.
 * @param output_files
 *            - A Map<String,File> containing all relevant output files. Key
 *            "predictions" usually contains the predictions that were
 *            generated by this run.
 * @return UploadRun - An object containing information on the
 *         implementation upload.
 * @throws Exception
 *             - Can be: API Error (see documentation at openml.org), server
 *             down, etc.
 */
public UploadRun runUpload(File description, Map<String, File> output_files) throws Exception {
    MultipartEntity params = new MultipartEntity();
    if (verboseLevel >= Constants.VERBOSE_LEVEL_ARFF) {
        System.out.println(Conversion.fileToString(output_files.get("predictions")) + "\n==========\n");
    }
    if (verboseLevel >= Constants.VERBOSE_LEVEL_XML) {
        System.out.println(Conversion.fileToString(description) + "\n==========");
    }
    params.addPart("description", new FileBody(description));
    for (String s : output_files.keySet()) {
        params.addPart(s, new FileBody(output_files.get(s)));
    }
    Object apiResult = HttpConnector.doApiRequest(OPENML_URL + API_PART + "run/", params, getApiKey(),
            verboseLevel);
    if (apiResult instanceof UploadRun) {
        return (UploadRun) apiResult;
    } else {
        throw new DataFormatException("Casting Api Object to UploadRun");
    }
}

From source file:org.openml.apiconnector.io.OpenmlConnector.java

/**
 * Returns a list with run results. Must be restricted with tasks, setups or both. 
 * // ww  w  .ja v  a2s. c  o  m
 * @param task_id - a list with task ids to include (null to not restrict on tasks)
 * @param setup_id - a list with setup ids to include (null to not restrict on setups)
 * @return
 * @throws Exception
 */
public RunList runList(List<Integer> task_id, List<Integer> setup_id, List<Integer> flow_id,
        List<Integer> uploader_id) throws Exception {
    String suffix = "";

    if (uploader_id != null) {
        suffix += "/uploader/" + StringUtils.join(uploader_id, ',');
    }
    if (flow_id != null) {
        suffix += "/flow/" + StringUtils.join(flow_id, ',');
    }
    if (task_id != null) {
        suffix += "/task/" + StringUtils.join(task_id, ',');
    }
    if (setup_id != null) {
        suffix += "/setup/" + StringUtils.join(setup_id, ',');
    }

    Object apiResult = HttpConnector.doApiRequest(OPENML_URL + API_PART + "run/list" + suffix, getApiKey(),
            verboseLevel);
    if (apiResult instanceof RunList) {
        return (RunList) apiResult;
    } else {
        throw new DataFormatException("Casting Api Object to RunList");
    }
}

From source file:org.openml.apiconnector.io.OpenmlConnector.java

/**
 * Returns a list with run results. Must be restricted with tasks, setups or both. 
 * // ww  w.ja va 2  s  .c  o m
 * @param task_id - a list with task ids to include (null to not restrict on tasks)
 * @param setup_id - a list with setup ids to include (null to not restrict on setups)
 * @param function - the evaluation measure interested in
 * @return
 * @throws Exception
 */
public EvaluationList evaluationList(List<Integer> task_id, List<Integer> setup_id, String function)
        throws Exception {
    String suffix = "";

    if (task_id != null) {
        suffix += "/task/" + StringUtils.join(task_id, ',');
    }
    if (setup_id != null) {
        suffix += "/setup/" + StringUtils.join(setup_id, ',');
    }
    if (function != null) {
        suffix += "/function/" + function;
    }

    Object apiResult = HttpConnector.doApiRequest(OPENML_URL + API_PART + "evaluation/list" + suffix,
            getApiKey(), verboseLevel);
    if (apiResult instanceof EvaluationList) {
        return (EvaluationList) apiResult;
    } else {
        throw new DataFormatException("Casting Api Object to EvaluationList");
    }
}

From source file:org.openml.apiconnector.io.OpenmlConnector.java

/**
 * Tags a run/*from www. j  a va 2s .c o  m*/
 * 
 * @param id - The run id
 * @param tag - The tag
 * @return
 * @throws Exception
 */
public RunTag runTag(int id, String tag) throws Exception {
    MultipartEntity params = new MultipartEntity();
    params.addPart("run_id", new StringBody("" + id));
    params.addPart("tag", new StringBody(tag));
    Object apiResult = HttpConnector.doApiRequest(OPENML_URL + API_PART + "run/tag", params, getApiKey(),
            verboseLevel);
    if (apiResult instanceof RunTag) {
        return (RunTag) apiResult;
    } else {
        throw new DataFormatException("Casting Api Object to RunTag");
    }
}

From source file:org.openml.apiconnector.io.OpenmlConnector.java

/**
 * Removes a tag from a run//from w  ww . java2 s  .  c om
 * 
 * @param id - the run id
 * @param tag - the tag to be removed
 * @return
 * @throws Exception
 */
public RunUntag runUntag(int id, String tag) throws Exception {
    MultipartEntity params = new MultipartEntity();
    params.addPart("run_id", new StringBody("" + id));
    params.addPart("tag", new StringBody(tag));
    Object apiResult = HttpConnector.doApiRequest(OPENML_URL + API_PART + "run/untag", params, getApiKey(),
            verboseLevel);
    if (apiResult instanceof RunUntag) {
        return (RunUntag) apiResult;
    } else {
        throw new DataFormatException("Casting Api Object to RunUntag");
    }
}

From source file:org.openml.apiconnector.io.OpenmlConnector.java

/**
 * Stores evaluation measures of a run (admin rights required, typically executed by evaluation engine)
 * //w w w  .java 2 s.co  m
 * @param description - description file (complying to xsd)
 * @return
 * @throws Exception
 */
public RunEvaluate runEvaluate(File description) throws Exception {
    MultipartEntity params = new MultipartEntity();
    params.addPart("description", new FileBody(description));

    Object apiResult = HttpConnector.doApiRequest(OPENML_URL + API_PART + "run/evaluate", params, getApiKey(),
            verboseLevel);
    if (apiResult instanceof RunEvaluate) {
        return (RunEvaluate) apiResult;
    } else {
        throw new DataFormatException("Casting Api Object to RunEvaluate");
    }
}

From source file:org.openml.apiconnector.io.OpenmlConnector.java

/**
 * Uploads trace results in the database, typically used when an internal parameter optimization loop was executed. (admin rights required, typically executed by evaluation engine)
 * /*  w  w w  .  j  a v a2 s  .  co  m*/
 * @param trace - the trace description xml
 * @return
 * @throws Exception
 */
public RunTraceUpload runTraceUpload(File trace) throws Exception {
    MultipartEntity params = new MultipartEntity();
    params.addPart("trace", new FileBody(trace));

    Object apiResult = HttpConnector.doApiRequest(OPENML_URL + API_PART + "run/trace", params, getApiKey(),
            verboseLevel);
    if (apiResult instanceof RunTraceUpload) {
        return (RunTraceUpload) apiResult;
    } else {
        throw new DataFormatException("Casting Api Object to RunTraceUpload");
    }
}

From source file:org.openml.apiconnector.io.OpenmlConnector.java

/**
 * Stores trace results in the database, typically used when an internal parameter optimization loop was executed. (admin rights required, typically executed by evaluation engine)
 * //  w w  w.  j  av  a  2  s.co m
 * @param trace - the trace description xml
 * @return
 * @throws Exception
 */
public RunTrace runTrace(int run_id) throws Exception {

    Object apiResult = HttpConnector.doApiRequest(OPENML_URL + API_PART + "run/trace/" + run_id, getApiKey(),
            verboseLevel);
    if (apiResult instanceof RunTrace) {
        return (RunTrace) apiResult;
    } else {
        throw new DataFormatException("Casting Api Object to RunTrace");
    }
}

From source file:org.openml.apiconnector.io.OpenmlConnector.java

/**
 * Downloads run information//w  w  w .jav a  2s  .c  o  m
 * 
 * @param runId - the run id
 * @return
 * @throws Exception
 */
public Run runGet(int runId) throws Exception {
    Object apiResult = HttpConnector.doApiRequest(OPENML_URL + API_PART + "run/" + runId, getApiKey(),
            verboseLevel);
    if (apiResult instanceof Run) {
        return (Run) apiResult;
    } else {
        throw new DataFormatException("Casting Api Object to Task");
    }
}

From source file:org.openml.apiconnector.io.OpenmlConnector.java

/**
 * Deletes a run and all it's important components
 * /*from w  ww  .  ja  v a 2 s . co m*/
 * @param id
 *            - The numeric id of the run to be deleted.
 * @return RunDelete - An object containing the id of the deleted run
 * @throws Exception
 *             - Can be: API Error (see documentation at openml.org), server
 *             down, etc.
 */
public RunDelete runDelete(int id) throws Exception {
    Object apiResult = HttpConnector.doApiDelete(OPENML_URL + API_PART + "run/" + id, getApiKey(),
            verboseLevel);
    if (apiResult instanceof RunDelete) {
        return (RunDelete) apiResult;
    } else {
        throw new DataFormatException("Casting Api Object to RunDelete");
    }
}