Skip to content

[BEAM-115] Runner API representation of windowing strategies for Python#2190

Closed
robertwb wants to merge 6 commits intoapache:masterfrom
robertwb:py-runner-api
Closed

[BEAM-115] Runner API representation of windowing strategies for Python#2190
robertwb wants to merge 6 commits intoapache:masterfrom
robertwb:py-runner-api

Conversation

@robertwb
Copy link
Contributor

@robertwb robertwb commented Mar 8, 2017

Be sure to do all of the following to help us incorporate your contribution
quickly and easily:

  • Make sure the PR title is formatted like:
    [BEAM-<Jira issue #>] Description of pull request
  • Make sure tests pass via mvn clean verify. (Even better, enable
    Travis-CI on your fork and ensure the whole test matrix passes).
  • Replace <Jira issue #> in the title with the actual Jira issue
    number, if there is one.
  • If this contribution is large, please file an Apache
    Individual Contributor License Agreement.

@robertwb
Copy link
Contributor Author

robertwb commented Mar 8, 2017

R: @vikkyrk

@asfbot
Copy link

asfbot commented Mar 8, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/8192/
--none--

@kennknowles
Copy link
Member

Is the plan to check in the generated code?


def _unique_ref(self):
self._counter += 1
return "ref_%s_%s" % (obj_type.__name__, self._counter)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obj_type is not available in this function, please use self._obj_type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I'm going to add tests for this.


def to_runner_api(self):
context_proto = beam_runner_api_pb2.Components()
for name, cls in self.__COMPONENT_TYEPS:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in self.__COMPONENT_TYEPS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing my comments!
There is still a typo here: *TYEPS vs. *TYPES

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. Fixed. I'll add some tests to make sure this actually works an push again. (Oh, for a statically typechecked Python...)

return self._is_default

def to_runner_api(self, context):
raise NotImplementedError
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably not intentional as you are returning a WindowingStrategy the exception is raised

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yes.

context_proto = beam_runner_api_pb2.Components()
for name, cls in self.__COMPONENT_TYEPS:
getattr(self, name).populate_map(getattr(context_proto, name))
return components
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like components is undefined at this point

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


@staticmethod
def from_runner_api(self, proto, context):
return Windowing(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windowing class has different named parameters: windowfn and triggerfn is used there (without underscore).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

def from_runner_api(self, proto, context):
return Windowing(
window_fn=WindowFn.from_runner_api(proto.window_fn),
trigger_fn=TriggerFn.from_runner_api(proto.trigger),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TriggerFn was not imported in this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there was a circular import. Fixed.

allowed_lateness=0)

@staticmethod
def from_runner_api(self, proto, context):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A staticmethod shall not need 'self' parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return beam_runner_api_pb2.Trigger(
after_each=beam_runner_api_pb2.Trigger.AfterEach(
subtriggers=[
subtrigger.to_runner_api(context) for subtrigger in triggers]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: please replace triggers by self.triggers

Copy link
Contributor Author

@robertwb robertwb Mar 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done and test added.

return beam_runner_api_pb2.Trigger(
or_finally=beam_runner_api_pb2.Trigger.OrFinally(
main=self.triggers[0].to_runner_api(context),
**{'finally': self.triggers[1].to_runner_api(context)}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's just me, but I needed some time to figure out what it does.
Wouldn't be simpler just passing finally=self.triggers[1].to_runner_api(context)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if only finally wasn't a keyword in Python, so I can't put it literally.

@robertwb
Copy link
Contributor Author

robertwb commented Mar 8, 2017

Thanks for taking a look, @tibkiss. I though I had added tests for Windowing, but clearly not.

@robertwb
Copy link
Contributor Author

robertwb commented Mar 8, 2017

@kennknowles As for checking in generated code, I poked around a bit, and asked around, and that's what we're currently doing for the other protos and apitools generated code. It'd be nice to avoid a protoc/mvn dependency for contributors, but I figured this was better than generating the json manually.

@asfbot
Copy link

asfbot commented Mar 8, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/8211/
--none--

@asfbot
Copy link

asfbot commented Mar 8, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/8212/
--none--

@robertwb robertwb force-pushed the py-runner-api branch 2 times, most recently from f077d5e to 36269d6 Compare March 8, 2017 18:57
@asfbot
Copy link

asfbot commented Mar 8, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/8216/
--none--

@asfbot
Copy link

asfbot commented Mar 8, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/8218/
--none--

@robertwb
Copy link
Contributor Author

robertwb commented Mar 8, 2017

R: @kennknowles

@kennknowles
Copy link
Member

@robertwb with regard to checking it in, I actually don't have much of an objection. It seems like a potentially annoying problem, and this unblocks other work. Perhaps we'll get to a point where it is autogenerated later, and it won't be hard to adjust other things.

I'll take a little bit to get to this review in more depth, though. I trust the LGTM of someone involved in the Python SDK more deeply.

SLIDING_WINDOWS_FN = "beam:window_fn:sliding_windows:v0.1"
SESSION_WINDOWS_FN = "beam:window_fn:session_windows:v0.1"

PICKLED_CODER = "dataflow:coder:pickled_python:v0.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/s/dataflow/beam

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

OUTPUT_AT_EOW = beam_runner_api_pb2.END_OF_WINDOW
OUTPUT_AT_EARLIEST = beam_runner_api_pb2.EARLIEST_IN_PANE
OUTPUT_AT_LATEST = beam_runner_api_pb2.LATEST_IN_PANE
OUTPUT_AT_EARLIEST_TRANSFORMED = 'OUTPUT_AT_EARLIEST_TRANSFORMED'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail when converting to_runner_api as it is not defined in the proto, maybe comment it out with a TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return pickler.loads(fn_parameter.value)

def to_runner_api_parameter(self, context):
raise TypeError(self)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

trigger=self.triggerfn.to_runner_api(context),
accumulation_mode=self.accumulation_mode,
output_time=self.output_time_fn,
closing_behavior=beam_runner_api_pb2.EMIT_ALWAYS,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a TODO to support EMIT_IF_NONEMPTY?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

visitor.visit_value(v, self)


class PipelineContextMap(object):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests for PipelineContextMap and PipelineContext would be great.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return self._id_to_obj[id]


class PipelineContext(object):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a user facing class or should it it be in runners module.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@asfbot
Copy link

asfbot commented Mar 9, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/8268/

Build result: FAILURE

[...truncated 1.96 MB...] at java.lang.Thread.run(Thread.java:745)Caused by: org.apache.maven.plugin.MojoExecutionException: Command execution failed. at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:302) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 31 moreCaused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404) at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166) at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:764) at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:711) at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:289) ... 33 more2017-03-09T18:10:22.481 [ERROR] 2017-03-09T18:10:22.481 [ERROR] Re-run Maven using the -X switch to enable full debug logging.2017-03-09T18:10:22.481 [ERROR] 2017-03-09T18:10:22.481 [ERROR] For more information about the errors and possible solutions, please read the following articles:2017-03-09T18:10:22.481 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException2017-03-09T18:10:22.481 [ERROR] 2017-03-09T18:10:22.481 [ERROR] After correcting the problems, you can resume the build with the command2017-03-09T18:10:22.481 [ERROR] mvn -rf :beam-sdks-pythonchannel stoppedSetting status of d2f6d5b to FAILURE with url https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/8268/ and message: 'Build finished. 'Using context: Jenkins: Maven clean install
--none--

