mantik.remote_file_service.s3_file_service

Attributes

FilePath

logger

Classes

S3Credentials

S3FileService

Client that allows transferring files between s3 and

Module Contents

mantik.remote_file_service.s3_file_service.FilePath[source]
class mantik.remote_file_service.s3_file_service.S3Credentials[source]
aws_access_key_id: str[source]
aws_secret_access_key: str[source]
classmethod get_credentials(connection_id: uuid.UUID | None = None) S3Credentials[source]
class mantik.remote_file_service.s3_file_service.S3FileService(aws_access_key_id: str, aws_secret_access_key: str, local_base_path: str = '.')[source]

Bases: mantik.remote_file_service.abstract_file_service.AbstractFileService

Client that allows transferring files between s3 and the local machine.

To specify that a path is remote, start the path with s3:// E.g. client.copy_file(“/path/local.file”, “s3://path/local.file”) This would upload the file from local to s3.

aws_access_key_id[source]
aws_secret_access_key[source]
abstract change_permissions(target: FilePath, new_permissions: mantik.remote_file_service.abstract_file_service.FileMeta) None[source]

Change metadata (permissions) of a file.

Note: bash chmod

copy_directory(source: FilePath, target: FilePath) mantik.remote_file_service.abstract_file_service.Directory[source]

Copy directory.

Note: bash cp

copy_file(source: FilePath, target: FilePath) mantik.remote_file_service.abstract_file_service.File[source]

Copy file.

Note: bash cp

create_directory(target: FilePath) mantik.remote_file_service.abstract_file_service.Directory[source]

Make a new directory.

Note: bash mkdir

create_file_if_not_exists(target=FilePath) mantik.remote_file_service.abstract_file_service.File[source]

Create (empty) file if not exists.

Note: bash touch

exists(target=FilePath) bool[source]

Return if file exists

classmethod from_env(connection_id: uuid.UUID | None = None) S3FileService[source]

Instantiate with environment variables.

Credentials are either fetched from mantik api or passed in through end vars.

classmethod get_bucket_name(path: FilePath) str[source]

Extracts bucket name from an S3 url s3://<bucket-name>/resource/…

classmethod is_remote(path: FilePath) bool[source]

Checks whether a given url is an S3 url.

list_directory(target: FilePath) List[mantik.remote_file_service.abstract_file_service.Directory | mantik.remote_file_service.abstract_file_service.File][source]

List content of directory.

Note: bash ls

classmethod localise_path(path: FilePath) FilePath[source]

Strips s3 prefix and bucket name from S3 url.

remove_directory(target: FilePath) None[source]

Remove a directory.

Note: bash rm -r

remove_file(target=FilePath) None[source]

Remove file or directory.

Note: bash rm

property user: str[source]

Return current user.

mantik.remote_file_service.s3_file_service.logger[source]