Skip to content

Commit 9e2a714

Browse files
committed
Update base model to use only output directory
1 parent 79910f9 commit 9e2a714

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

openlayer/model_runners/base_model.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,29 @@ def run_from_cli(self):
3232
"--dataset-path", type=str, required=True, help="Path to the dataset"
3333
)
3434
parser.add_argument(
35-
"--dataset-name", type=str, required=True, help="Name of the dataset"
36-
)
37-
parser.add_argument(
38-
"--output-path",
35+
"--output-dir",
3936
type=str,
4037
required=False,
41-
help="Path to dump the results",
42-
default="output",
38+
help="Directory to dump the results in",
4339
)
4440

4541
# Parse the arguments
4642
args = parser.parse_args()
4743

4844
return self.batch(
4945
dataset_path=args.dataset_path,
50-
dataset_name=args.dataset_name,
51-
output_dir=args.output_path,
46+
output_dir=args.output_dir,
5247
)
5348

54-
def batch(self, dataset_path: str, dataset_name: str, output_dir: str):
49+
def batch(self, dataset_path: str, output_dir: str):
5550
# Load the dataset into a pandas DataFrame
56-
df = pd.read_json(dataset_path, orient="records")
51+
if dataset_path.endswith(".csv"):
52+
df = pd.read_csv(dataset_path)
53+
elif dataset_path.endswith(".json"):
54+
df = pd.read_json(dataset_path, orient="records")
5755

5856
# Call the model's run_batch method, passing in the DataFrame
5957
output_df, config = self.run_batch_from_df(df)
60-
output_dir = os.path.join(output_dir, dataset_name)
6158
self.write_output_to_directory(output_df, config, output_dir)
6259

6360
def run_batch_from_df(self, df: pd.DataFrame) -> Tuple[pd.DataFrame, dict]:

0 commit comments

Comments
 (0)