Skip to content

Commit 187933b

Browse files
committed
Remove warning and rename internal lazy to compute
1 parent 5f331c8 commit 187933b

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

caterva2/client.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import functools
22
import io
3-
import logging
43
import pathlib
54
import sys
65
from collections.abc import Sequence
@@ -1173,11 +1172,8 @@ def lazyexpr(self, name, expression, operands=None, compute=False):
11731172
if operands is not None:
11741173
operands = {k: str(v) for k, v in operands.items()}
11751174
else:
1176-
logging.warning(
1177-
"User has not provided operands for the LazyExpression. Proceeding with empty operands arg"
1178-
)
11791175
operands = {}
1180-
expr = {"name": name, "expression": expression, "operands": operands, "lazy": not compute}
1176+
expr = {"name": name, "expression": expression, "operands": operands, "compute": compute}
11811177
dataset = api_utils.post(f"{self.urlbase}/api/lazyexpr/", expr, auth_cookie=self.cookie)
11821178
return pathlib.PurePosixPath(dataset)
11831179

caterva2/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class NewLazyExpr(pydantic.BaseModel):
6565
name: str
6666
expression: str
6767
operands: dict[str, str]
68-
lazy: bool
68+
compute: bool
6969

7070

7171
class MoveCopyPayload(pydantic.BaseModel):

caterva2/services/sub.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ async def get_chunk(
878878
return responses.StreamingResponse(downloader)
879879

880880

881-
def make_expr(name: str, expr: str, operands: dict[str, str], user: db.User, lazy: bool = True) -> str:
881+
def make_expr(name: str, expr: str, operands: dict[str, str], user: db.User, compute: bool = False) -> str:
882882
"""
883883
Create a lazy expression dataset in personal space.
884884
@@ -938,10 +938,10 @@ def make_expr(name: str, expr: str, operands: dict[str, str], user: db.User, laz
938938
path = settings.personal / str(user.id)
939939
path.mkdir(exist_ok=True, parents=True)
940940
urlpath = f"{path / name}.b2nd"
941-
if lazy:
942-
arr.save(urlpath=urlpath, mode="w")
943-
else:
941+
if compute:
944942
arr.compute(urlpath=urlpath, mode="w")
943+
else:
944+
arr.save(urlpath=urlpath, mode="w")
945945

946946
return f"@personal/{name}.b2nd"
947947

@@ -969,7 +969,7 @@ def error(msg):
969969
return fastapi.HTTPException(status_code=400, detail=msg) # bad request
970970

971971
try:
972-
result_path = make_expr(expr.name, expr.expression, expr.operands, user, expr.lazy)
972+
result_path = make_expr(expr.name, expr.expression, expr.operands, user, expr.compute)
973973
except (SyntaxError, ValueError, TypeError) as exc:
974974
raise error(f"Invalid name or expression: {exc}") from exc
975975
except KeyError as ke:
@@ -2069,10 +2069,10 @@ async def htmx_command(
20692069

20702070
elif nargs > 1 and argv[1] in {"=", ":="}:
20712071
operator = argv[1]
2072-
lazy = operator == "="
2072+
compute = operator == ":="
20732073
try:
20742074
result_name, expr = command.split(operator, maxsplit=1)
2075-
result_path = make_expr(result_name, expr, operands, user, lazy=lazy)
2075+
result_path = make_expr(result_name, expr, operands, user, compute=compute)
20762076
url = make_url(request, "html_home", path=result_path)
20772077
return htmx_redirect(hx_current_url, url)
20782078
except SyntaxError:

0 commit comments

Comments
 (0)