Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
154 changes: 0 additions & 154 deletions caterva2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,78 +533,6 @@ def copy(self, dst):
"""
return self.client.copy(self.path, dst)

def concat(self, srcs, dst, axis):
"""
Concatenate the file with srcs along axis to a new location dst.

Parameters
----------
srcs: list of Paths
Source files to be concatenated with current file
dst : Path
The destination path for the file.
axis: int
Axis along which to concatenate.

Returns
-------
Path
The new path of the concatenated file.

Examples
--------
>>> import caterva2 as cat2
>>> import numpy as np
>>> # For concatenating a file you need to be a registered user
>>> client = cat2.Client("https://cat2.cloud/demo", ("joedoe@example.com", "foobar"))
>>> root = client.get('@personal')
>>> root.upload('root-example/dir2/ds-4d.b2nd', "a.b2nd")
<Dataset: @personal/a.b2nd>
>>> root.upload('root-example/dir2/ds-4d.b2nd', "b.b2nd")
<Dataset: @personal/b.b2nd>
>>> file = root['a.b2nd']
>>> file.concat('@personal/b.b2nd', '@personal/c.b2nd', axis=0)
PurePosixPath('@personal/c.b2nd')
"""
srcs = [srcs] if not isinstance(srcs, list) else srcs # assure that srcs is list
return self.client.concat([self.path] + srcs, dst, axis)

def stack(self, srcs, dst, axis):
"""
Stack the file with srcs along new axis to a new location dst.

Parameters
----------
srcs: list of Paths
Source files to be stacked with current file
dst : Path
The destination path for the file.
axis: int
Axis along which to stack.

Returns
-------
Path
The new path of the stacked file.

Examples
--------
>>> import caterva2 as cat2
>>> import numpy as np
>>> # For stacking a file you need to be a registered user
>>> client = cat2.Client("https://cat2.cloud/demo", ("joedoe@example.com", "foobar"))
>>> root = client.get('@personal')
>>> root.upload('root-example/dir2/ds-4d.b2nd', "a.b2nd")
<Dataset: @personal/a.b2nd>
>>> root.upload('root-example/dir2/ds-4d.b2nd', "b.b2nd")
<Dataset: @personal/b.b2nd>
>>> file = root['a.b2nd']
>>> file.stack('@personal/b.b2nd', '@personal/c.b2nd', axis=0)
PurePosixPath('@personal/c.b2nd')
"""
srcs = [srcs] if not isinstance(srcs, list) else srcs # assure that srcs is list
return self.client.stack([self.path] + srcs, dst, axis)

def remove(self):
"""
Removes the file from the remote repository.
Expand Down Expand Up @@ -1314,88 +1242,6 @@ def copy(self, src, dst):
)
return pathlib.PurePosixPath(result)

def concat(self, srcs, dst, axis):
"""
Concatenate the srcs along axis to a new location dst.

Parameters
----------
srcs: list of Paths
Source files to be concatenated
dst : Path
The destination path for the file.
axis: int
Axis along which to concatenate.

Returns
-------
Path
The new path of the concatenated file.

Examples
--------
>>> import caterva2 as cat2
>>> import numpy as np
>>> # For concatenating a file you need to be a registered user
>>> client = cat2.Client("https://cat2.cloud/demo", ("joedoe@example.com", "foobar"))
>>> root = client.get('@personal')
>>> root.upload('root-example/dir2/ds-4d.b2nd', "a.b2nd")
<Dataset: @personal/a.b2nd>
>>> root.upload('root-example/dir2/ds-4d.b2nd', "b.b2nd")
<Dataset: @personal/b.b2nd>
>>> client.concat(['@personal/a.b2nd', '@personal/b.b2nd'], '@personal/c.b2nd', axis=0)
PurePosixPath('@personal/c.b2nd')
"""
urlbase, _ = _format_paths(self.urlbase)
result = api_utils.post(
f"{self.urlbase}/api/concat/",
{"srcs": [str(src) for src in srcs], "dst": str(dst), "axis": int(axis)},
auth_cookie=self.cookie,
timeout=self.timeout,
)
return pathlib.PurePosixPath(result)

def stack(self, srcs, dst, axis):
"""
Stack the files in srcs along new axis to a new location dst.

Parameters
----------
srcs: list of Paths
Source files accessible by client to be stacked
dst : Path
The destination path for the file.
axis: int
Axis along which to stack.

Returns
-------
Path
The new path of the stacked file.

Examples
--------
>>> import caterva2 as cat2
>>> import numpy as np
>>> # For stacking a file you need to be a registered user
>>> client = cat2.Client("https://cat2.cloud/demo", ("joedoe@example.com", "foobar"))
>>> root = client.get('@personal')
>>> root.upload('root-example/dir2/ds-4d.b2nd', "a.b2nd")
<Dataset: @personal/a.b2nd>
>>> root.upload('root-example/dir2/ds-4d.b2nd', "b.b2nd")
<Dataset: @personal/b.b2nd>
>>> client.stack(['@personal/a.b2nd', '@personal/b.b2nd'], '@personal/c.b2nd', axis=0)
PurePosixPath('@personal/c.b2nd')
"""
urlbase, _ = _format_paths(self.urlbase)
result = api_utils.post(
f"{self.urlbase}/api/stack/",
{"srcs": [str(src) for src in srcs], "dst": str(dst), "axis": int(axis)},
auth_cookie=self.cookie,
timeout=self.timeout,
)
return pathlib.PurePosixPath(result)

def lazyexpr(self, name, expression, operands=None, compute=False):
"""
Creates a lazy expression dataset in personal space.
Expand Down
6 changes: 0 additions & 6 deletions caterva2/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@ class MoveCopyPayload(pydantic.BaseModel):
dst: str


class ConcatStackPayload(pydantic.BaseModel):
axis: int
srcs: list[str]
dst: str


class AddUserPayload(pydantic.BaseModel):
username: str
password: str | None
Expand Down
Loading