3

我正在尝试访问作为输入工件传递给脚本模板的文件的内容(json 数据)。它失败并出现以下错误NameError: name 'inputs' is not defined. Did you mean: 'input'?

我的工件存储在 aws s3 存储桶中。我也尝试过使用环境变量而不是直接在脚本模板中直接引用工件,但它也不起作用。

这是我的工作流程

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: output-artifact-s3-
spec:
  entrypoint: main
  templates:
    - name: main
      dag:
        tasks:
          - name: whalesay-script-template
            template: whalesay

          - name: retrieve-output-template
            dependencies: [whalesay-script-template]
            arguments:
              artifacts:
                - name: result
                  from: "{{tasks.whalesay-script-template.outputs.artifacts.message}}"
            template: retrieve-output


    - name: whalesay
      script:
        image: python
        command: [python]
        env:
          - name: OUTDATA
            value: |
              {
              "lb_url" : "<>.us-east-1.elb.amazonaws.com",
              "vpc_id" : "<vpc-id",
              "web_server_count" : "4"
              }
        source: |
          import json
          import os
          OUTDATA = json.loads(os.environ["OUTDATA"])
          with open('/tmp/templates_lst.txt', 'w') as outfile:
            outfile.write(str(json.dumps(OUTDATA)))
        volumeMounts:
          - name: out
            mountPath: /tmp
      volumes:
        - name: out
          emptyDir: { }
      outputs:
        artifacts:
          - name: message
            path: /tmp


    - name: retrieve-output
      inputs:
        artifacts:
          - name: result
            path: /tmp
      script:
        image: python
        command: [python]
        source: |
          import json
          result = {{inputs.artifacts.result}}
          with open(result, 'r') as outfile:
            lines = outfile.read()
            print(lines)
          print('Execution completed')

这个工作流程有什么问题?

4

1 回答 1

3
于 2021-12-27T18:47:57.200 回答