Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow RUN仕様整理・修正 #105

Closed
itutu-tienday opened this issue Oct 12, 2023 · 4 comments · Fixed by #120
Closed

Workflow RUN仕様整理・修正 #105

itutu-tienday opened this issue Oct 12, 2023 · 4 comments · Fixed by #120
Assignees
Milestone

Comments

@itutu-tienday
Copy link
Collaborator

itutu-tienday commented Oct 12, 2023

/WorkflowのRUN機能(変更点のみの差分実行機能)について、仕様整理と、必要な改修を実施する。

@itutu-tienday itutu-tienday changed the title RUN仕様整理、修正 Workflow RUN仕様整理、修正 Oct 12, 2023
@ReiHashimoto
Copy link

ReiHashimoto commented Oct 24, 2023

@itutu-tienday

#92 対応後にはそちらにも記載予定です

RUN仕様整理

現状の仕様のまとめ

  • 関数のパラメータが変更された、もしくは前回の実行時にエラーだったAlgorithm Nodeおよびその後ろのノードを再実行する
  • 以下のような操作を行っても結果が変わらない
    • Input Nodeのファイル変更
    • snakemake, nwbのパラメータ変更
  • Algorithm Nodeの追加による挙動
    • 新たにAlgorithm Nodeを追加した場合は、その関数のみ実行される
    • 後ろにAlgorithm Nodeが繋がっているAlgorithm Nodeを別なものに入れ替えた場合、入れ替え後の関数が実行される
      • しかし、後続の関数は再実行されず、入れ替え前の関数の結果を入力としたものが結果となっている

Backend

RUN_ALLとの違い

  • forceRunListに再実行対象のノードのリストを渡す(RUN_ALLの場合は空)
  • このリストは以下の箇所で使用される
    if len(snakemake_params.forcerun) > 0:
    delete_dependencies(
    workspace_id=self.workspace_id,
    unique_id=self.unique_id,
    smk_params=snakemake_params,
    nodeDict=self.nodeDict,
    edgeDict=self.edgeDict,
    )

    def delete_dependencies(
    workspace_id: str,
    unique_id: str,
    smk_params: SmkParam,
    nodeDict: Dict[str, Node],
    edgeDict: Dict[str, Edge],
    ):
    queue = deque()
    for param in smk_params.forcerun:
    queue.append(param.nodeId)
    while True:
    # terminate condition
    if len(queue) == 0:
    break
    # delete pickle
    node_id = queue.pop()
    algo_name = nodeDict[node_id].data.label
    pickle_filepath = join_filepath(
    [
    DIRPATH.OUTPUT_DIR,
    get_pickle_file(
    workspace_id=workspace_id,
    unique_id=unique_id,
    node_id=node_id,
    algo_name=algo_name,
    ),
    ]
    )
    # print(pickle_filepath)
    if os.path.exists(pickle_filepath):
    os.remove(pickle_filepath)
    # 全てのedgeを見て、node_idがsourceならtargetをqueueに追加する
    for edge in edgeDict.values():
    if node_id == edge.source:
    queue.append(edge.target)
    • 上記の処理によって、再実行対象ノードおよびそのtargetになっているノード(つまり、再実行対象とそれよりフローの後ろにあるノード)のoutput(pickleファイル)を削除する
    • snakemakeはoutputのファイルが存在しない場合のみ対象のジョブを実行するため、ここでoutputが削除されたノードはジョブの実行対象となる

Frontend

