read_metadata: support file inputs as well as dirs

This commit is contained in:
Starbeamrainbowlabs 2022-11-10 19:53:30 +00:00
parent aa7d9b8cf6
commit 0aa2ce19f5
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -5,6 +5,9 @@ import json
from ..io.readfile import readfile
def read_metadata(dirpath_dataset):
filepath_metadata = os.path.join(dirpath_dataset, "metadata.json")
if os.path.isfile(dirpath_dataset):
filepath_metadata = os.path.join(os.path.dirname(dirpath_dataset), "metadata.jsonl")
else:
filepath_metadata = os.path.join(dirpath_dataset, "metadata.json")
return json.loads(readfile(filepath_metadata))