caterva2.lazyexpr#
- caterva2.lazyexpr(name, expression, operands, urlbase=None, auth_cookie=None)#
Creates a lazy expression dataset in personal space.
A dataset with the specified name will be created or overwritten if already exists.
- Parameters:
name¶ (str) – Name of the dataset to be created (without extension).
expression¶ (str) – Expression to be evaluated, which must yield a lazy expression.
operands¶ (dict) – Mapping of variables in the expression to their corresponding dataset paths.
urlbase¶ (str, optional) – Base URL to query. Default to
caterva2.sub_urlbase_default
.auth_cookie¶ (str, optional) – HTTP cookie for authorization. Must be provided unless specified in a :py_obj:`caterva2.c2context`.
- Returns:
Path of the created dataset.
- Return type:
Path
Examples
>>> import caterva2 as cat2 >>> import numpy as np >>> # To create a lazyexpr you need to be a registered used >>> urlbase = 'https://cat2.cloud/demo' >>> auth_cookie = cat2.get_auth_cookie(urlbase, dict(username='user@example.com', password='foo')) >>> src_path = f'@personal/dir{np.random.randint(0, 100)}/ds-4d.b2nd' >>> path = cat2.upload('root-example/dir1/ds-2d.b2nd', src_path, urlbase, auth_cookie) >>> cat2.lazyexpr('example-expr', 'a + a', {'a': path}, urlbase, auth_cookie) PosixPath('@personal/example-expr.b2nd') >>> 'example-expr.b2nd' in cat2.get_list('@personal', urlbase, auth_cookie) True