[ 
https://issues.apache.org/jira/browse/BEAM-8996?focusedWorklogId=361636&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-361636
 ]

ASF GitHub Bot logged work on BEAM-8996:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/Dec/19 12:39
            Start Date: 20/Dec/19 12:39
    Worklog Time Spent: 10m 
      Work Description: lgajowy commented on pull request #10424: [BEAM-8996] 
Auto-generate pipeline options documentation for FlinkRunner
URL: https://github.com/apache/beam/pull/10424#discussion_r360355857
 
 

 ##########
 File path: 
runners/flink/src/test/java/org/apache/beam/runners/flink/website/PipelineOptionsTableGenerator.java
 ##########
 @@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.flink.website;
+
+import edu.umd.cs.findbugs.annotations.Nullable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Optional;
+import org.apache.beam.runners.flink.FlinkPipelineOptions;
+import org.apache.beam.sdk.options.Default;
+import org.apache.beam.sdk.options.Description;
+import 
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.CaseFormat;
+import 
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList;
+
+/**
+ * A main class which is called by the Gradle generatePipelineOptionsTable* 
tasks to update the list
+ * of available pipeline options for the Beam website.
+ */
+public class PipelineOptionsTableGenerator {
+
+  private static final List<String> supportedLanguages = 
ImmutableList.of("java", "python");
+
+  private static class Option {
+    String name;
+    String description;
+    @Nullable String defaultValue;
+
+    public Option(String name, String description, @Nullable String 
defaultValue) {
+      this.name = name;
+      this.description = description;
+      this.defaultValue = defaultValue;
+    }
+  }
+
+  public static void main(String[] args) {
+    if (args.length != 1) {
+      throw new RuntimeException(
+          "Please specify the language (" + supportedLanguages + ") as the 
only argument.");
+    }
+    String arg = args[0].toLowerCase();
+    if (!supportedLanguages.contains(arg)) {
+      throw new RuntimeException("The language is not supported: " + arg);
+    }
+    boolean isPython = arg.equals("python");
+
+    printHeader();
+    List<Option> options = extractOptions(isPython);
+    printOptionsTable(options);
+  }
+
+  private static void printHeader() {
+    System.out.println(
+        "<!--\n"
+            + "Licensed under the Apache License, Version 2.0 (the 
\"License\");\n"
+            + "you may not use this file except in compliance with the 
License.\n"
+            + "You may obtain a copy of the License at\n"
+            + "\n"
+            + "http://www.apache.org/licenses/LICENSE-2.0\n";
+            + "\n"
+            + "Unless required by applicable law or agreed to in writing, 
software\n"
+            + "distributed under the License is distributed on an \"AS IS\" 
BASIS,\n"
+            + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
implied.\n"
+            + "See the License for the specific language governing permissions 
and\n"
+            + "limitations under the License.\n"
+            + "-->");
+    System.out.println(
+        "<!--\n"
+            + "This is an auto-generated file.\n"
+            + "Use generatePipelineOptionsTableJava and 
generatePipelineOptionsTablePython respectively\n"
+            + "which should be called before running the tests.\n"
+            + "-->");
+  }
+
+  /**
+   * Returns the extracted list of options via reflections on 
FlinkPipelineOptions. Options are
+   * returned sorted in alphabetical order since Java does not guarantee any 
consistent order on the
+   * class methods.
+   */
+  private static List<Option> extractOptions(boolean isPython) {
+    List<Option> options = new ArrayList<>();
+    for (Method method : FlinkPipelineOptions.class.getDeclaredMethods()) {
 
 Review comment:
   My take on that is that streams let you separate the consequent steps easily 
and organize the code well. I don't think the speed of execution is important 
here. How big the class should be to feel the performance impact? 
   
   Regarding the quantity of the methods - I don't know why is this a problem. 
I have to disagree one more time. If a method name explains what is done and 
the method does one thing only then readability increases. IMO, since 
developers most of the time spent working read the code rather than write it, 
it's worth investing time and effort to organize the code well. Notice that you 
wouldn't have to look inside the private methods to see what the public one 
does when you read the code  (thanks to good naming) so reading and getting to 
know it is faster.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 361636)
    Time Spent: 2h 40m  (was: 2.5h)

> Auto-generate pipeline options documentation for FlinkRunner
> ------------------------------------------------------------
>
>                 Key: BEAM-8996
>                 URL: https://issues.apache.org/jira/browse/BEAM-8996
>             Project: Beam
>          Issue Type: Improvement
>          Components: runner-flink
>            Reporter: Maximilian Michels
>            Assignee: Maximilian Michels
>            Priority: Major
>             Fix For: 2.19.0
>
>          Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> The documentation on the pipeline options on the [runner 
> page|https://beam.apache.org/documentation/runners/flink/] easily becomes 
> outdated. In order for them to stay up to date, we should auto-generate the 
> documentation from the {{FlinkPipelineOptions}} class. This should be done 
> for both Java and Python.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to