@asfbot
Copy link

asfbot commented Mar 9, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/8272/

Build result: FAILURE

[...truncated 1.69 MB...] at java.lang.Thread.run(Thread.java:745)Caused by: org.apache.maven.plugin.MojoExecutionException: Command execution failed. at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:302) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 31 moreCaused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404) at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166) at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:764) at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:711) at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:289) ... 33 more2017-03-09T20:03:54.653 [ERROR] 2017-03-09T20:03:54.653 [ERROR] Re-run Maven using the -X switch to enable full debug logging.2017-03-09T20:03:54.653 [ERROR] 2017-03-09T20:03:54.653 [ERROR] For more information about the errors and possible solutions, please read the following articles:2017-03-09T20:03:54.653 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException2017-03-09T20:03:54.654 [ERROR] 2017-03-09T20:03:54.654 [ERROR] After correcting the problems, you can resume the build with the command2017-03-09T20:03:54.654 [ERROR] mvn -rf :beam-sdks-pythonchannel stoppedSetting status of 29cfcbe to FAILURE with url https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/8272/ and message: 'Build finished. 'Using context: Jenkins: Maven clean install
--none--

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 70.175% when pulling 8a0db87 on robertwb:py-runner-api into 29d9bd3 on apache:master.

@asfbot
Copy link

asfbot commented Mar 9, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/8278/
--none--

@vikkyrk
Copy link
Contributor

vikkyrk commented Mar 9, 2017

LGTM.

@asfbot
Copy link

asfbot commented Mar 10, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/8289/

Build result: FAILURE

[...truncated 1.96 MB...] at java.lang.Thread.run(Thread.java:745)Caused by: org.apache.maven.plugin.MojoExecutionException: Command execution failed. at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:302) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 31 moreCaused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404) at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166) at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:764) at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:711) at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:289) ... 33 more2017-03-10T00:36:53.061 [ERROR] 2017-03-10T00:36:53.061 [ERROR] Re-run Maven using the -X switch to enable full debug logging.2017-03-10T00:36:53.061 [ERROR] 2017-03-10T00:36:53.061 [ERROR] For more information about the errors and possible solutions, please read the following articles:2017-03-10T00:36:53.061 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException2017-03-10T00:36:53.062 [ERROR] 2017-03-10T00:36:53.062 [ERROR] After correcting the problems, you can resume the build with the command2017-03-10T00:36:53.062 [ERROR] mvn -rf :beam-sdks-pythonchannel stoppedSetting status of 3bc8d8d to FAILURE with url https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/8289/ and message: 'Build finished. 'Using context: Jenkins: Maven clean install
--none--

@asfbot
Copy link

asfbot commented Mar 10, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/8293/

Build result: FAILURE

[...truncated 1.96 MB...] at java.lang.Thread.run(Thread.java:745)Caused by: org.apache.maven.plugin.MojoExecutionException: Command execution failed. at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:302) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 31 moreCaused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404) at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166) at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:764) at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:711) at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:289) ... 33 more2017-03-10T01:50:03.593 [ERROR] 2017-03-10T01:50:03.593 [ERROR] Re-run Maven using the -X switch to enable full debug logging.2017-03-10T01:50:03.593 [ERROR] 2017-03-10T01:50:03.593 [ERROR] For more information about the errors and possible solutions, please read the following articles:2017-03-10T01:50:03.593 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException2017-03-10T01:50:03.593 [ERROR] 2017-03-10T01:50:03.594 [ERROR] After correcting the problems, you can resume the build with the command2017-03-10T01:50:03.594 [ERROR] mvn -rf :beam-sdks-pythonchannel stoppedSetting status of 0cc50dc to FAILURE with url https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/8293/ and message: 'Build finished. 'Using context: Jenkins: Maven clean install
--none--

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 86e1754 on robertwb:py-runner-api into ** on apache:master**.

@asfbot
Copy link

asfbot commented Mar 10, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/8294/
--none--

@asfgit asfgit closed this in 2c2424c Mar 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants