Skip to content

Commit

Permalink
Print helpful warning when manifest file is binary
Browse files Browse the repository at this point in the history
  • Loading branch information
mittagessen committed Jun 19, 2024
1 parent 4d73479 commit 803553f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions kraken/ketos/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,20 @@
def _validate_manifests(ctx, param, value):
images = []
for manifest in value:
for entry in manifest.readlines():
im_p = entry.rstrip('\r\n')
if os.path.isfile(im_p):
images.append(im_p)
else:
logger.warning('Invalid entry "{}" in {}'.format(im_p, manifest.name))
try:
for entry in manifest.readlines():
im_p = entry.rstrip('\r\n')
if os.path.isfile(im_p):
images.append(im_p)
else:
logger.warning('Invalid entry "{}" in {}'.format(im_p, manifest.name))
except UnicodeDecodeError:
raise click.BadOptionUsage(param,
f'File {manifest.name} is not a text file. Please '
'ensure that the argument to `-t`/`-e` is a manifest '
'file containing paths to training data (one per '
'line).',
ctx=ctx)
return images


Expand Down

0 comments on commit 803553f

Please sign in to comment.