Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More performant plotting for simple plot types #904

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
a035269
big refactor
39bytes Sep 22, 2023
62502bc
basic scatter working
39bytes Sep 22, 2023
a40cb1b
basic plot working for scatter
39bytes Sep 25, 2023
9ee52dd
trying things
39bytes Sep 26, 2023
8935ad1
trying points
39bytes Sep 26, 2023
63be4bb
wip
39bytes Sep 28, 2023
0b5ce5b
big refactor
39bytes Sep 28, 2023
bf8cf9c
a mess
39bytes Sep 28, 2023
bb5af4b
incremental updates
39bytes Sep 29, 2023
c2beb96
back to stateless
39bytes Oct 2, 2023
b1ac17e
Merge branch 'develop' into jeff/stu-143-more-performant-plotting-for…
39bytes Oct 2, 2023
3509fa1
refactor
39bytes Oct 2, 2023
54681d2
camera partial refactor
39bytes Oct 2, 2023
4e00a41
more refactor
39bytes Oct 3, 2023
a80aea7
remove unused fields
39bytes Oct 3, 2023
a2c8184
more refactoring
39bytes Oct 3, 2023
8ae975d
panning kinda works
39bytes Oct 4, 2023
899c03e
more refactor
39bytes Oct 4, 2023
a0554d4
tweaks
39bytes Oct 6, 2023
f412ae7
panning works properly now
39bytes Oct 6, 2023
759e986
better panning
39bytes Oct 6, 2023
3b87296
remove unused function
39bytes Oct 6, 2023
f6e7145
plot cleanup functions
39bytes Oct 10, 2023
8d465ab
make ctrl update immutable
39bytes Oct 10, 2023
0139864
more configurable scatter3d
39bytes Oct 10, 2023
fce568d
more configurability
39bytes Oct 11, 2023
7b92841
Merge branch 'develop' into jeff/stu-143-more-performant-plotting-for…
39bytes Oct 18, 2023
cf2f8bb
fix up plot lib
39bytes Oct 18, 2023
13e0197
add scientific notation to big number
39bytes Oct 18, 2023
49a3d78
submodule
39bytes Oct 18, 2023
3f14e8c
submodule
39bytes Oct 18, 2023
e922eb0
submodule
39bytes Oct 18, 2023
d37d455
Merge branch 'develop' into jeff/stu-143-more-performant-plotting-for…
39bytes Oct 18, 2023
11ddd5a
format
39bytes Oct 18, 2023
d532933
fix memory leak
39bytes Oct 19, 2023
6e2d7d7
add packages
39bytes Oct 19, 2023
9c07990
camera adjustments
39bytes Oct 19, 2023
0195240
point color fixes
39bytes Oct 19, 2023
59edb6d
Merge branch 'develop' into jeff/stu-143-more-performant-plotting-for…
39bytes Oct 20, 2023
a6e974e
fix key error
39bytes Oct 20, 2023
c812249
add text color to theme
39bytes Oct 20, 2023
7a3bdf5
logging
39bytes Oct 20, 2023
e4648dc
use orjson instead for serialization
39bytes Oct 20, 2023
15e7dbd
fix shadow
39bytes Oct 20, 2023
4cced6c
key error fix
39bytes Oct 20, 2023
238e7fc
adjust camera motion multipliers
39bytes Oct 24, 2023
74b826d
bump version
39bytes Oct 24, 2023
eda35ed
bump packages
39bytes Oct 24, 2023
e9aa732
Some logging
39bytes Oct 25, 2023
674e30f
Merge branch 'main' into jeff/stu-143-more-performant-plotting-for-si…
39bytes Nov 7, 2023
1f6229a
fix manifest error
39bytes Nov 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions captain/internal/wsmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from flojoy import PlotlyJSONEncoder
from queue import Queue
from typing import Any, Union
import json
import orjson
from captain.types.worker import WorkerJobResponse
import threading
import traceback
Expand Down Expand Up @@ -44,7 +44,8 @@ async def disconnect(self, socket_id: str):
del self.active_connections_map[socket_id]

# this method sends a message to all connected websockets
async def broadcast(self, message: Union[dict[str, Any], WorkerJobResponse]):
async def broadcast(self, message: Union[dict[str, Any],
WorkerJobResponse]):
if not isinstance(message, WorkerJobResponse):
return

Expand All @@ -56,9 +57,9 @@ async def broadcast(self, message: Union[dict[str, Any], WorkerJobResponse]):
continue

