-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Create singleton view for pipeline options during pipeline construction. #37474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| { | ||
| "comment": "Modify this file in a trivial way to cause this test suite to run", | ||
| "revision": 2 | ||
| "revision": 3 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # | ||
| # 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. | ||
| # | ||
|
|
||
| """Singleton providing access to pipeline options during graph construction. | ||
|
|
||
| This module provides a lightweight singleton that holds the full | ||
| PipelineOptions set during Pipeline.__init__. | ||
| """ | ||
|
|
||
| from typing import Optional | ||
|
|
||
| from apache_beam.options.pipeline_options import PipelineOptions | ||
|
|
||
|
|
||
| class PipelineConstructionOptions: | ||
| """Holds the current pipeline's options during graph construction. | ||
|
|
||
| Set during Pipeline.__init__. | ||
| """ | ||
| options: Optional[PipelineOptions] = None | ||
|
|
||
|
|
||
| pipeline_construction_options = PipelineConstructionOptions() | ||
claudevdm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -74,12 +74,12 @@ | |||
| from apache_beam.coders import typecoders | ||||
| from apache_beam.internal import pickler | ||||
| from apache_beam.io.filesystems import FileSystems | ||||
| from apache_beam.options.pipeline_construction_options import pipeline_construction_options | ||||
| from apache_beam.options.pipeline_options import CrossLanguageOptions | ||||
| from apache_beam.options.pipeline_options import DebugOptions | ||||
| from apache_beam.options.pipeline_options import PipelineOptions | ||||
| from apache_beam.options.pipeline_options import SetupOptions | ||||
| from apache_beam.options.pipeline_options import StandardOptions | ||||
| from apache_beam.options.pipeline_options import StreamingOptions | ||||
| from apache_beam.options.pipeline_options import TypeOptions | ||||
| from apache_beam.options.pipeline_options_validator import PipelineOptionsValidator | ||||
| from apache_beam.portability import common_urns | ||||
|
|
@@ -226,8 +226,7 @@ def __init__( | |||
| raise ValueError( | ||||
| 'Pipeline has validations errors: \n' + '\n'.join(errors)) | ||||
|
|
||||
| typecoders.registry.update_compatibility_version = self._options.view_as( | ||||
| StreamingOptions).update_compatibility_version | ||||
| pipeline_construction_options.options = self._options | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you meant pipeline_construction_options.PipelineConstructionOptions.options? Other thoughts:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
pipeline_construction_options is a singleton instance, but I can see why this is confusing and I can rename the instance.
There are other cases of singleton objects that are not thread safe, like coder registry used during pipeline construction.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Closing this PR after discussion. Will plumb pipeline options explicitly. |
||||
|
|
||||
| # set default experiments for portable runners | ||||
| # (needs to occur prior to pipeline construction) | ||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.