Skip to content

Commit

Permalink
feat(vue3): vue3 client is the new default
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Jan 1, 2024
1 parent 32dcdda commit 35013f4
Showing 1 changed file with 2 additions and 60 deletions.
62 changes: 2 additions & 60 deletions trame/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import logging
from trame_server import Server, Client
from trame_server.core import set_default_client_type, DEFAULT_CLIENT_TYPE
from trame_server.core import set_default_client_type
from trame_client.widgets.core import VirtualNode

# Ensure this is imported so that mimetypes.init() is decorated
Expand All @@ -13,61 +12,7 @@

logger = logging.getLogger(__name__)


def trame_3_warning(*args, **kwargs):
if os.environ.get("TRAME_DISABLE_V3_WARNING", 0):
return

logger.warning("")
logger.warning("-" * 80)
logger.warning(
" !!! You are currently using trame@3 which may break your application !!!"
)
logger.warning("-" * 80)
logger.warning(
"\n 1. trame@3 only provides by default trame.widgets.[html,client] and remove"
"\n everything else as implicit dependency. Those other widgets will still"
"\n exist and will be supported, but they will need to be defined as a"
"\n dependency of your application."
"\n"
"\n $ pip install trame-vtk trame-vuetify trame-plotly"
"\n"
"\n Import paths are remaining the same."
"\n"
"\n For libraries like vuetify since they offer different API between"
"\n their vue2 and vue3 implementation, the widget name will reflect"
"\n which vue version they are referencing. But original naming will remain."
"\n"
"\n from trame.widgets import vuetify2, vuetify3"
"\n\n"
"\n 2. trame@3 aims to use vue3 as a new default. But to smooth the transition"
"\n we will maintain the server.client_type = 'vue2' default until"
"\n December 2023 which is the vue2 EOL."
"\n"
"\n After that time, the new default will be switched to 'vue3'."
"\n Vue2 will still work 'forever' and many of the new widgets will be"
"\n written to support both versions."
"\n"
"\n If you have a 'vue2' application and don't need or want to update your code,"
"\n you can still use trame@3 with vue2 by setting `server.client_type='vue2'."
"\n"
"\n Actions items"
"\n ~~~~~~~~~~~~~"
"\n a. Make sure you set `server.client_type` to either 'vue2' or 'vue3'."
"\n b. List the expected dependencies or have a 'trame<3' dependency"
"\n"
)
logger.warning("-" * 80)
logger.warning(f" => Current client_type default: {DEFAULT_CLIENT_TYPE}")
logger.warning("-" * 80)
logger.warning("")


# ---------------------------------------------------------
# After December 2023 we will switch to vue3
# ---------------------------------------------------------
set_default_client_type("vue2")
# ---------------------------------------------------------
set_default_client_type("vue3")


def apply_client_type(server, client_type=None):
Expand Down Expand Up @@ -100,9 +45,6 @@ def get_server(name=None, create_if_missing=True, client_type=None, **kwargs):
:return: Return a unique Server instance per given name.
:rtype: trame_server.core.Server
"""
if client_type is None:
trame_3_warning()

# Convenient method for decorator like usage
if isinstance(name, Server):
return apply_client_type(name, client_type)
Expand Down

0 comments on commit 35013f4

Please sign in to comment.