nova-trame 0.22.0__py3-none-any.whl → 0.22.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,73 @@
1
+ """Components used to control the lifecycle of a Themed Application."""
2
+
3
+ import logging
4
+ from typing import Any
5
+
6
+ from trame.app import get_server
7
+ from trame.widgets import vuetify3 as vuetify
8
+
9
+ logger = logging.getLogger(__name__)
10
+ logger.setLevel(logging.INFO)
11
+
12
+
13
+ class ExitButton:
14
+ """Exit button for Trame Applications."""
15
+
16
+ def __init__(self, exit_callback: Any = None, job_status_callback: Any = None) -> None:
17
+ self.server = get_server(None, client_type="vue3")
18
+ self.server.state.nova_kill_jobs_on_exit = False
19
+ self.server.state.nova_show_exit_dialog = False
20
+ self.server.state.nova_show_stop_jobs_on_exit_checkbox = False
21
+ self.server.state.nova_running_jobs = []
22
+ self.server.state.nova_show_exit_progress = False
23
+ self.exit_application_callback = exit_callback
24
+ self.job_status_callback = job_status_callback
25
+ self.create_ui()
26
+
27
+ def create_ui(self) -> None:
28
+ with vuetify.VBtn(
29
+ "Exit",
30
+ prepend_icon="mdi-close-box",
31
+ classes="mr-4 bg-error",
32
+ id="shutdown_app_theme_button",
33
+ color="white",
34
+ click=self.open_exit_dialog,
35
+ ):
36
+ with vuetify.VDialog(v_model="nova_show_exit_dialog", persistent="true"):
37
+ with vuetify.VCard(classes="pa-4 ma-auto"):
38
+ vuetify.VCardTitle("Exit Application")
39
+ with vuetify.VCardText(
40
+ "Are you sure you want to exit this application?",
41
+ variant="outlined",
42
+ ):
43
+ vuetify.VCheckbox(
44
+ v_model="nova_kill_jobs_on_exit",
45
+ label="Stop All Jobs On Exit.",
46
+ v_if="nova_running_jobs.length > 0",
47
+ )
48
+ with vuetify.VList():
49
+ vuetify.VListSubheader("Running Jobs:", v_if="nova_running_jobs.length > 0")
50
+ vuetify.VListItem("{{ item }}", v_for="(item, index) in nova_running_jobs")
51
+ with vuetify.VCardActions(v_if="!nova_show_exit_progress"):
52
+ vuetify.VBtn(
53
+ "Exit App",
54
+ click=self.exit_application_callback,
55
+ color="error",
56
+ )
57
+ vuetify.VBtn(
58
+ "Stay In App",
59
+ click=self.close_exit_dialog,
60
+ )
61
+ with vuetify.VCardActions(v_else=True):
62
+ vuetify.VCardText(
63
+ "Exiting Application...",
64
+ variant="outlined",
65
+ )
66
+ vuetify.VProgressCircular(indeterminate=True)
67
+
68
+ async def open_exit_dialog(self) -> None:
69
+ self.server.state.nova_show_exit_dialog = True
70
+ await self.job_status_callback()
71
+
72
+ async def close_exit_dialog(self) -> None:
73
+ self.server.state.nova_show_exit_dialog = False
@@ -1,12 +1,15 @@
1
1
  """Implementation of ThemedApp."""
2
2
 
3
+ import asyncio
3
4
  import json
4
5
  import logging
6
+ import sys
5
7
  from asyncio import create_task
6
8
  from functools import partial
7
9
  from pathlib import Path
8
10
  from typing import Optional
9
11
 
12
+ import blinker
10
13
  import sass
11
14
  from mergedeep import Strategy, merge
12
15
  from trame.app import get_server
@@ -18,7 +21,9 @@ from trame_client.widgets import html
18
21
  from trame_server.core import Server
19
22
  from trame_server.state import State
20
23
 
24
+ from nova.common.signals import Signal
21
25
  from nova.mvvm.pydantic_utils import validate_pydantic_parameter
26
+ from nova.trame.view.theme.exit_button import ExitButton
22
27
  from nova.trame.view.utilities.local_storage import LocalStorageManager
23
28
 
24
29
  THEME_PATH = Path(__file__).parent
@@ -138,6 +143,29 @@ class ThemedApp:
138
143
  async def init_theme(self) -> None:
139
144
  create_task(self._init_theme())
140
145
 
146
+ async def get_jobs_callback(self) -> None:
147
+ get_tools_signal = blinker.signal(Signal.GET_ALL_TOOLS)
148
+ response = get_tools_signal.send()
149
+ if response and len(response[0]) > 1: # Make sure that the callback had a return value
150
+ try:
151
+ self.server.state.nova_running_jobs = [tool.id for tool in response[0][1]]
152
+ if len(self.server.state.nova_running_jobs) > 0:
153
+ self.server.state.nova_show_stop_jobs_on_exit_checkbox = True
154
+ self.server.state.nova_kill_jobs_on_exit = True
155
+ else:
156
+ self.server.state.nova_show_stop_jobs_on_exit_checkbox = False
157
+ except Exception as e:
158
+ logger.warning(f"Issue getting running jobs: {e}")
159
+
160
+ async def exit_callback(self) -> None:
161
+ logger.info(f"Closing App. Killing jobs: {self.server.state.nova_kill_jobs_on_exit}")
162
+ if self.server.state.nova_kill_jobs_on_exit:
163
+ self.server.state.nova_show_exit_progress = True
164
+ await asyncio.sleep(2)
165
+ stop_signal = blinker.signal(Signal.EXIT_SIGNAL)
166
+ stop_signal.send()
167
+ sys.exit(0)
168
+
141
169
  def set_theme(self, theme: Optional[str], force: bool = True) -> None:
