Skip to content

Commit 1dc94cf

Browse files
Always load a token from the environment when on TileDB Cloud (#55)
* always load token * update to 1.0.1 * Height and width in pixels * update to viz-core 1.0.2-alpha.1 * update to viz-core 1.0.2-alpha.2
1 parent 789cc49 commit 1dc94cf

File tree

4 files changed

+33
-18
lines changed

4 files changed

+33
-18
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"dependencies": {
5959
"@jupyter-widgets/base": "^1.1.10 || ^2 || ^3 || ^4",
6060
"@jupyterlab/application": "^3.4.5",
61-
"@tiledb-inc/viz-core": "1.0.0"
61+
"@tiledb-inc/viz-core": "^1.0.2-alpha.2"
6262
},
6363
"devDependencies": {
6464
"@jupyterlab/builder": "^3.1.0",

pybabylonjs/args.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
}
4848

4949

50-
def check_point_cloud_args(mode, point_cloud_args_in):
50+
def check_point_cloud_args(source, mode, point_cloud_args_in):
5151
if mode == "time":
5252
raise ValueError("This mode will be implemented soon")
5353
if mode == "classes":
@@ -73,9 +73,30 @@ def check_point_cloud_args(mode, point_cloud_args_in):
7373
if key is not None:
7474
point_cloud_args[key] = point_cloud_args_in.pop(key)
7575

76-
if not "height" in point_cloud_args:
77-
point_cloud_args["height"] = 600
78-
point_cloud_args["width"] = 800
76+
def in_pixels(h, default):
77+
if h is None:
78+
return default
79+
if isinstance(h, str):
80+
if "px" in h:
81+
return h
82+
return h + "px"
83+
if isinstance(h, int):
84+
return str(h) + "px"
85+
if isinstance(h, float):
86+
return str(int(h)) + "px"
87+
88+
point_cloud_args["height"] = in_pixels(point_cloud_args.get("height"), "500px")
89+
point_cloud_args["width"] = in_pixels(point_cloud_args.get("width"), "700px")
90+
91+
if not "token" in point_cloud_args:
92+
try:
93+
token = os.getenv("TILEDB_REST_TOKEN")
94+
except:
95+
if source == "cloud" & token == None:
96+
raise ValueError(
97+
"The TileDB Cloud token needed to access the array is not specified or cannot be accessed"
98+
)
99+
point_cloud_args = {**point_cloud_args, "token": token}
79100

80101
return point_cloud_args
81102

@@ -121,14 +142,6 @@ def check_point_cloud_data_local(mode, uri, point_cloud_args):
121142

122143

123144
def check_point_cloud_data_cloud(streaming, uri, point_cloud_args):
124-
if not "token" in point_cloud_args:
125-
token = os.getenv("TILEDB_REST_TOKEN")
126-
if token == None:
127-
raise ValueError(
128-
"The TileDB Cloud token needed to access the array is not specified or cannot be accessed"
129-
)
130-
point_cloud_args = {**point_cloud_args, "token": token}
131-
132145
o = urlparse(uri)
133146

134147
if not streaming:

pybabylonjs/show.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ def point_cloud(
6060
streaming, uri, point_cloud_args_in
6161
)
6262

63-
point_cloud_args = check_point_cloud_args(mode, point_cloud_args_in)
63+
point_cloud_args = check_point_cloud_args(
64+
source, streaming, point_cloud_args_in
65+
)
6466

6567
d = {
6668
**point_cloud_args,

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -806,10 +806,10 @@
806806
paralleljs "github:SarantopoulosKon/parallel.js#node-mode-in-web-worker"
807807
save-file "^2.3.1"
808808

809-
"@tiledb-inc/[email protected].0":
810-
version "1.0.0"
811-
resolved "https://registry.yarnpkg.com/@tiledb-inc/viz-core/-/viz-core-1.0.0.tgz#62bf814aeba300a2ad15b327d7b0b22aba3f9720"
812-
integrity sha512-BPShN0I88R6O8Ca0VRK7ER0C/OkJwyEaRfgGYd6ElsdaGxRVM4t8ogQple1+073C3veRdrrAFzcmnkg3+3kGtA==
809+
"@tiledb-inc/viz-core@^1.0.2-alpha.2":
810+
version "1.0.2-alpha.2"
811+
resolved "https://registry.yarnpkg.com/@tiledb-inc/viz-core/-/viz-core-1.0.2-alpha.2.tgz#9f22b591f801cbe1e44a5cba85fbce40e69aea96"
812+
integrity sha512-zC4IdCnuGi2UhuHZdPqY3WVbM9vQ8j4/fVzsqy6u+EnDJcV0vBcg1hVKw0k4tOxtcALbufKKnFR26LnGrAYLaA==
813813
dependencies:
814814
"@babylonjs/core" "^5.42.0"
815815
"@babylonjs/gui" "^5.42.0"

0 commit comments

Comments
 (0)