Skip to content

Commit

Permalink
Don't serialize some options to json (#1097)
Browse files Browse the repository at this point in the history
Debug a serialization failure
  • Loading branch information
manthey authored and cooperlab committed Apr 4, 2024
1 parent ba19303 commit d4710a2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions histomicstk/cli/SuperpixelSegmentation/SuperpixelSegmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def createSuperPixels(opts): # noqa
'boundaries': opts.boundaries,
}],
'attributes': {
'params': vars(opts),
'params': {k: v for k, v in vars(opts).items() if not callable(v)},
'cli': Path(__file__).stem,
'version': histomicstk.__version__,
},
Expand All @@ -259,14 +259,19 @@ def createSuperPixels(opts): # noqa
'lineColor': opts.default_strokeColor,
} for bidx, (bcx, bcy, bw, bh) in enumerate(bboxes)],
'attributes': {
'params': vars(opts),
'params': {k: v for k, v in vars(opts).items() if not callable(v)},
'cli': Path(__file__).stem,
'version': histomicstk.__version__,
},
}
annotation = [annotation, bboxannotation]
with open(opts.outputAnnotationFile, 'w') as annotation_file:
json.dump(annotation, annotation_file, separators=(',', ':'), sort_keys=False)
try:
json.dump(annotation, annotation_file, separators=(',', ':'), sort_keys=False)
except Exception:
print('Failed to serialize annotation')
print(repr(annotation))
raise
if hasattr(opts, 'callback'):
opts.callback('file', 2, 2)

Expand Down

0 comments on commit d4710a2

Please sign in to comment.