graflo.data_source.files¶
Files read through a files connection: a local directory or an S3 prefix.
A FileConnector bound to a :class:~graflo.connections.sources.FilesConnConfig
reads sub_path relative to the connection's root. :func:list_files finds
the files it matches; :func:file_data_source reads one of them. Both serve
sampling and ingestion alike.
Attributes¶
__all__ = ['FileEntry', 'S3ObjectDataSource', 'file_data_source', 'list_files', 'walk']
module-attribute
¶
Classes¶
FileEntry
¶
One file under a files connection: its path relative to the root, and size.
Source code in graflo/data_source/files.py
S3ObjectDataSource
¶
Bases: AbstractDataSource
One S3 object, read as the file it is: downloaded, then read like a local file.
The download lives only while :meth:iter_batches runs.
Source code in graflo/data_source/files.py
Attributes¶
encoding = EncodingType.UTF_8
class-attribute
instance-attribute
¶
file_type = None
class-attribute
instance-attribute
¶
key
instance-attribute
¶
s3
instance-attribute
¶
source_type = DataSourceType.FILE
class-attribute
instance-attribute
¶
Methods:¶
iter_batches(batch_size=1000, limit=None)
¶
Source code in graflo/data_source/files.py
Functions:¶
file_data_source(files, relative, *, file_type=None, encoding=EncodingType.UTF_8)
¶
The data source reading the file at relative under the root of files.
Source code in graflo/data_source/files.py
list_files(files, connector, limit=None)
¶
Paths, relative to the root of files, of the files connector matches.
connector.regex matches a file's name, as for a local directory.
Source code in graflo/data_source/files.py
walk(files, sub_path='', *, recursive=True, limit=None)
¶
Every file under sub_path of files, sorted by relative path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
FilesConnConfig
|
The files connection. |
required |
sub_path
|
str
|
Directory relative to the connection's root. |
''
|
recursive
|
bool
|
Also list the directories below sub_path. |
True
|
limit
|
int | None
|
Stop after this many files. |
None
|