flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-2021) Rework examples to use ParameterTool
Date Thu, 21 Jan 2016 12:33:39 GMT

    [ https://issues.apache.org/jira/browse/FLINK-2021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15110521#comment-15110521
] 

ASF GitHub Bot commented on FLINK-2021:
---------------------------------------

Github user chiwanpark commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1536#discussion_r50395062
  
    --- Diff: flink-examples/flink-examples-batch/src/main/scala/org/apache/flink/examples/scala/clustering/KMeans.scala
---
    @@ -104,36 +105,52 @@ object KMeans {
     
       }
     
    -  private def parseParameters(programArguments: Array[String]): Boolean = {
    -    if (programArguments.length > 0) {
    +  private val POINTS_PATH_OPTION: Option =
    +    new Option("points").alt("P").help("The path to the input points")
    +  private val CENTERS_PATH_OPTION: Option =
    +    new Option("centroids").alt("C").help("The path to the input centroids")
    +  private val OUTPUT_PATH_OPTION: Option =
    +    new Option("output").alt("O").help("The path where the output will be written")
    +  private val NUM_ITERATIONS_OPTION: Option =
    +    new Option("iterations").alt("I").help("The number of iteration performed by the
K-Means algorithm")
    +
    +  @throws(classOf[RequiredParametersException])
    --- End diff --
    
    This statement doesn't need also. We catch `RequiredParametersException` in `catch` statement.


> Rework examples to use ParameterTool
> ------------------------------------
>
>                 Key: FLINK-2021
>                 URL: https://issues.apache.org/jira/browse/FLINK-2021
>             Project: Flink
>          Issue Type: Improvement
>          Components: Examples
>    Affects Versions: 0.9
>            Reporter: Robert Metzger
>            Priority: Minor
>              Labels: starter
>
> In FLINK-1525, we introduced the {{ParameterTool}}.
> We should port the examples to use the tool.
> The examples could look like this (we should maybe discuss it first on the mailing lists):
> {code}
> public static void main(String[] args) throws Exception {
>     ParameterTool pt = ParameterTool.fromArgs(args);
>     boolean fileOutput = pt.getNumberOfParameters() == 2;
>     String textPath = null;
>     String outputPath = null;
>     if(fileOutput) {
>         textPath = pt.getRequired("input");
>         outputPath = pt.getRequired("output");
>     }
>     // set up the execution environment
>     final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
>     env.getConfig().setUserConfig(pt);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message