小编Mar*_*vin的帖子

Bash Operator错误:气流中没有此类文件或目录

我是Airflow的新手,并且与BashOperator苦苦挣扎。我想在dag.py中使用bash操作符访问shell脚本。

我检查了: 如何在Airflow中运行bash脚本文件,BashOperator不运行bash文件apache airflow

关于如何通过bash运算符访问shell脚本的信息。

这是我所做的:

 cmd = "./myfirstdag/dag/lib/script.sh "

        t_1 = BashOperator(
            task_id='start',
            bash_command=cmd
        )
Run Code Online (Sandbox Code Playgroud)

在运行配方并检查气流时,出现以下错误:

[2018-11-01 10:44:05,078] {bash_operator.py:77} INFO - /tmp/airflowtmp7VmPci/startUDmFWW: line 1: ./myfirstdag/dag/lib/script.sh: No such file or directory
[2018-11-01 10:44:05,082] {bash_operator.py:80} INFO - Command exited with return code 127
[2018-11-01 10:44:05,083] {models.py:1361} ERROR - Bash command failed
Run Code Online (Sandbox Code Playgroud)

不知道为什么会这样。任何帮助,将不胜感激。

谢谢 !

编辑注意:我假设它正在某个气流tmp位置而不是我提供的路径中搜索。但是,如何使它搜索正确的路径。

python bash directed-acyclic-graphs airflow

6
推荐指数
2
解决办法
2441
查看次数

如何使用python docx将表格边框添加到word doc

我正在尝试使用 Python 的 docx 模块创建一个 word 文档。但是我无法向它添加表格边框。

我的代码如下:

    import docx
    from docx import Document
    from docx.shared import Pt
    doc = Document('C:/Users/Vinny/Desktop/Python/Template.docx')
    doc.add_paragraph('Changes:')

    doc.add_paragraph('Metrics:')
    #add table
    table = doc.add_table(rows = 4, cols = 2, style='TableGrid')
    doc.save('C:/Users/Vinny/Desktop/Python/rel.docx')
Run Code Online (Sandbox Code Playgroud)

但它抛出错误为:

Traceback (most recent call last):
  File "C:\Users\Vinny\Desktop\Python\abc.py", line 14, in <module>
    table = doc.add_table(rows = 4, cols = 2, style='TableGrid')
  File "C:\Users\Vinny\AppData\Local\Programs\Python\Python36-32\lib\site-packages\docx\document.py", line 100, in add_table
    table.style = style
  File "C:\Users\Vinny\AppData\Local\Programs\Python\Python36-32\lib\site-packages\docx\table.py", line 134, in style
    style_or_name, WD_STYLE_TYPE.TABLE
  File "C:\Users\Vinny\AppData\Local\Programs\Python\Python36-32\lib\site-packages\docx\parts\document.py", line 76, in get_style_id
    return …
Run Code Online (Sandbox Code Playgroud)

python docx python-3.x python-docx

4
推荐指数
1
解决办法
7071
查看次数

将多个值添加到字典键

我有两个清单:

list1 = ['670', '619', '524', '670', '693', '693', '693', '632', '671']
list2 = ['JAIPUR', 'MUMBAI', 'DELHI', 'UDAIPUR', 'GOA', 'GOA', 'GOA', 'LUCKNOW', 'JAIPUR']
Run Code Online (Sandbox Code Playgroud)

我想以此为基础制作一本字典。请严格按照应映射到的顺序记下这两个列表。就像键“670”值我们“JAIPUR”等等。

但是当我尝试时,它给出的输出为:

d = dict(zip(list1, list2))

{'670': 'UDAIPUR', '619': 'MUMBAI', '524': 'DELHI', '693': 'GOA', '632': 'LUCKNOW', '671': 'JAIPUR'}
Run Code Online (Sandbox Code Playgroud)

如果为单个键找到多个值,则仅采用最新值。然而我想要的是像 670 这样的单个键应该有多个值:

'670': ['JAIPUR', 'UDAIPUR']
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮忙。

python dictionary list data-structures

0
推荐指数
1
解决办法
8096
查看次数