Skip to content

Commit f42dc2f

Browse files
authored
Merge pull request #192 from lanl/custom_reader_fix
updated error checking for custom readers
2 parents 50ed9aa + ffcabf1 commit f42dc2f

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

dsi/dsi.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,10 @@ def read(self, filenames, reader_name, table_name = None):
167167
168168
Recommended when the input file contains a single table for the `CSV`, `Parquet`, `JSON`, or `Ensemble` reader.
169169
"""
170-
if isinstance(filenames, str) and not os.path.exists(filenames):
170+
# only DSI-repo readers require filename input. Custom readers do not.
171+
if isinstance(filenames, str) and not os.path.exists(filenames) and not reader_name.endswith(".py"):
171172
sys.exit("read() ERROR: The input file must be a valid filepath. Please check again.")
172-
if isinstance(filenames, list) and not all(os.path.exists(f) for f in filenames):
173+
if isinstance(filenames, list) and not all(os.path.exists(f) for f in filenames) and not reader_name.endswith(".py"):
173174
sys.exit("read() ERROR: All input files must have a valid filepath. Please check again.")
174175

175176
if reader_name.endswith(".py"):
@@ -200,9 +201,6 @@ def read(self, filenames, reader_name, table_name = None):
200201

201202
if class_name == None:
202203
sys.exit(f"read() Error: The custom Reader must be structured as a Class in the Python script.")
203-
if init_params == []:
204-
print("read() Error: The custom Reader must be DSI-compatible.")
205-
sys.exit("Please review https://lanl.github.io/dsi/dev_readers.html to ensure it is compatible.")
206204

207205
updated = {}
208206
for param in init_params:
@@ -741,9 +739,6 @@ def write(self, filename, writer_name, table_name = None):
741739

742740
if class_name == None:
743741
sys.exit(f"write() Error: The custom Writer must be structured as a Class in the Python script.")
744-
if init_params == []:
745-
print("write() Error: The custom Writer must be DSI-compatible.")
746-
sys.exit("Please review https://lanl.github.io/dsi/dev_writers.html to ensure it is compatible.")
747742

748743
updated = {}
749744
for param in init_params:

0 commit comments

Comments
 (0)