mlops-for-all / mlops-for-all.github.io

169 stars 38 forks source link

[Question] Kubeflow -> 11. Pipeline Run Result 파트의 Visualization 관련 yaml 파일 내용 추가 문의 및 8. Component InputPath / OutputPath 오타 커밋 관련 요청 #89

Closed RyanKor closed 2 years ago

RyanKor commented 2 years ago

1. Kubeflow -> 11. Pipeline Run Result 파트의 Visualization 관련 yaml 파일 내용 추가 문의

안녕하세요.

image

위의 이미지에 보이는 큐브 플로우의 시각화를 진행할 수 있는 yaml 파일 내용을 모두의mlops 문서에 현재 없어 추가하면 좋을 것 같은데 해당 부분 프로젝트 관리자님이 확인해주시면, 빠르게 PR을 진행하고자 합니다.

하단은 plot_pipeline.yaml 설정 내용입니다.

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: plot-pipeline-
  annotations: {pipelines.kubeflow.org/kfp_sdk_version: 1.8.9, pipelines.kubeflow.org/pipeline_compilation_time: '2
022-01-17T13:31:32.963214',
    pipelines.kubeflow.org/pipeline_spec: '{"name": "plot_pipeline"}'}
  labels: {pipelines.kubeflow.org/kfp_sdk_version: 1.8.9}
spec:
  entrypoint: plot-pipeline
  templates:
  - name: plot-linear
    container:
      args: [--mlpipeline-ui-metadata, /tmp/outputs/mlpipeline_ui_metadata/data]
      command:
      - sh
      - -c
      - (PIP_DISABLE_PIP_VERSION_CHECK=1 python3 -m pip install --quiet --no-warn-script-location
        'matplotlib' || PIP_DISABLE_PIP_VERSION_CHECK=1 python3 -m pip install --quiet
        --no-warn-script-location 'matplotlib' --user) && "$0" "$@"
      - sh
      - -ec
      - |
        program_path=$(mktemp)
        printf "%s" "$0" > "$program_path"
        python3 -u "$program_path" "$@"
      - |
        def _make_parent_dirs_and_return_path(file_path: str):
            import os
            os.makedirs(os.path.dirname(file_path), exist_ok=True)
            return file_path
        def plot_linear(mlpipeline_ui_metadata):
            import base64
            import json
            from io import BytesIO
            import matplotlib.pyplot as plt
            plt.plot([1, 2, 3], [1, 2, 3])
            tmpfile = BytesIO()
            plt.savefig(tmpfile, format="png")
            encoded = base64.b64encode(tmpfile.getvalue()).decode("utf-8")
            html = f"<img src='data:image/png;base64,{encoded}'>"
            metadata = {
                "outputs": [
                    {
                        "type": "web-app",
                        "storage": "inline",
                        "source": html,
                    },
                ],
            }
            with open(mlpipeline_ui_metadata, "w") as html_writer:
                json.dump(metadata, html_writer)

        import argparse
        _parser = argparse.ArgumentParser(prog='Plot linear', description='')
        _parser.add_argument("--mlpipeline-ui-metadata", dest="mlpipeline_ui_metadata", type=_make_parent_dirs_and_return_path, required=True, default=argparse.SUPPRESS)
        _parsed_args = vars(_parser.parse_args())
        _outputs = plot_linear(**_parsed_args)
      image: python:3.7
    outputs:
      artifacts:
      - {name: mlpipeline-ui-metadata, path: /tmp/outputs/mlpipeline_ui_metadata/data}
    metadata:
      labels:
        pipelines.kubeflow.org/kfp_sdk_version: 1.8.9
        pipelines.kubeflow.org/pipeline-sdk-type: kfp
        pipelines.kubeflow.org/enable_caching: "true"
      annotations: {pipelines.kubeflow.org/component_spec: '{"implementation": {"container":
          {"args": ["--mlpipeline-ui-metadata", {"outputPath": "mlpipeline_ui_metadata"}],
          "command": ["sh", "-c", "(PIP_DISABLE_PIP_VERSION_CHECK=1 python3 -m pip
          install --quiet --no-warn-script-location ''matplotlib'' || PIP_DISABLE_PIP_VERSION_CHECK=1
          python3 -m pip install --quiet --no-warn-script-location ''matplotlib''
          --user) && \"$0\" \"$@\"", "sh", "-ec", "program_path=$(mktemp)\nprintf
          \"%s\" \"$0\" > \"$program_path\"\npython3 -u \"$program_path\" \"$@\"\n",
          "def _make_parent_dirs_and_return_path(file_path: str):\n    import os\n    os.makedirs(os.path.dirname(file_path),
          exist_ok=True)\n    return file_path\n\ndef plot_linear(mlpipeline_ui_metadata):\n    import
          base64\n    import json\n    from io import BytesIO\n\n    import matplotlib.pyplot
          as plt\n\n    plt.plot([1, 2, 3], [1, 2, 3])\n\n    tmpfile = BytesIO()\n    plt.savefig(tmpfile,
          format=\"png\")\n    encoded = base64.b64encode(tmpfile.getvalue()).decode(\"utf-8\")\n\n    html
          = f\"<img src=''data:image/png;base64,{encoded}''>\"\n    metadata = {\n        \"outputs\":
          [\n            {\n                \"type\": \"web-app\",\n                \"storage\":
          \"inline\",\n                \"source\": html,\n            },\n        ],\n    }\n    with
          open(mlpipeline_ui_metadata, \"w\") as html_writer:\n        json.dump(metadata,
          html_writer)\n\nimport argparse\n_parser = argparse.ArgumentParser(prog=''Plot
          linear'', description='''')\n_parser.add_argument(\"--mlpipeline-ui-metadata\",
          dest=\"mlpipeline_ui_metadata\", type=_make_parent_dirs_and_return_path,
          required=True, default=argparse.SUPPRESS)\n_parsed_args = vars(_parser.parse_args())\n\n_outputs
          = plot_linear(**_parsed_args)\n"], "image": "python:3.7"}}, "name": "Plot
          linear", "outputs": [{"name": "mlpipeline_ui_metadata", "type": "UI_Metadata"}]}',
        pipelines.kubeflow.org/component_ref: '{}'}
  - name: plot-pipeline
    dag:
      tasks:
      - {name: plot-linear, template: plot-linear}
  arguments:
    parameters: []
  serviceAccountName: pipeline-runner

2. Kubeflow -> 8. Component InputPath / OutputPath 부분 오타 커밋 진행 문의

image

1번 내용 추가와 함께 간단한 오타를 큐브플로우 챕터 8에서 발견해 함께 수정 PR을 보내고 싶은데, 확인해주시면 감사하겠습니다.

Aiden-Jeon commented 2 years ago

안녕하세요. 해당 내용 추가 및 수정해서 PR 주신다면 좋을 것 같습니다! 감사합니다!