Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
B
beam
管理
动态
成员
计划
Wiki
代码
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
部署
发布
模型注册表
分析
贡献者分析
仓库分析
洞察
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
oss-mirrors
beam
提交
b4ffbfe7
未验证
提交
b4ffbfe7
编辑于
1 year ago
作者:
Robert Bradshaw
提交者:
GitHub
1 year ago
浏览文件
操作
下载
差异文件
Merge pull request #29828 Also pull default beam services from an environment variable.
上级
3f3f6442
7e95776a
No related branches found
No related tags found
无相关合并请求
变更
2
隐藏空白变更内容
行内
左右并排
显示
2 个更改的文件
sdks/python/apache_beam/options/pipeline_options.py
+11
-3
11 个添加, 3 个删除
sdks/python/apache_beam/options/pipeline_options.py
sdks/python/apache_beam/options/pipeline_options_test.py
+33
-0
33 个添加, 0 个删除
sdks/python/apache_beam/options/pipeline_options_test.py
有
44 个添加
和
3 个删除
sdks/python/apache_beam/options/pipeline_options.py
+
11
−
3
浏览文件 @
b4ffbfe7
...
...
@@ -572,12 +572,18 @@ class StreamingOptions(PipelineOptions):
class
CrossLanguageOptions
(
PipelineOptions
):
@staticmethod
def
_beam_services_from_enviroment
():
return
json
.
loads
(
os
.
environ
.
get
(
'
BEAM_SERVICE_OVERRIDES
'
)
or
'
{}
'
)
@classmethod
def
_add_argparse_args
(
cls
,
parser
):
parser
.
add_argument
(
'
--beam_services
'
,
type
=
json
.
loads
,
default
=
{},
type
=
lambda
s
:
{
**
cls
.
_beam_services_from_enviroment
(),
**
json
.
loads
(
s
)
},
default
=
cls
.
_beam_services_from_enviroment
(),
help
=
(
'
For convenience, Beam provides the ability to automatically
'
'
download and start various services (such as expansion services)
'
...
...
@@ -586,7 +592,9 @@ class CrossLanguageOptions(PipelineOptions):
'
use pre-started services or non-default pre-existing artifacts to
'
'
start the given service.
'
'
Should be a json mapping of gradle build targets to pre-built
'
'
artifacts (e.g. jar files) expansion endpoints (e.g. host:port).
'
))
'
artifacts (e.g. jar files) or expansion endpoints
'
'
(e.g. host:port). Defaults to the value of BEAM_SERVICE_OVERRIDES
'
'
from the environment.
'
))
parser
.
add_argument
(
'
--use_transform_service
'
,
...
...
此差异已折叠。
点击以展开。
sdks/python/apache_beam/options/pipeline_options_test.py
+
33
−
0
浏览文件 @
b4ffbfe7
...
...
@@ -21,11 +21,14 @@
import
json
import
logging
import
os
import
unittest
import
hamcrest
as
hc
import
mock
from
parameterized
import
parameterized
from
apache_beam.options.pipeline_options
import
CrossLanguageOptions
from
apache_beam.options.pipeline_options
import
DebugOptions
from
apache_beam.options.pipeline_options
import
GoogleCloudOptions
from
apache_beam.options.pipeline_options
import
PipelineOptions
...
...
@@ -395,6 +398,36 @@ class PipelineOptionsTest(unittest.TestCase):
self
.
assertEqual
(
worker_options
.
machine_type
,
'
abc
'
)
self
.
assertEqual
(
worker_options
.
disk_type
,
'
def
'
)
def
test_beam_services_empty
(
self
):
with
mock
.
patch
.
dict
(
os
.
environ
,
{},
clear
=
True
):
options
=
PipelineOptions
().
view_as
(
CrossLanguageOptions
)
self
.
assertEqual
(
options
.
beam_services
,
{})
def
test_beam_services_from_env
(
self
):
with
mock
.
patch
.
dict
(
os
.
environ
,
{
'
BEAM_SERVICE_OVERRIDES
'
:
'
{
"
foo
"
:
"
bar
"
}
'
},
clear
=
True
):
options
=
PipelineOptions
().
view_as
(
CrossLanguageOptions
)
self
.
assertEqual
(
options
.
beam_services
,
{
'
foo
'
:
'
bar
'
})
def
test_beam_services_from_flag
(
self
):
with
mock
.
patch
.
dict
(
os
.
environ
,
{},
clear
=
True
):
options
=
PipelineOptions
([
'
--beam_services={
"
foo
"
:
"
bar
"
}
'
]).
view_as
(
CrossLanguageOptions
)
self
.
assertEqual
(
options
.
beam_services
,
{
'
foo
'
:
'
bar
'
})
def
test_beam_services_from_env_and_flag
(
self
):
with
mock
.
patch
.
dict
(
os
.
environ
,
{
'
BEAM_SERVICE_OVERRIDES
'
:
'
{
"
foo
"
:
"
bar
"
,
"
other
"
:
"
zzz
"
}
'
},
clear
=
True
):
options
=
PipelineOptions
([
'
--beam_services={
"
foo
"
:
"
override
"
}
'
]).
view_as
(
CrossLanguageOptions
)
self
.
assertEqual
(
options
.
beam_services
,
{
'
foo
'
:
'
override
'
,
'
other
'
:
'
zzz
'
})
def
test_option_modifications_are_shared_between_views
(
self
):
pipeline_options
=
PipelineOptions
([
'
--mock_option
'
,
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录