首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Argo -使用输入参数文件从python提交工作流

Argo -使用输入参数文件从python提交工作流
EN

Stack Overflow用户
提问于 2022-07-02 23:24:43
回答 1查看 370关注 0票数 0

基本上,我想通过正式的argo submit -n argo workflows/workflow.yaml -f params.json运行以下命令:python

本例介绍了如何提交工作流清单,但我不知道在哪里添加输入参数文件。

代码语言:javascript
复制
import os
from pprint import pprint
import yaml
from pathlib import Path

import argo_workflows
from argo_workflows.api import workflow_service_api
from argo_workflows.model.io_argoproj_workflow_v1alpha1_workflow_create_request import \
    IoArgoprojWorkflowV1alpha1WorkflowCreateRequest

configuration = argo_workflows.Configuration(host="https://localhost:2746")
configuration.verify_ssl = False

with open("workflows/workflow.yaml", "r") as f:
    manifest = yaml.safe_load(f)

api_client = argo_workflows.ApiClient(configuration)
api_instance = workflow_service_api.WorkflowServiceApi(api_client)
api_response = api_instance.create_workflow(
    namespace="argo",
    body=IoArgoprojWorkflowV1alpha1WorkflowCreateRequest(workflow=manifest, _check_type=False),
    _check_return_type=False)
pprint(api_response)

在哪里传递params.json文件?

EN

回答 1

Stack Overflow用户

发布于 2022-08-03 23:11:02

我在WorkflowServiceApi.md的文档中找到了这个片段(这显然太大了,无法作为标记呈现):

代码语言:javascript
复制
import time
import argo_workflows
from argo_workflows.api import workflow_service_api
from argo_workflows.model.grpc_gateway_runtime_error import GrpcGatewayRuntimeError
from argo_workflows.model.io_argoproj_workflow_v1alpha1_workflow_submit_request import IoArgoprojWorkflowV1alpha1WorkflowSubmitRequest
from argo_workflows.model.io_argoproj_workflow_v1alpha1_workflow import IoArgoprojWorkflowV1alpha1Workflow
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:2746
# See configuration.py for a list of all supported configuration parameters.
configuration = argo_workflows.Configuration(
    host = "http://localhost:2746"
)


# Enter a context with an instance of the API client
with argo_workflows.ApiClient() as api_client:
    # Create an instance of the API class
    api_instance = workflow_service_api.WorkflowServiceApi(api_client)
    namespace = "namespace_example" # str | 
    body = IoArgoprojWorkflowV1alpha1WorkflowSubmitRequest(
        namespace="namespace_example",
        resource_kind="resource_kind_example",
        resource_name="resource_name_example",
        submit_options=IoArgoprojWorkflowV1alpha1SubmitOpts(
            annotations="annotations_example",
            dry_run=True,
            entry_point="entry_point_example",
            generate_name="generate_name_example",
            labels="labels_example",
            name="name_example",
            owner_reference=OwnerReference(
                api_version="api_version_example",
                block_owner_deletion=True,
                controller=True,
                kind="kind_example",
                name="name_example",
                uid="uid_example",
            ),
            parameter_file="parameter_file_example",
            parameters=[
                "parameters_example",
            ],
            pod_priority_class_name="pod_priority_class_name_example",
            priority=1,
            server_dry_run=True,
            service_account="service_account_example",
        ),
    ) # IoArgoprojWorkflowV1alpha1WorkflowSubmitRequest | 

    # example passing only required values which don't have defaults set
    try:
        api_response = api_instance.submit_workflow(namespace, body)
        pprint(api_response)
    except argo_workflows.ApiException as e:
        print("Exception when calling WorkflowServiceApi->submit_workflow: %s\n" % e)

你试过使用IoArgoprojWorkflowV1alpha1WorkflowSubmitRequest吗?看起来它有submit_options类型的IoArgoprojWorkflowV1alpha1SubmitOpts,它有一个parameter_file参数。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72843040

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档