caterva2.remove#

caterva2.remove(path, urlbase=None, auth_cookie=None)#

Removes a dataset or the contents of a directory from a remote repository.

Note: When a directory is removed, only its contents are deleted; the directory itself remains. This behavior allows for future uploads to the same directory. It is subject to in future versions.

Parameters:
  • path (Path) – Path of the dataset or directory to remove.

  • urlbase (str, optional) – Base URL to query. Defaults 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:

The path that was removed.

Return type:

str

Examples

>>> import caterva2 as cat2
>>> import numpy as np
>>> # To remove a file 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'))
>>> path = f'@personal/dir{np.random.randint(0, 100)}/ds-4d.b2nd'
>>> uploaded_path = cat2.upload('root-example/dir2/ds-4d.b2nd', path, urlbase, auth_cookie)
>>> removed_path = cat2.remove(path, urlbase, auth_cookie)
>>> removed_path == path
True