RUNのrequest bodyの生成

  • request bodyは以下の関数selectorで取得する
    export const selectRunPostData = (state: RootState) => {
    const nwbParam = selectNwbParams(state)
    const snakemakeParam = selectSnakemakeParams(state)
    const edgeDictForRun = selectEdgeDictForRun(state)
    const nodeDictForRun = selectNodeDictForRun(state)
    const forceRunList = selectForceRunList(state)
    const runPostData: Omit<RunPostData, "name"> = {
    nwbParam,
    snakemakeParam,
    edgeDict: edgeDictForRun,
    nodeDict: nodeDictForRun,
    forceRunList,
    }
    return runPostData
    }
  • forceRunListは以下のロジック
    const selectForceRunList = (state: RootState) => {
    const nodes = selectFlowNodes(state)
    return nodes
    .filter(isAlgorithmNodeData)
    .filter((node) => {
    const isUpdated = selectAlgorithmIsUpdated(node.id)(state)
    const status = selectPipelineNodeResultStatus(node.id)(state)
    return isUpdated || status === NODE_RESULT_STATUS.ERROR
    })
    .map((node) => ({
    nodeId: node.id,
    name: selectAlgorithmName(node.id)(state),
    }))
    }
    • つまり、Algorithm Nodeが以下のどちらかの条件の場合にforceRunListに追加される
      • isUpdatedフラグが立っている
      • ステータスがerror
  • isUpdatedの更新
    • 以下のupdateParam reducerのみでisUpdatedはtrueになる
      updateParam: (
      state,
      action: PayloadAction<{
      nodeId: string
      path: string
      newValue: unknown
      }>,
      ) => {
      const { nodeId, path, newValue } = action.payload
      const param = state[nodeId].params
      if (param != null) {
      const target = getChildParam(path, param)
      if (target != null) {
      target.value = newValue
      state[nodeId].isUpdated = true
      }
      }
      },
    • このイベントをdispatchするのは以下のコンポーネント(Algorithm Nodeのパラメータフォーム)のみ
      const ParamItem = memo(function ParamItem({ paramKey }: ParamItemProps) {
      const nodeId = useContext(ParamFormContext)
      const Component = createParamFormItemComponent({
      paramSelector: (paramKey) => selectAlgorithmParam(nodeId, paramKey),
      paramValueSelector: (path) => selectAlgorithmParamsValue(nodeId, path),
      paramUpdateActionCreator: (path, newValue) =>
      updateParam({ nodeId, path, newValue }),
      })
      return <Component paramKey={paramKey} />
      })
      • snakemake, nwbのパラメータは影響がない

ToBe

  • 基本的には、関数のパラメータを変更して解析を行う、またはエラーがあった関数のパラメータをチューニングして再実行するための機能で、現行の機能自体は問題ない
    • また、reproduceの際にRUNをしなくとも結果が利用可能になったことで、パラメータ変更という目的にフォーカスしやすくなった
  • 一方で、RUN ALLで実行すべき場合(パイプライン全体に影響するパラメータ等の変更があった時)にRUNになり得るのが問題
    • Input Nodeのファイル変更やsnakemake, nwbのパラメータ変更が該当
      • パラメータの変更反映前にダイアログで確認する
      • これらの変更があった場合に、RUNを利用不可にする

@itutu-tienday
Copy link
Collaborator Author

itutu-tienday commented Oct 24, 2023

@ReiHashimoto
調査ありがとうございます。 数点、コメントを記載します。

※詳細のディスカッションは、またMTGなどで行えればと思います。

  1. RUNの実行対象範囲について
    • しかし、後続の関数は再実行されず、入れ替え前の関数の結果を入力としたものが結果となっている

    • 上記の挙動は、Snakemakeの仕様からも 整合はとれていることを理解しましたが、ユーザーの利用ケースをイメージすると、「変更したノード以降のノードがRUNの対象となる」という動作が、直感的+ニーズとマッチするのでは? と感じました。
  2. RUNの実行対象の強調表示
    • また上のようなRUNの仕様は、テキストでの説明はやや伝わりづらくも思われるため、「ノード等の変更時、RUNの対象となるノードがハイライトされる」などの表示オプションがあると、ユーザビリティ面で良さそうかと思いました。

また RUNの実行時にエラーが生じやすい状況についても、何か判明した情報があれば、またシェアいただければと思います。

@ReiHashimoto ReiHashimoto linked a pull request Oct 25, 2023 that will close this issue
@itutu-tienday itutu-tienday added this to the v1.1.0 milestone Oct 26, 2023
@itutu-tienday
Copy link
Collaborator Author

itutu-tienday commented Oct 26, 2023

  • 残タスクメモ
    • RUN実行時の出力データの格納仕様についての整理
      • 前回の実行のアウトプットが残存する(前回と今回で出力が混在する)件
      • 前回の実行履歴は保持対象外となる件

→ ユーザー側にも意見伺いするのがよさそう

@itutu-tienday itutu-tienday changed the title Workflow RUN仕様整理、修正 Workflow RUN仕様整理・修正 Nov 27, 2023
@itutu-tienday
Copy link
Collaborator Author

残タスクは 後続issue( #196 ) での対応とし、当issueはクローズ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants