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

plotのタイトル表示 #54

Merged
merged 4 commits into from
Sep 29, 2023
Merged

Conversation

ReiHashimoto
Copy link

  • Scatter, Bar, HeatMapのプロットにx軸、y軸、プロットタイトルの表示機能を追加
  • wrapper関数で対象のdataclassオブジェクトに対して、PlotMetaDataクラスを渡すことでこれらの情報を付加できる
    • 各生成グラフの命名等が決まっていないため、現時点ではwrapper関数側への割り当てはなし
  • workflow実行後に生成されるjsonファイル(etaのmean_heatmap.jsonなど)に以下のように"meta"フィールドを追記することで動作確認可能
    {
      "meta": {
          "xlabel": "foo",
          "ylabel": "bar",
          "title": "foo vs bar"
      },
      "columns": [],
      "index": [],
      "data": [],
    }

newPlot (1)
newPlot (2)
newPlot (3)

@ReiHashimoto ReiHashimoto self-assigned this Aug 23, 2023
@itutu-tienday
Copy link
Collaborator

@ReiHashimoto
一点質問ですが、この対応はfluorescenceなどの線グラフにも対応されていますでしょうか?

※ 以下の対応に、plotタイトル表示を適用できるとよいものと思います。

@ReiHashimoto
Copy link
Author

@itutu-tienday

この対応はfluorescenceなどの線グラフにも対応されていますでしょうか?

timeseries(fluorescence含む)には現状非対応です。
timeseriesの場合、0.json, 1.jsonのように複数のjsonファイルが発生するため、それぞれにmetaデータフィールドを持たせる必要があり、対応しかねていたという背景があります。

しかし、コメントをしながら思いましたが、
そもそも同一のjsonファイル内に書き込むのではなく
別ファイルでmeta.jsonなどを用意して保存し、APIで返す際にmergeすれば良さそうですね。
その方針でfixしてみようと思いますが、いかがでしょうか?

@itutu-tienday
Copy link
Collaborator

@ReiHashimoto

別ファイルでmeta.jsonなどを用意して保存し、APIで返す際にmergeすれば良さそうですね。

ファイルは増えますが、上記の形式だと、plotの種類が切り替わっても 設定の形式に一貫性があり、よいかもしれないですね。
※細かい点ですが、設定ファイル名は plotやgraphなどのキーワード付与(plot-meta.json や graph-meta.json など)があるとよいかもしれません。

@ReiHashimoto
Copy link
Author

@itutu-tienday

設定ファイル名は plotやgraphなどのキーワード付与(plot-meta.json や graph-meta.json など)があるとよいかもしれません。

そうですね、plot-meta.jsonで進めます!

@ReiHashimoto
Copy link
Author

  • metaデータをplot-meta.jsonとして別ファイルで保存する方式に変更

  • timeseries, imageなどのデータクラスにも対応

  • timeseries, csvについては、jsonファイルのパスではなくディレクトリがAPIで指定されるため、ファイル保存先の仕様が異なる

    • 対象のディレクトリと並列に保存される
    • 例としてfluorescenceの場合、
      OUTPUT_DIR/
      └ workspace_id
          └ workflow_id
              └ function_id
                   ├ fluorescence
                   |    ├ 0.json
                   |    ├ 1.json
                   |    └ n.json
                   └ fluorescence.plot-meta.json
      

@itutu-tienday
Copy link
Collaborator

itutu-tienday commented Aug 28, 2023

@ReiHashimoto
以下数点、質問になります。

  • 以下のファイルを配置して動作確認しましたが、plotタイトルが表示されない模様です。指摘があればお願いします。

    • file:
      • (function_id)/
        • fluorescence.plot-meta.json
          {
            "meta": {
                "xlabel": "frames",
                "ylabel": "bar",
                "title": "foo vs bar"
            }
          }
          
    • ※上記のファイル格納後、ブラウザreload→reproduce→run→visualize を表示
  • fluorescence.plot-meta.json などは、fluorescence/plot-meta.json よりも、上記のファイル名形式のほうが妥当そうでしたでしょうか?

@ReiHashimoto
Copy link
Author

@itutu-tienday
共有漏れでした、別ファイルに保存するようになったことに伴い、

{
    "xlabel": "frames",
    "ylabel": "bar",
    "title": "foo vs bar"
}

がplot-meta.jsonの中身になります。


fluorescence.plot-meta.json などは、fluorescence/plot-meta.json よりも、上記のファイル名形式のほうが妥当そうでしたでしょうか?

以下のように対象ディレクトリから連番のファイルをglobパターンで取得しており、excludeしにくいことからこのような実装としています。

studio/app/common/routers/outputs.py

@router.get("/inittimedata/{dirpath:path}", response_model=JsonTimeSeriesData)
async def get_inittimedata(dirpath: str):
    file_numbers = sorted(
        [
            os.path.splitext(os.path.basename(x))[0]
            for x in glob(join_filepath([dirpath, "*.json"]))
        ]
    )

@itutu-tienday
Copy link
Collaborator

@ReiHashimoto

がplot-meta.jsonの中身になります。

上記の設定で、plot の label が表示されることを確認しました。

excludeしにくいことからこのような実装としています。

了解しました。

excludeのしづらさもありますが、他のデータファイルの構成(基本的に {データタイプ名}.json が実データ内容に対応)との統一感から、{データタイプ名}.plot-meta.json でよさそうですね。
※なおややファイル名が長い気もしましたが、他に案は一旦ないため({データタイプ名}.visual.json くらい)、このファイル名でOKかと思います。

@ReiHashimoto
Copy link
Author

Note: 20230904 MTG

  • タイトルなどに限らず、layoutで使用するパラメータを関数から設定できるようにしたい
    • Visualize画面でインタラクティブに変更できる必要はない
      • 関数ごとに決まった値のセットが使用できれば良い
    • 任意のkey, valueの組み合わせになるので、condaやparamsなどと同じように関数ごとのパラメータを指定する方式にした方が良いかもしれない

@ReiHashimoto ReiHashimoto marked this pull request as draft September 5, 2023 12:48
@ReiHashimoto ReiHashimoto marked this pull request as ready for review September 29, 2023 11:30
@ReiHashimoto ReiHashimoto merged commit e4365c2 into develop-main Sep 29, 2023
@ReiHashimoto ReiHashimoto deleted the feature/add-plot-meta branch September 29, 2023 11:30
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 this pull request may close these issues.

2 participants