From 2796993afc4aab0251bc070e8b6b50e4a9fc7ad7 Mon Sep 17 00:00:00 2001 From: atmorling Date: Fri, 15 Nov 2024 11:10:30 +0200 Subject: [PATCH] Plot title kwargs (#368) * a first cut * add x/y positional params * recompile * reset lockfiles to be even with origin * relock --------- Co-authored-by: Charles Stern <62192187+cisaacstern@users.noreply.github.com> --- .../formdata.py | 3 +++ .../params.py | 3 +++ .../rjsf.json | 19 +++++++++++++++++++ .../pixi.lock | 16 ++++++++-------- .../formdata.py | 3 +++ .../params.py | 3 +++ .../rjsf.json | 19 +++++++++++++++++++ .../pixi.lock | 16 ++++++++-------- .../pixi.lock | 16 ++++++++-------- .../tasks/results/_ecoplot.py | 3 +++ .../tests/tasks/test_ecoplot.py | 2 +- 11 files changed, 78 insertions(+), 25 deletions(-) diff --git a/examples/events/ecoscope-workflows-events-workflow/ecoscope_workflows_events_workflow/formdata.py b/examples/events/ecoscope-workflows-events-workflow/ecoscope_workflows_events_workflow/formdata.py index 84db1a42b..3ea2b5d36 100644 --- a/examples/events/ecoscope-workflows-events-workflow/ecoscope_workflows_events_workflow/formdata.py +++ b/examples/events/ecoscope-workflows-events-workflow/ecoscope_workflows_events_workflow/formdata.py @@ -109,6 +109,9 @@ class BarLayoutStyle(BaseModel): font_style: Optional[str] = Field(None, title="Font Style") plot_bgcolor: Optional[str] = Field(None, title="Plot Bgcolor") showlegend: Optional[bool] = Field(None, title="Showlegend") + title: Optional[str] = Field(None, title="Title") + title_x: Optional[confloat(ge=0.0, le=1.0)] = Field(None, title="Title X") + title_y: Optional[confloat(ge=0.0, le=1.0)] = Field(None, title="Title Y") bargap: Optional[confloat(ge=0.0, le=1.0)] = Field(None, title="Bargap") bargroupgap: Optional[confloat(ge=0.0, le=1.0)] = Field(None, title="Bargroupgap") diff --git a/examples/events/ecoscope-workflows-events-workflow/ecoscope_workflows_events_workflow/params.py b/examples/events/ecoscope-workflows-events-workflow/ecoscope_workflows_events_workflow/params.py index 66b42b80d..16e801d33 100644 --- a/examples/events/ecoscope-workflows-events-workflow/ecoscope_workflows_events_workflow/params.py +++ b/examples/events/ecoscope-workflows-events-workflow/ecoscope_workflows_events_workflow/params.py @@ -109,6 +109,9 @@ class BarLayoutStyle(BaseModel): font_style: Optional[str] = Field(None, title="Font Style") plot_bgcolor: Optional[str] = Field(None, title="Plot Bgcolor") showlegend: Optional[bool] = Field(None, title="Showlegend") + title: Optional[str] = Field(None, title="Title") + title_x: Optional[confloat(ge=0.0, le=1.0)] = Field(None, title="Title X") + title_y: Optional[confloat(ge=0.0, le=1.0)] = Field(None, title="Title Y") bargap: Optional[confloat(ge=0.0, le=1.0)] = Field(None, title="Bargap") bargroupgap: Optional[confloat(ge=0.0, le=1.0)] = Field(None, title="Bargroupgap") diff --git a/examples/events/ecoscope-workflows-events-workflow/ecoscope_workflows_events_workflow/rjsf.json b/examples/events/ecoscope-workflows-events-workflow/ecoscope_workflows_events_workflow/rjsf.json index a182df46d..23689a4fd 100644 --- a/examples/events/ecoscope-workflows-events-workflow/ecoscope_workflows_events_workflow/rjsf.json +++ b/examples/events/ecoscope-workflows-events-workflow/ecoscope_workflows_events_workflow/rjsf.json @@ -235,6 +235,25 @@ "title": "Showlegend", "type": "boolean" }, + "title": { + "default": null, + "title": "Title", + "type": "string" + }, + "title_x": { + "default": null, + "maximum": 1.0, + "minimum": 0.0, + "title": "Title X", + "type": "number" + }, + "title_y": { + "default": null, + "maximum": 1.0, + "minimum": 0.0, + "title": "Title Y", + "type": "number" + }, "bargap": { "default": null, "maximum": 1.0, diff --git a/examples/events/ecoscope-workflows-events-workflow/pixi.lock b/examples/events/ecoscope-workflows-events-workflow/pixi.lock index 250d2d9ac..ae7d19472 100644 --- a/examples/events/ecoscope-workflows-events-workflow/pixi.lock +++ b/examples/events/ecoscope-workflows-events-workflow/pixi.lock @@ -5678,8 +5678,8 @@ packages: subdir: noarch noarch: python url: file:///tmp/ecoscope-workflows/release/artifacts/noarch/ecoscope-workflows-core-v0.0.21-pyh4616a5c_0.conda - sha256: e6bad4640ce3d9cd3aa1747815b7f73e3d8b5b83a672add2fd3cf9905a00244c - md5: bfc56c192538df7124c9f86dd6c80d07 + sha256: 05ad185eb329415714b15f27e4d205058459e0c5cc9dac84d4bf0ddb3dc81bd5 + md5: 2fbd8b3d1edbc2c242cd5710fe055e57 depends: - python - jinja2 @@ -5696,8 +5696,8 @@ packages: - pydot - python license: BSD-3-Clause - size: 52000 - timestamp: 1731528846142 + size: 51785 + timestamp: 1731660872628 - kind: pypi name: ecoscope-workflows-events-workflow version: 0.0.0 @@ -5712,16 +5712,16 @@ packages: subdir: noarch noarch: python url: file:///tmp/ecoscope-workflows/release/artifacts/noarch/ecoscope-workflows-ext-ecoscope-v0.0.21-pyh4616a5c_0.conda - sha256: 0b7a6ab906b8fb531f1af9b18dff106d4374866338ac35f33187263cffdd7603 - md5: 2c033ca8d31c099a1ec4d339950bc9ac + sha256: 079d60e2124f1a80dcbec2f2a2c31bcb772fba46c18fa068adf0c08ecfcd262a + md5: ab0151bd22a34f373a11bd801110be35 depends: - python - ecoscope-workflows-core ==v0.0.21 - ecoscope ==v1.8.8 - python license: BSD-3-Clause - size: 6799456 - timestamp: 1731528898 + size: 6799478 + timestamp: 1731660922599 - kind: conda name: email-validator version: 2.2.0 diff --git a/examples/patrols/ecoscope-workflows-patrols-workflow/ecoscope_workflows_patrols_workflow/formdata.py b/examples/patrols/ecoscope-workflows-patrols-workflow/ecoscope_workflows_patrols_workflow/formdata.py index 9bf1ad06d..eeb0d0522 100644 --- a/examples/patrols/ecoscope-workflows-patrols-workflow/ecoscope_workflows_patrols_workflow/formdata.py +++ b/examples/patrols/ecoscope-workflows-patrols-workflow/ecoscope_workflows_patrols_workflow/formdata.py @@ -148,6 +148,9 @@ class BarLayoutStyle(BaseModel): font_style: Optional[str] = Field(None, title="Font Style") plot_bgcolor: Optional[str] = Field(None, title="Plot Bgcolor") showlegend: Optional[bool] = Field(None, title="Showlegend") + title: Optional[str] = Field(None, title="Title") + title_x: Optional[confloat(ge=0.0, le=1.0)] = Field(None, title="Title X") + title_y: Optional[confloat(ge=0.0, le=1.0)] = Field(None, title="Title Y") bargap: Optional[confloat(ge=0.0, le=1.0)] = Field(None, title="Bargap") bargroupgap: Optional[confloat(ge=0.0, le=1.0)] = Field(None, title="Bargroupgap") diff --git a/examples/patrols/ecoscope-workflows-patrols-workflow/ecoscope_workflows_patrols_workflow/params.py b/examples/patrols/ecoscope-workflows-patrols-workflow/ecoscope_workflows_patrols_workflow/params.py index f3444cfe7..e60c53cf7 100644 --- a/examples/patrols/ecoscope-workflows-patrols-workflow/ecoscope_workflows_patrols_workflow/params.py +++ b/examples/patrols/ecoscope-workflows-patrols-workflow/ecoscope_workflows_patrols_workflow/params.py @@ -127,6 +127,9 @@ class BarLayoutStyle(BaseModel): font_style: Optional[str] = Field(None, title="Font Style") plot_bgcolor: Optional[str] = Field(None, title="Plot Bgcolor") showlegend: Optional[bool] = Field(None, title="Showlegend") + title: Optional[str] = Field(None, title="Title") + title_x: Optional[confloat(ge=0.0, le=1.0)] = Field(None, title="Title X") + title_y: Optional[confloat(ge=0.0, le=1.0)] = Field(None, title="Title Y") bargap: Optional[confloat(ge=0.0, le=1.0)] = Field(None, title="Bargap") bargroupgap: Optional[confloat(ge=0.0, le=1.0)] = Field(None, title="Bargroupgap") diff --git a/examples/patrols/ecoscope-workflows-patrols-workflow/ecoscope_workflows_patrols_workflow/rjsf.json b/examples/patrols/ecoscope-workflows-patrols-workflow/ecoscope_workflows_patrols_workflow/rjsf.json index 3acf4f452..bd9eaae81 100644 --- a/examples/patrols/ecoscope-workflows-patrols-workflow/ecoscope_workflows_patrols_workflow/rjsf.json +++ b/examples/patrols/ecoscope-workflows-patrols-workflow/ecoscope_workflows_patrols_workflow/rjsf.json @@ -310,6 +310,25 @@ "title": "Showlegend", "type": "boolean" }, + "title": { + "default": null, + "title": "Title", + "type": "string" + }, + "title_x": { + "default": null, + "maximum": 1.0, + "minimum": 0.0, + "title": "Title X", + "type": "number" + }, + "title_y": { + "default": null, + "maximum": 1.0, + "minimum": 0.0, + "title": "Title Y", + "type": "number" + }, "bargap": { "default": null, "maximum": 1.0, diff --git a/examples/patrols/ecoscope-workflows-patrols-workflow/pixi.lock b/examples/patrols/ecoscope-workflows-patrols-workflow/pixi.lock index 5affd345c..1bf38b3b6 100644 --- a/examples/patrols/ecoscope-workflows-patrols-workflow/pixi.lock +++ b/examples/patrols/ecoscope-workflows-patrols-workflow/pixi.lock @@ -5678,8 +5678,8 @@ packages: subdir: noarch noarch: python url: file:///tmp/ecoscope-workflows/release/artifacts/noarch/ecoscope-workflows-core-v0.0.21-pyh4616a5c_0.conda - sha256: e6bad4640ce3d9cd3aa1747815b7f73e3d8b5b83a672add2fd3cf9905a00244c - md5: bfc56c192538df7124c9f86dd6c80d07 + sha256: 05ad185eb329415714b15f27e4d205058459e0c5cc9dac84d4bf0ddb3dc81bd5 + md5: 2fbd8b3d1edbc2c242cd5710fe055e57 depends: - python - jinja2 @@ -5696,8 +5696,8 @@ packages: - pydot - python license: BSD-3-Clause - size: 52000 - timestamp: 1731528846142 + size: 51785 + timestamp: 1731660872628 - kind: conda name: ecoscope-workflows-ext-ecoscope version: v0.0.21 @@ -5705,16 +5705,16 @@ packages: subdir: noarch noarch: python url: file:///tmp/ecoscope-workflows/release/artifacts/noarch/ecoscope-workflows-ext-ecoscope-v0.0.21-pyh4616a5c_0.conda - sha256: 0b7a6ab906b8fb531f1af9b18dff106d4374866338ac35f33187263cffdd7603 - md5: 2c033ca8d31c099a1ec4d339950bc9ac + sha256: 079d60e2124f1a80dcbec2f2a2c31bcb772fba46c18fa068adf0c08ecfcd262a + md5: ab0151bd22a34f373a11bd801110be35 depends: - python - ecoscope-workflows-core ==v0.0.21 - ecoscope ==v1.8.8 - python license: BSD-3-Clause - size: 6799456 - timestamp: 1731528898 + size: 6799478 + timestamp: 1731660922599 - kind: pypi name: ecoscope-workflows-patrols-workflow version: 0.0.0 diff --git a/examples/subject-tracking/ecoscope-workflows-subject-tracking-workflow/pixi.lock b/examples/subject-tracking/ecoscope-workflows-subject-tracking-workflow/pixi.lock index c5ff1b25e..3896d091a 100644 --- a/examples/subject-tracking/ecoscope-workflows-subject-tracking-workflow/pixi.lock +++ b/examples/subject-tracking/ecoscope-workflows-subject-tracking-workflow/pixi.lock @@ -5678,8 +5678,8 @@ packages: subdir: noarch noarch: python url: file:///tmp/ecoscope-workflows/release/artifacts/noarch/ecoscope-workflows-core-v0.0.21-pyh4616a5c_0.conda - sha256: e6bad4640ce3d9cd3aa1747815b7f73e3d8b5b83a672add2fd3cf9905a00244c - md5: bfc56c192538df7124c9f86dd6c80d07 + sha256: 05ad185eb329415714b15f27e4d205058459e0c5cc9dac84d4bf0ddb3dc81bd5 + md5: 2fbd8b3d1edbc2c242cd5710fe055e57 depends: - python - jinja2 @@ -5696,8 +5696,8 @@ packages: - pydot - python license: BSD-3-Clause - size: 52000 - timestamp: 1731528846142 + size: 51785 + timestamp: 1731660872628 - kind: conda name: ecoscope-workflows-ext-ecoscope version: v0.0.21 @@ -5705,16 +5705,16 @@ packages: subdir: noarch noarch: python url: file:///tmp/ecoscope-workflows/release/artifacts/noarch/ecoscope-workflows-ext-ecoscope-v0.0.21-pyh4616a5c_0.conda - sha256: 0b7a6ab906b8fb531f1af9b18dff106d4374866338ac35f33187263cffdd7603 - md5: 2c033ca8d31c099a1ec4d339950bc9ac + sha256: 079d60e2124f1a80dcbec2f2a2c31bcb772fba46c18fa068adf0c08ecfcd262a + md5: ab0151bd22a34f373a11bd801110be35 depends: - python - ecoscope-workflows-core ==v0.0.21 - ecoscope ==v1.8.8 - python license: BSD-3-Clause - size: 6799456 - timestamp: 1731528898 + size: 6799478 + timestamp: 1731660922599 - kind: pypi name: ecoscope-workflows-subject-tracking-workflow version: 0.0.0 diff --git a/src/ecoscope-workflows-ext-ecoscope/ecoscope_workflows_ext_ecoscope/tasks/results/_ecoplot.py b/src/ecoscope-workflows-ext-ecoscope/ecoscope_workflows_ext_ecoscope/tasks/results/_ecoplot.py index eb097cb7f..fb23e8a76 100644 --- a/src/ecoscope-workflows-ext-ecoscope/ecoscope_workflows_ext_ecoscope/tasks/results/_ecoplot.py +++ b/src/ecoscope-workflows-ext-ecoscope/ecoscope_workflows_ext_ecoscope/tasks/results/_ecoplot.py @@ -35,6 +35,9 @@ class LayoutStyle(BaseModel): font_style: str | SkipJsonSchema[None] = None plot_bgcolor: str | SkipJsonSchema[None] = None showlegend: bool | SkipJsonSchema[None] = None + title: str | SkipJsonSchema[None] = None + title_x: Annotated[float, Field(ge=0.0, le=1.0)] | SkipJsonSchema[None] = None + title_y: Annotated[float, Field(ge=0.0, le=1.0)] | SkipJsonSchema[None] = None class BarLayoutStyle(LayoutStyle): diff --git a/src/ecoscope-workflows-ext-ecoscope/tests/tasks/test_ecoplot.py b/src/ecoscope-workflows-ext-ecoscope/tests/tasks/test_ecoplot.py index b6fecd297..318c5dc7b 100644 --- a/src/ecoscope-workflows-ext-ecoscope/tests/tasks/test_ecoplot.py +++ b/src/ecoscope-workflows-ext-ecoscope/tests/tasks/test_ecoplot.py @@ -150,8 +150,8 @@ def test_draw_time_series_bar_chart(time_series_dataframe, time_interval): time_interval=time_interval, color_column="color_column", plot_style=PlotStyle(xperiodalignment="middle"), + layout_style=LayoutStyle(title="Some Bars"), ) - assert isinstance(plot, str)