darabos commited on
Commit
44a2d59
·
1 Parent(s): 408ef2b

Move Pandas import from lynxkite-app to lynxkite-graph-analytics.

Browse files
lynxkite-app/src/lynxkite_app/main.py CHANGED
@@ -1,11 +1,9 @@
1
  """The FastAPI server for serving the LynxKite application."""
2
 
3
- import os
4
  import shutil
5
  import pydantic
6
  import fastapi
7
  import importlib
8
- import pandas as pd
9
  import pathlib
10
  import pkgutil
11
  from fastapi.staticfiles import StaticFiles
@@ -14,13 +12,6 @@ from lynxkite.core import ops
14
  from lynxkite.core import workspace
15
  from . import crdt, config
16
 
17
- if os.environ.get("NX_CUGRAPH_AUTOCONFIG", "").strip().lower() == "true":
18
- import cudf.pandas
19
-
20
- cudf.pandas.install()
21
-
22
- pd.options.mode.copy_on_write = True # Prepare for Pandas 3.0.
23
-
24
 
25
  def detect_plugins():
26
  plugins = {}
 
1
  """The FastAPI server for serving the LynxKite application."""
2
 
 
3
  import shutil
4
  import pydantic
5
  import fastapi
6
  import importlib
 
7
  import pathlib
8
  import pkgutil
9
  from fastapi.staticfiles import StaticFiles
 
12
  from lynxkite.core import workspace
13
  from . import crdt, config
14
 
 
 
 
 
 
 
 
15
 
16
  def detect_plugins():
17
  plugins = {}
lynxkite-core/src/lynxkite/core/workspace.py CHANGED
@@ -42,10 +42,14 @@ class WorkspaceNode(BaseConfig):
42
 
43
  def publish_result(self, result: ops.Result):
44
  """Sends the result to the frontend. Call this in an executor when the result is available."""
45
- with self._crdt.doc.transaction():
46
- self._crdt["data"]["display"] = result.display
47
- self._crdt["data"]["error"] = result.error
48
- self._crdt["data"]["in_progress"] = False
 
 
 
 
49
 
50
  def publish_error(self, error: Exception | str):
51
  self.publish_result(ops.Result(error=str(error)))
 
42
 
43
  def publish_result(self, result: ops.Result):
44
  """Sends the result to the frontend. Call this in an executor when the result is available."""
45
+ self.data.display = result.display
46
+ self.data.error = result.error
47
+ self.data.in_progress = False
48
+ if hasattr(self, "_crdt"):
49
+ with self._crdt.doc.transaction():
50
+ self._crdt["data"]["display"] = result.display
51
+ self._crdt["data"]["error"] = result.error
52
+ self._crdt["data"]["in_progress"] = False
53
 
54
  def publish_error(self, error: Exception | str):
55
  self.publish_result(ops.Result(error=str(error)))
lynxkite-graph-analytics/src/lynxkite_graph_analytics/__init__.py CHANGED
@@ -1,3 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
  from .core import * # noqa (easier access for core classes)
2
  from . import lynxkite_ops # noqa (imported to trigger registration)
3
  from . import networkx_ops # noqa (imported to trigger registration)
 
1
+ """Graph analytics environment for LynxKite. The core types and functions are imported here for easy access."""
2
+
3
+ import os
4
+ import pandas as pd
5
+
6
+ if os.environ.get("NX_CUGRAPH_AUTOCONFIG", "").strip().lower() == "true":
7
+ import cudf.pandas
8
+
9
+ cudf.pandas.install()
10
+
11
+ pd.options.mode.copy_on_write = True # Prepare for Pandas 3.0.
12
+
13
  from .core import * # noqa (easier access for core classes)
14
  from . import lynxkite_ops # noqa (imported to trigger registration)
15
  from . import networkx_ops # noqa (imported to trigger registration)