diff --git a/Integrations/python/setup.py b/Integrations/python/setup.py index e8452fb644b..8b6bf1422bb 100644 --- a/Integrations/python/setup.py +++ b/Integrations/python/setup.py @@ -53,6 +53,11 @@ def normalize_version(ver): keywords='Deephaven Development', packages=find_packages(exclude=['docs', 'test']), install_requires=['deephaven-jpy=={}'.format(__normalized_version__), - 'numpy', 'dill>=0.2.8', 'wrapt', 'pandas', 'numba;python_version>"3.0"', - 'enum34;python_version<"3.4"'], + 'numpy', + 'dill>=0.2.8', + 'wrapt', + 'pandas', + 'numba;python_version>"3.0"', + 'enum34;python_version<"3.4"', + ], ) diff --git a/py/server/deephaven/pandasplugin/__init__.py b/py/server/deephaven/pandasplugin/__init__.py new file mode 100644 index 00000000000..f1e1cb856d8 --- /dev/null +++ b/py/server/deephaven/pandasplugin/__init__.py @@ -0,0 +1,7 @@ +from deephaven.plugin import Registration +from . import pandas_as_table + +class PandasPluginRegistration(Registration): + @classmethod + def register_into(clscls, callback: Registration.Callback) -> None: + callback.register(pandas_as_table.PandasDataFrameSerializer) diff --git a/py/server/deephaven/pandasplugin/pandas_as_table.py b/py/server/deephaven/pandasplugin/pandas_as_table.py new file mode 100644 index 00000000000..a84f00f849b --- /dev/null +++ b/py/server/deephaven/pandasplugin/pandas_as_table.py @@ -0,0 +1,18 @@ +from deephaven.pandas import to_table +from deephaven.plugin.object import Exporter, ObjectType +from pandas import DataFrame + +NAME = "pandas.DataFrame" + + +class PandasDataFrameSerializer(ObjectType): + @property + def name(self) -> str: + return NAME + + def is_type(self, object) -> bool: + return isinstance(object, DataFrame) + + def to_bytes(self, exporter: Exporter, data_frame: DataFrame): + exporter.reference(to_table(data_frame)) + return b'' diff --git a/py/server/setup.py b/py/server/setup.py index 7015760b5fc..d0e40300e07 100644 --- a/py/server/setup.py +++ b/py/server/setup.py @@ -44,6 +44,15 @@ def normalize_version(version): ], keywords='Deephaven Development', install_requires=['deephaven-jpy=={}'.format(__normalized_version__), - 'numpy', 'dill>=0.2.8', 'wrapt', 'pandas', 'numba;python_version>"3.0"', - 'enum34;python_version<"3.4"'], + 'deephaven-plugin', + 'numpy', + 'dill>=0.2.8', + 'wrapt', + 'pandas', + 'numba;python_version>"3.0"', + 'enum34;python_version<"3.4"' + ], + entry_points={ + 'deephaven.plugin': ['registration_cls = deephaven.pandasplugin:PandasPluginRegistration'] + }, ) diff --git a/web/client-api/src/main/java/io/deephaven/ide/shared/IdeSession.java b/web/client-api/src/main/java/io/deephaven/ide/shared/IdeSession.java index 6f17b0f71f3..2f339f64661 100644 --- a/web/client-api/src/main/java/io/deephaven/ide/shared/IdeSession.java +++ b/web/client-api/src/main/java/io/deephaven/ide/shared/IdeSession.java @@ -103,7 +103,7 @@ public Promise getFigure(String name) { return getVariableDefinition(name, JsVariableChanges.FIGURE).then(connection::getFigure); } - public Promise getObject(JsPropertyMap definitionObject) { + public Promise getObject(JsPropertyMap definitionObject) { if (definitionObject instanceof JsVariableDefinition) { return connection.getObject((JsVariableDefinition) definitionObject); } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/WorkerConnection.java b/web/client-api/src/main/java/io/deephaven/web/client/api/WorkerConnection.java index b5c9b46275b..b5b15759409 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/WorkerConnection.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/WorkerConnection.java @@ -680,31 +680,16 @@ public Promise getTable(JsVariableDefinition varDef, @Nullable Boolean }); } - public Promise getPandas(JsVariableDefinition varDef) { - return whenServerReady("get a pandas table").then(serve -> { - JsLog.debug("innerGetPandasTable", varDef.getTitle(), " started"); - return newState(info, - (c, cts, metadata) -> { - JsLog.debug("performing fetch for ", varDef.getTitle(), " / ", cts, - " (" + LazyString.of(cts::getHandle), ")"); - throw new UnsupportedOperationException("getPandas"); - - }, "fetch pandas table " + varDef.getTitle()).then(cts -> { - JsLog.debug("innerGetPandasTable", varDef.getTitle(), " succeeded ", cts); - JsTable table = new JsTable(this, cts); - return Promise.resolve(table); - }); - }); - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - public Promise getObject(JsVariableDefinition definition) { - if (definition.getType().equals(JsVariableChanges.TABLE)) { - return (Promise) getTable(definition, null); - } else if (definition.getType().equals(JsVariableChanges.FIGURE)) { - return (Promise) getFigure(definition); + public Promise getObject(JsVariableDefinition definition) { + if (JsVariableChanges.TABLE.equals(definition.getType())) { + return getTable(definition, null); + } else if (JsVariableChanges.FIGURE.equals(definition.getType())) { + return getFigure(definition); + } else if (JsVariableChanges.PANDAS.equals(definition.getType())) { + return getWidget(definition) + .then(widget -> widget.getExportedObjects()[0].fetch()); } else { - return (Promise) getWidget(definition); + return getWidget(definition); } } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/console/JsVariableChanges.java b/web/client-api/src/main/java/io/deephaven/web/client/api/console/JsVariableChanges.java index 547d6e83f10..03aae4e6507 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/console/JsVariableChanges.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/console/JsVariableChanges.java @@ -14,7 +14,7 @@ public class JsVariableChanges { TABLEMAP = "TableMap", FIGURE = "Figure", OTHERWIDGET = "OtherWidget", - PANDAS = "Pandas"; + PANDAS = "pandas.DataFrame"; private final JsVariableDefinition[] created; private final JsVariableDefinition[] updated; diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/widget/JsWidgetExportedObject.java b/web/client-api/src/main/java/io/deephaven/web/client/api/widget/JsWidgetExportedObject.java index f784acfc727..a42f6c1b93f 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/widget/JsWidgetExportedObject.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/widget/JsWidgetExportedObject.java @@ -28,7 +28,7 @@ public String getType() { } @JsMethod - public Promise fetch() { + public Promise fetch() { if (getType().equals(JsVariableChanges.TABLE)) { return Callbacks.grpcUnaryPromise(c -> { connection.tableServiceClient().getExportedTableCreationResponse(ticket.getTicket(),