142
170
  """Sets the theme of the application.
143
171
 
@@ -227,6 +255,7 @@ class ThemedApp:
227
255
  "Selected",
228
256
  v_if=f"nova__theme === '{theme['value']}'",
229
257
  )
258
+ ExitButton(self.exit_callback, self.get_jobs_callback)
230
259
 
231
260
  with vuetify.VMain(classes="align-stretch d-flex flex-column h-screen"):
232
261
  # [slot override example]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: nova-trame
3
- Version: 0.22.0
3
+ Version: 0.22.1
4
4
  Summary: A Python Package for injecting curated themes and custom components into Trame applications
5
5
  License: MIT
6
6
  Keywords: NDIP,Python,Trame,Vuetify
@@ -18,7 +18,7 @@ Requires-Dist: blinker (>=1.9.0,<2.0.0)
18
18
  Requires-Dist: libsass
19
19
  Requires-Dist: mergedeep
20
20
  Requires-Dist: natsort (>=8.4.0,<9.0.0)
21
- Requires-Dist: nova-common (>=0.2.0)
21
+ Requires-Dist: nova-common (>=0.2.2)
22
22
  Requires-Dist: nova-mvvm
23
23
  Requires-Dist: pydantic
24
24
  Requires-Dist: tomli
@@ -43,7 +43,7 @@ You can install this package directly with
43
43
  pip install nova-trame
44
44
  ```
45
45
 
46
- A user guide, examples, and a full API for this package can be found at https://nova-application-development.readthedocs.io/en/stable/.
46
+ A user guide, examples, and a full API for this package can be found at [https://nova-application-development.readthedocs.io/en/stable/](https://nova-application-development.readthedocs.io/projects/nova-trame/en/stable/).
47
47
 
48
48
  Developers: please read [this document](DEVELOPMENT.md)
49
49
 
@@ -25,15 +25,16 @@ nova/trame/view/theme/assets/js/delay_manager.js,sha256=mRV6KoO8-Bxq3tG5Bh9CQYy-
25
25
  nova/trame/view/theme/assets/js/lodash.min.js,sha256=KCyAYJ-fsqtp_HMwbjhy6IKjlA5lrVrtWt1JdMsC57k,73016
26
26
  nova/trame/view/theme/assets/js/revo_grid.js,sha256=WBsmoslu9qI5DHZkHkJam2AVgdiBp6szfOSV8a9cA5Q,3579
27
27
  nova/trame/view/theme/assets/vuetify_config.json,sha256=a0FSgpLYWGFlRGSMhMq61MyDFBEBwvz55G4qjkM08cs,5627
28
- nova/trame/view/theme/theme.py,sha256=0KzBJgAZRwlnwzCIf7gUjDY-gbhON7b2h3CMh2_9HY4,11746
28
+ nova/trame/view/theme/exit_button.py,sha256=Kqv1GVJZGrSsj6_JFjGU3vm3iNuMolLC2T1x2IsdmV0,3094
29
+ nova/trame/view/theme/theme.py,sha256=8JqSrEbhxK1SccXE1_jUdel9Wtc2QNObVEwtbVWG_QY,13146
29
30
  nova/trame/view/utilities/local_storage.py,sha256=vD8f2VZIpxhIKjZwEaD7siiPCTZO4cw9AfhwdawwYLY,3218
30
31
  nova/trame/view_model/data_selector.py,sha256=RyMHml1K_pupH4JtXnGxAaYTYYwNoEVus7Abdpqwueo,3698
31
32
  nova/trame/view_model/execution_buttons.py,sha256=MfKSp95D92EqpD48C15cBo6dLO0Yld4FeRZMJNxJf7Y,3551
32
33
  nova/trame/view_model/progress_bar.py,sha256=6AUKHF3hfzbdsHqNEnmHRgDcBKY5TT8ywDx9S6ovnsc,2854
33
34
  nova/trame/view_model/remote_file_input.py,sha256=ojEOJ8ZPkajpbAaZi9VLj7g-uBjhb8BMrTdMmwf_J6A,3367
34
35
  nova/trame/view_model/tool_outputs.py,sha256=ev6LY7fJ0H2xAJn9f5ww28c8Kpom2SYc2FbvFcoN4zg,829
35
- nova_trame-0.22.0.dist-info/LICENSE,sha256=Iu5QiDbwNbREg75iYaxIJ_V-zppuv4QFuBhAW-qiAlM,1061
36
- nova_trame-0.22.0.dist-info/METADATA,sha256=7ySWYYUkEE99UeZnMvMMwskNWHHhHjrrNv0_5dYRU0s,1603
37
- nova_trame-0.22.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
38
- nova_trame-0.22.0.dist-info/entry_points.txt,sha256=J2AmeSwiTYZ4ZqHHp9HO6v4MaYQTTBPbNh6WtoqOT58,42
39
- nova_trame-0.22.0.dist-info/RECORD,,
36
+ nova_trame-0.22.1.dist-info/LICENSE,sha256=Iu5QiDbwNbREg75iYaxIJ_V-zppuv4QFuBhAW-qiAlM,1061
37
+ nova_trame-0.22.1.dist-info/METADATA,sha256=A-wOqVcFQXeV1qpuPJv253RugeWK5j2UryAUYdwgtII,1689
38
+ nova_trame-0.22.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
39
+ nova_trame-0.22.1.dist-info/entry_points.txt,sha256=J2AmeSwiTYZ4ZqHHp9HO6v4MaYQTTBPbNh6WtoqOT58,42
40
+ nova_trame-0.22.1.dist-info/RECORD,,