Storage

Storage prototype

class qarnot.storage.Storage[source]

Bases: object

Common architecture for storage providers

get_all_files(output_dir, progress=None)[source]

Get all files from the storage.

Parameters
  • output_dir (str) – local directory for the retrieved files.

  • progress (bool or function(float, float, str)) – can be a callback (read,total,filename) or True to display a progress bar

Raises

Warning

Will override output_dir content.

__init__()[source]
list_files()[source]

List files on the storage.

… note:

File object returned must have a key property.

Returns

List of the files on the storage.

get_file(remote, local=None, progress=None)[source]

Get a file from the storage. Create needed subfolders.

Parameters
  • remote (str) – the name of the remote file

  • local (str) – local name of the retrieved file (defaults to remote)

  • progress (bool or function(float, float, str)) – can be a callback (read,total,filename) or True to display a progress bar

Return type

str

Returns

The name of the output file.

Raises

ValueError – no such file

copy_file(source, dest)[source]

Create a copy of a file

Parameters
  • source (str) – name of the existing file to duplicate

  • dest (str) – name of the created file

add_directory(local, remote)[source]

Add a directory to the storage. Does not follow symlinks. File hierarchy is preserved.

Parameters
  • local (str) – path of the local directory to add

  • remote (str) – path of the directory on remote node (defaults to local)

Raises

IOError – not a valid directory

add_file(local_or_file, remote)[source]

Add a local file or a Python File on the storage.

Note

You can also use object[remote] = local

Parameters
  • local_or_file (str or File) – path of the local file or an opened Python File

  • remote (str) – name of the remote file (defaults to local_or_file)

delete_file(remote)[source]

Delete a file from the storage.

Parameters

remote (str) – the name of the remote file

update(flush=None)[source]

Update object from remote endpoint

Parameters

flush (bool) – bypass cache

Deprecated since version 2.6.0: This will be removed in 3.0. Legacy function

flush()[source]

Ensure all background uploads are complete

Deprecated since version 2.6.0: This will be removed in 3.0. Legacy function