Filesystems
lume_services.services.files.filesystems.filesystem
Classes
Filesystem
Bases: ABC
, BaseModel
Attributes
identifier
class-attribute
identifier: str
Functions
dir_exists
abstractmethod
dir_exists(dir: str, create_dir: bool = False) -> bool
Check that a directory exists
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir |
str
|
Path of directory |
required |
create_dir |
bool
|
Whether to create directory if it does not exist |
False
|
Returns:
Type | Description |
---|---|
bool
|
bool |
Source code in lume_services/services/files/filesystems/filesystem.py
10 11 12 13 14 15 16 17 18 19 20 21 |
|
file_exists
abstractmethod
file_exists(filepath: str) -> bool
Check that a file exists
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str
|
Path to file |
required |
Returns:
Type | Description |
---|---|
bool
|
bool |
Source code in lume_services/services/files/filesystems/filesystem.py
23 24 25 26 27 28 29 30 31 32 33 34 |
|
create_dir
abstractmethod
create_dir(dir: str) -> None
Create a directory on the filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir |
str
|
Directory path to create |
required |
Source code in lume_services/services/files/filesystems/filesystem.py
36 37 38 39 40 41 42 43 44 |
|
read
abstractmethod
read(filepath: str, serializer: SerializerBase) -> Any
Read file from the filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str
|
Path of file to read |
required |
serializer |
SerializerBase
|
Implementation of lume-base SerializerBase abstract base class |
required |
Source code in lume_services/services/files/filesystems/filesystem.py
46 47 48 49 50 51 52 53 54 55 56 |
|
write
abstractmethod
write(
filepath: str,
object: Any,
serializer: SerializerBase,
create_dir: bool = False,
) -> None
Write a file to the filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str
|
required | |
object |
Any
|
Object to serialize |
required |
serializer |
SerializerBase
|
Implementation of lume-base SerializerBase abstract base class |
required |
create_dir |
bool
|
Whether to create directory in case not implemented |
False
|
Source code in lume_services/services/files/filesystems/filesystem.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
lume_services.services.files.filesystems.local
Classes
LocalFilesystem
Bases: Filesystem
Handler for local filesystem.
Attributes
identifier
class-attribute
identifier: str = 'local'
Functions
dir_exists
dir_exists(dir: str, create_dir: bool = False) -> bool
Check that a directory exists on the local filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir |
str
|
Path of directory |
required |
create_dir |
bool
|
Whether to create directory if it does not exist |
False
|
Returns:
Type | Description |
---|---|
bool
|
bool |
Source code in lume_services/services/files/filesystems/local.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
file_exists
file_exists(filepath: str) -> bool
Check that a file exists on the local filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str
|
Path to file |
required |
Returns:
Type | Description |
---|---|
bool
|
bool |
Source code in lume_services/services/files/filesystems/local.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
create_dir
create_dir(dir: str) -> None
Create a directory on the local filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir |
str
|
Directory path to create |
required |
Source code in lume_services/services/files/filesystems/local.py
60 61 62 63 64 65 66 67 68 69 70 71 |
|
read
read(filepath: str, serializer: SerializerBase) -> Any
Read file from the local filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str
|
Path of file to read. |
required |
serializer |
SerializerBase
|
Implementation of lume-base SerializerBase abstract base class. |
required |
Source code in lume_services/services/files/filesystems/local.py
73 74 75 76 77 78 79 80 81 82 83 84 |
|
write
write(
filepath: str,
object: Any,
serializer: SerializerBase,
create_dir: bool = False,
) -> None
Write a file to the local filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str
|
required | |
object |
Any
|
Object to serialize |
required |
serializer |
SerializerBase
|
Implementation of lume-base SerializerBase abstract base class |
required |
create_dir |
bool
|
Whether to create directory in case not implemented |
False
|
Source code in lume_services/services/files/filesystems/local.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
lume_services.services.files.filesystems.mounted
Classes
PathNotInMount
PathNotInMount(
filesystem_identifier: str,
path: str,
mount_path: str,
mount_alias: str,
)
Bases: Exception
Source code in lume_services/services/files/filesystems/mounted.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
Attributes
filesystem_identifier
instance-attribute
filesystem_identifier = filesystem_identifier
path
instance-attribute
path = (path)
mount_path
instance-attribute
mount_path = mount_path
mount_alias
instance-attribute
mount_alias = mount_alias
message
instance-attribute
message = "Path %s not in mount for mounted filesystem identifier: %s, Mount path: %s, Mount alias: %s"
Functions
MountedFilesystem
Bases: LocalFilesystem
Handler for mounted filesystem. Modifies the LocalFilesystem to implements checks for mount path modifications. Container and container orchestration tools often allow the ability to provide an alias for a mounted directory. This handler accounts for the mount base and verifies that the file is within the path.
Attributes
identifier
class-attribute
identifier: str = 'mounted'
mount_path
class-attribute
mount_path: str
mount_alias
class-attribute
mount_alias: str
mount_type
class-attribute
mount_type: _HostMountLiteral = 'DirectoryOrCreate'
Functions
validate_mount_path
validate_mount_path(v, values)
Source code in lume_services/services/files/filesystems/mounted.py
55 56 57 58 59 60 61 62 |
|
dir_exists
dir_exists(dir: str, create_dir: bool = False) -> bool
Check that a directory exists on the mounted filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir |
str
|
Path of directory |
required |
create_dir |
bool
|
Whether to create directory if it does not exist |
False
|
Returns:
Type | Description |
---|---|
bool
|
bool |
Source code in lume_services/services/files/filesystems/mounted.py
64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
file_exists
file_exists(filepath: str) -> bool
Check that a file exists on the mounted filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str
|
Path to file |
required |
Returns:
Type | Description |
---|---|
bool
|
bool |
Source code in lume_services/services/files/filesystems/mounted.py
78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
create_dir
create_dir(dir: str) -> None
Create a directory on the mounted filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir |
str
|
Directory path to create |
required |
Source code in lume_services/services/files/filesystems/mounted.py
92 93 94 95 96 97 98 99 100 |
|
read
read(filepath: str, serializer: SerializerBase) -> Any
Read file from the mounted filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str
|
Path of file to read |
required |
serializer |
SerializerBase
|
Implementation of lume-base SerializerBase abstract base class |
required |
Source code in lume_services/services/files/filesystems/mounted.py
102 103 104 105 106 107 108 109 110 111 112 |
|
write
write(
filepath: str,
object: Any,
serializer: SerializerBase,
create_dir: bool = False,
) -> None
Write a file to the mounted filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str
|
required | |
object |
Any
|
Object to serialize |
required |
serializer |
SerializerBase
|
Implementation of lume-base SerializerBase abstract base class |
required |
create_dir |
bool
|
Whether to create directory in case not implemented |
False
|
Source code in lume_services/services/files/filesystems/mounted.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|