我正在尝试使用jbuilder从rails构建一些json输出.我有类似的东西:
json.links do | i |
i.array!( @links ) do | j, link |
j.source link['source']
j.target link['target']
j.stats do | s |
[ 'item1', 'item2' ].each { |item|
s.item statistics_path( :source => link['source'], :metric => item )
}
end
end
end
Run Code Online (Sandbox Code Playgroud)
当然,这导致类似于:
{
links: [
source: "a",
target: "b",
stats: {
item: 'url for item2'
}
]
}
Run Code Online (Sandbox Code Playgroud)
当我真正想要的东西:
{
links: [
source: "a",
target: "b",
stats: {
item1: 'url for item1',
item2: 'url for item2'
}
]
} …Run Code Online (Sandbox Code Playgroud) 所以我注意到在我的ansible playbooks中,如果我使用相同的playbook定位多个主机,那么每个任务必须在所有主机进入下一个任务之前完成.
是否可以定义播放簿,以便任务在完成后立即运行以下任务而无需等待任务在所有其他主机上完成?
我正在尝试从 Airflow 导出 dag 统计信息。statsd 输出不是很有用,所以我决定基本上运行一个 dag 来查询 SQL 并将其导出为 influxdb。
所以很容易创建一个 DAG 来查询 postgres 气流数据库。但是,我对架构有点困惑。我会想:
select run_id, start_date, end_date from dag_run where dag_id= 'blah';
Run Code Online (Sandbox Code Playgroud)
会这样做,但 endend_date似乎永远不会被填充。
我真正想要的是 dag 运行开始的总时间(第一个作业开始的时间,而不是作业第一次进入running状态的时间)和 dag 进入success状态的时间。
有人可以帮我翻译一些python 2.7语法到python 2.6请(由于redhat依赖,有点卡在2.6)
所以我有一个简单的功能来构建一个树:
def tree(): return defaultdict(tree)
Run Code Online (Sandbox Code Playgroud)
当然我想以某种方式显示树.在python 2.7下我可以使用:
$ /usr/bin/python2.7
Python 2.7.2 (default, Oct 17 2012, 03:00:49)
[GCC 4.4.6 [TWW]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def dicts(t): return {k: dicts(t[k]) for k in t}
...
>>>
Run Code Online (Sandbox Code Playgroud)
一切都很好...但在2.6以下我得到以下错误:
$ /usr/bin/python
Python 2.6.6 (r266:84292, Sep 4 2013, 07:46:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def dicts(t): return {k: dicts(t[k]) for k …Run Code Online (Sandbox Code Playgroud) airflow ×1
ansible ×1
jbuilder ×1
json ×1
python ×1
python-2.6 ×1
python-2.7 ×1
report ×1
statistics ×1
syntax ×1
wait ×1