Skip to content

Commit 580cc13

Browse files
authored
Merge pull request #123 from MeltanoLabs/fail_when_no_files_found
feat: Sometimes we don't want to fail when there's no files found
2 parents 829cddb + 3dc690b commit 580cc13

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pipx install git+https://github.com/MeltanoLabs/tap-universal-file.git
2323
| file_path | True | None | The path to obtain files from. Example: `/foo/bar`. Or, for `protocol==s3`, use `s3-bucket-name` instead. |
2424
| file_regex | False | None | A regex pattern to only include certain files. Example: `.*\.csv`. |
2525
| 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`. |
26+
| fail_when_no_files_found | True | true | Fail when no files are found |
2627
| 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. |
2728
| 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`. |
2829
| start_date | False | None | Used in place of state. Files that were last modified before the `start_date` wwill not be synced. |

tap_universal_file/files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def get_files(
133133
yield file_dict
134134
continue
135135

136-
if none_found:
136+
if self.config["fail_when_no_files_found"] and none_found:
137137
msg = (
138138
"No files found. Choose a different `file_path` or try a more lenient "
139139
"`file_regex`."

tap_universal_file/tap.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ class TapUniversalFile(Tap):
9090
"matching file extension, appropriately configure `file_regex`."
9191
),
9292
),
93+
th.Property(
94+
"fail_when_no_files_found",
95+
th.BooleanType,
96+
default=True,
97+
required=True,
98+
description="Fail when no files are found",
99+
),
93100
th.Property(
94101
"compression",
95102
th.StringType,

0 commit comments

Comments
 (0)