try:
await connection.send_text(
json.dumps(message, cls=PlotlyJSONEncoder)
)
await connection.send_bytes(
orjson.dumps(message,
option=orjson.OPT_SERIALIZE_NUMPY))
except Exception as e:
print(
f"Error in broadcast to {id}",
Expand Down
3 changes: 3 additions & 0 deletions captain/utils/manifest/generate_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

NAME_MAP = {
"AI_ML": "AI & ML",
"COMPUTER_VISION": "Computer Vision",
"DATA": "Data",
"DSP": "Digital Signal Processing",
"IMAGE": "Image",
Expand All @@ -29,6 +30,7 @@
# A node will inherit the type of its parent if it is not in the allowed types.
ALLOWED_TYPES = [
"AI_ML",
"COMPUTER_VISION",
"DATA",
"VISUALIZATION",
"MATH",
Expand All @@ -53,6 +55,7 @@
"ETL",
"DSP",
"IMAGE",
"COMPUTER_VISION",
"CONTROL_FLOW",
"HARDWARE",
"DSP",
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@radix-ui/react-tooltip": "^1.0.7",
"@tisoap/react-flow-smart-edge": "file:bauhaus/tisoap-react-flow-smart-edge-v3.0.0.tgz",
"axios": "^1.5.1",
"candygraph": "^0.10.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"cmdk": "^0.2.0",
Expand All @@ -37,6 +38,7 @@
"express": "^4.18.2",
"file-saver": "^2.0.5",
"framer-motion": "^10.16.4",
"gl-matrix": "^3.4.3",
"html-to-image": "^1.11.11",
"http-proxy-middleware": "^2.0.6",
"immer": "^10.0.3",
Expand All @@ -63,6 +65,7 @@
"react-syntax-highlighter": "^15.5.0",
"react-tabs": "^6.0.2",
"react-use": "^17.4.0",
"regl": "^2.1.0",
"reactflow": "^11.9.4",
"sonner": "^1.0.3",
"tailwind-merge": "^1.14.0",
Expand Down
1 change: 1 addition & 0 deletions pkgs/flojoy/flojoy/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ def flojoy(
deps: Optional[dict[str, str]] = None,
inject_node_metadata: bool = False,
inject_connection: bool = False,
forward_result: bool = False
) -> Callable[..., DataContainer | dict[str, Any] | None]: ...
3 changes: 2 additions & 1 deletion pkgs/flojoy/flojoy/flojoy_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def flojoy(
deps: Optional[dict[str, str]] = None,
inject_node_metadata: bool = False,
inject_connection: bool = False,
forward_result: bool = False,
):
"""
Decorator to turn Python functions with numerical return
Expand Down Expand Up @@ -251,7 +252,7 @@ def wrapper(

# Package the result and return it
FN = func.__name__
result = get_frontend_res_obj_from_result(dc_obj)
result = get_frontend_res_obj_from_result(dc_obj, forward_result)
return JobSuccess(
result=result,
fn=FN,
Expand Down
10 changes: 8 additions & 2 deletions pkgs/flojoy/flojoy/job_result_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@ def get_text_blob_from_dc(dc: DataContainer) -> str | None:


def get_frontend_res_obj_from_result(
result: Optional[dict[str, Any] | DataContainer]
result: Optional[dict[str, Any] | DataContainer], forward_result: bool = False
) -> Optional[dict[str, Any]]:
if result is None:
return None

if forward_result:
if isinstance(result, DataContainer):
return {"data": result}

# Only return a plotly fig if it is a viz node
match result:
case Plotly() | TextBlob() | Bytes():
Expand Down Expand Up @@ -107,4 +111,6 @@ def get_frontend_res_obj_from_result(
"text_blob": text_blob,
}
keys = list(result.keys())
return get_frontend_res_obj_from_result(result[keys[0]])
return get_frontend_res_obj_from_result(
result[keys[0]],
)
3 changes: 1 addition & 2 deletions pkgs/flojoy/flojoy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import base64
from .CONSTANTS import FLOJOY_DIR, FLOJOY_CACHE_DIR, CREDENTIAL_FILE


__all__ = [
"get_env_var",
"set_env_var",
Expand All @@ -36,7 +35,6 @@
"clear_flojoy_memory",
]


# # package result
# def package_result(result: dict | None, fn: str, node_id: str, jobset_id: str) -> dict:
# return {
Expand All @@ -55,6 +53,7 @@
# "FAILED_NODES": {node_id: str(error)},
# "jobsetId": jobset_id,
# }
#


# Make as a function to mock at test-time
Expand Down
2 changes: 1 addition & 1 deletion pkgs/flojoy/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = [
"Dallas Strandell <dalstrande@outlook.com>",
]
name = "flojoy"
version = "0.1.16"
version = "0.1.17"
description = ""
readme = "README.md"

Expand Down
Loading
Loading