Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Sometimes we don't want to fail when there's no files found #123

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pipx install git+https://github.com/MeltanoLabs/tap-universal-file.git
| file_path | True | None | The path to obtain files from. Example: `/foo/bar`. Or, for `protocol==s3`, use `s3-bucket-name` instead. |
| file_regex | False | None | A regex pattern to only include certain files. Example: `.*\.csv`. |
| file_type | False | delimited | Must be one of `delimited`, `jsonl`, or `avro`. Indicates the type of file to sync, where `delimited` is for CSV/TSV files and similar. Note that *all* files will be read as that type, regardless of file extension. To only read from files with a matching file extension, appropriately configure `file_regex`. |
| fail_when_no_files_found | True | true | Fail when no files are found |
| compression | False | detect | The encoding used to decompress data. Must be one of `none`, `zip`, `bz2`, `gzip`, `lzma`, `xz`, or `detect`. If set to `none` or any encoding, that setting will be applied to *all* files, regardless of file extension. If set to `detect`, encodings will be applied based on file extension. |
| additional_info | False | 1 | If `True`, each row in tap's output will have three additional columns: `_sdc_file_name`, `_sdc_line_number`, and `_sdc_last_modified`. If `False`, these columns will not be present. Incremental replication requires `additional_info==True`. |
| start_date | False | None | Used in place of state. Files that were last modified before the `start_date` wwill not be synced. |
Expand Down
2 changes: 1 addition & 1 deletion tap_universal_file/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def get_files(
yield file_dict
continue

if none_found:
if self.config["fail_when_no_files_found"] and none_found:
msg = (
"No files found. Choose a different `file_path` or try a more lenient "
"`file_regex`."
Expand Down
7 changes: 7 additions & 0 deletions tap_universal_file/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ class TapUniversalFile(Tap):
"matching file extension, appropriately configure `file_regex`."
),
),
th.Property(
"fail_when_no_files_found",
th.BooleanType,
default=True,
required=True,
description="Fail when no files are found",
),
th.Property(
"compression",
th.StringType,
Expand Down