Skip to main content

File Transfer Strategies

A set of classes with a shared interface to perform copy, download, and upload operations given two (source & destination) File objects that support various protocols.

Classes:

Blob([client_id, client_secret, tenant_id])

Implements FileTransferStrategy class to transfer files to/from Azure Blob Storage.

GCloud([credentials, project_id])

Implements FileTransferStrategy class to transfer files to/from Google Cloud Storage.

Implements Base FileTransferStrategy class to use HTTP to download files from public URLs.

Rsync([user, host, private_key_path])

Implements Base FileTransferStrategy class to use rsync to move files to and from remote or local filesystems.

S3([credentials, profile, region_name]

Implements Base FileTransferStrategy class to upload/download files from S3 Bucket.

class covalent.fs_strategies.Blob

#

Bases: covalent._file_transfer.strategies.transfer_strategy_base.FileTransferStrategy

Implements FileTransferStrategy class to transfer files to/from Azure Blob Storage.

Parameters

client_id (Optional[str]) - ID of a service principal authorized to perform the transfer

client_secret (Optional[str]) - Corresponding secret key for the service principal credentials

tenant_id (Optional[str]) - The Azure Active Directory tenant ID which owns the cloud resources.

credentials

A tuple containing (client_id, client_secret, tenant_id)

Methods:

cp(from_file[, to_file])

download(from_file[, to_file])

Download files or the contents of folders from Azure Blob Storage.

upload(from_file[, to_file])

Upload files or the contents of folders to Azure Blob Storage.

cp

#

Return Type

file

download

#

Download files or the contents of folders from Azure Blob Storage.

Parameters

from_file(file) - File object referencing an object in Azure Blob storage

to_file (file - File object referencing a path in the local filesystem

Returns

Download function that is injected into wrapper_fn

Return Type

callable

upload

#

Upload files or the contents of folders to Azure Blob Storage.

Parameters

from_file (file) - File object referencing a path in the local filesystem

to_file (file) - File object referencing an object in Azure Blob storage

Returns

Upload function that is injected into wrapper_fn

Return Type

callable

class covalent.fs_strategies.GCloud

#

Bases: covalent._file_transfer.strategies.transfer_strategy_base.FileTransferStrategy

Implements FileTransferStrategy class to transfer files to/from Google Cloud Storage.

Parameters

credentials(Optional[str]) - IPath to OAuth 2.0 credentials JSON file for a service account

project_id (Optional[str]) - ID of a project in GCP

credentials

String containing OAuth 2.0 credentials.

project_id

ID of a project in GCP

Methods:

cp(from_file[, to_file])

download(from_file[, to_file]

callable

upload(from_file[, to_file])

callable

cp

#

Return Type

file

download

#

Return Type

callable

upload

#

Return Type

callable

class covalent.fs_strategies.HTTP

#

Bases: covalent._file_transfer.strategies.transfer_strategy_base.FileTransferStrategy

Implements Base FileTransferStrategy class to use HTTP to download files from public URLs.

cp(from_file[, to_file])

RTYPE file

download(from_file[, to_file])

RTYPE file

upload(from_file[, to_file])

RTYPE file

cp

#

Return Type

file

upload

#

Return Type

file

download

#

Return Type

file

class covalent.fs_strategies.Rsync

#

Bases: covalent._file_transfer.strategies.transfer_strategy_base.FileTransferStrategy

Implements Base FileTransferStrategy class to use rsync to move files to and from remote or local filesystems. Rsync via ssh is used if one of the provided files is marked as remote.

user

(optional) Determine user to specify for remote host if using rsync with ssh

host

(optional) Determine what host to connect to if using rsync with ssh

private_key_path

(optional) Filepath for ssh private key to use if using rsync with ssh

Methods:

cp(from_file[, to_file])

RTYPE None

download(from_file[, to_file])

RTYPE file

get_rsync_cmd(from_file, to_file[, …])

RTYPE str

get_rsync_ssh_cmd(local_file, remote_file[, …])

RTYPE str

upload(from_file, to_file)

RTYPE None

cp

#

Return Type

None

download

#

Return Type

file

get_rsync_cmd

#

Return Type

str

get_rsync_ssh_cmd

#

Return Type

str

return_subprocess_callable

#

Return Type

None

upload

#

Return Type

None

class covalent.fs_strategies.S3

#

Bases: covalent._file_transfer.strategies.transfer_strategy_base.FileTransferStrategy

Implements Base FileTransferStrategy class to upload/download files from S3 Bucket.

Methods:

cp(from_file[, to_file])

RTYPE file

download(from_file[, to_file])

Download files or the contents of folders from S3 bucket.

upload(from_file, to_file)

Upload files or folders to S3 bucket.

cp

#

Return Type

file

download

#

Download files or the contents of folders from S3 bucket.

Return Type

file

upload

#

Upload files or folders to S3 bucket.

Return Type

file

Examples