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

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

                Author: ASF GitHub Bot
            Created on: 07/Feb/22 17:06
            Start Date: 07/Feb/22 17:06
    Worklog Time Spent: 10m 
      Work Description: daria-malkova commented on a change in pull request 
#16611:
URL: https://github.com/apache/beam/pull/16611#discussion_r800871562



##########
File path: playground/backend/internal/preparers/python_preparers.go
##########
@@ -112,3 +133,76 @@ func writeToFile(to *os.File, str string) error {
        }
        return nil
 }
+
+// saveGraph adds code to pipeline to save the pipeline's graph to the file 
GraphFileName
+func saveGraph(from *os.File, to *os.File) error {
+       newLine := false
+       reg := regexp.MustCompile(findPipelinePattern)
+       scanner := bufio.NewScanner(from)
+       pipelineName := ""
+       spaces := ""
+       err := errors.New("")
+
+       for scanner.Scan() {
+               line := scanner.Text()
+               if pipelineName == "" {
+                       // Try to find where the beam pipeline declaration is 
located
+                       err = writeLineToFile(findPipelineLine)(newLine, to, 
&line, &spaces, &pipelineName, &reg)
+               } else if reg != nil {
+                       // Try to find where beam pipeline definition is 
finished and add code to store the graph
+                       reg = 
regexp.MustCompile(fmt.Sprintf(indentationPattern, spaces))
+                       err = writeLineToFile(addCodeForGraph)(newLine, to, 
&line, &spaces, &pipelineName, &reg)
+               } else {
+                       err = writeLineToFile(func(line, spaces, pipelineName 
*string, reg **regexp.Regexp) {
+                               // No need to find or change anything, just 
write current line to file
+                       })(newLine, to, &line, &spaces, &pipelineName, nil)
+               }
+               if err != nil {
+                       logger.Errorf("Preparation: Error during write \"%s\" 
to tmp file, err: %s\n", line, err.Error())
+                       return err
+               }
+               newLine = true
+       }
+       return scanner.Err()
+}
+
+//findPipelineLine looking for a declaration of a beam pipeline and it's name
+func findPipelineLine(line, spaces, pipelineName *string, reg **regexp.Regexp) 
{

Review comment:
       Done




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

    Worklog Id:     (was: 722069)
    Time Spent: 2h  (was: 1h 50m)

> [Playground]Support graph on Python
> -----------------------------------
>
>                 Key: BEAM-13712
>                 URL: https://issues.apache.org/jira/browse/BEAM-13712
>             Project: Beam
>          Issue Type: Sub-task
>          Components: beam-playground
>            Reporter: Daria Malkova
>            Assignee: Daria Malkova
>            Priority: P3
>              Labels: beam-playground-backend, beam-playground-sprint-7
>          Time Spent: 2h
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to