caterva2.lazyexpr#
- caterva2.lazyexpr(name, expression, operands, urlbase=None, auth_cookie=None)#
Create a lazy expression dataset in personal space.
A dataset with the given name is created anew (or overwritten if already existing).
- Parameters:
name¶ (str) – The name of the dataset to be created (without extension).
expression¶ (str) – The expression to be evaluated. It must result in a lazy expression.
operands¶ (dict) – A mapping of the variables used in the expression to the dataset paths that they refer to.
urlbase¶ (str) – The base of URLs of the subscriber to query. Default is
caterva2.sub_urlbase_default
.auth_cookie¶ (str) – An HTTP cookie for authorizing access. This must be specified unless it was already specified inside a :py_obj:`caterva2.c2context`.
- Returns:
The 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=urlbase, auth_cookie=auth_cookie) >>> cat2.lazyexpr('example-expr', 'a + a', {'a': path}, urlbase=urlbase, auth_cookie=auth_cookie) PosixPath('@personal/example-expr.b2nd') >>> 'example-expr.b2nd' in cat2.get_list('@personal', urlbase, auth_cookie) True