-
Notifications
You must be signed in to change notification settings - Fork 641
Open
Description
Summary
TinyPersonFactory.create_factory_from_demography() raises a TypeError when logging level is set to INFO or DEBUG in config.ini. The error occurs in debug logging code that attempts to serialize self.sampling_dimensions using json.dumps(), but the dictionary contains Python set objects which are not JSON serializable.
This issue does not occur when LOGLEVEL=ERROR (the default), but users who enable more verbose logging for debugging purposes encounter this crash.
Error Traceback
TypeError: Object of type set is not JSON serializable
File ~/TinyTroupe/tinytroupe/factory/tiny_person_factory.py, line 532, in _initialize_sampling_plan_transaction
logger.debug(f"Sampling dimensions: {json.dumps(self.sampling_dimensions, indent=4)}")
File ~/miniconda3/lib/python3.12/json/encoder.py, line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
f'is not JSON serializable')Root Cause
File: tinytroupe/factory/tiny_person_factory.py
Line: 532
self.sampling_dimensions = utils.try_function(lambda: self._compute_sampling_dimensions(...))
logger.info("Sampling dimensions computed successfully.")
logger.debug(f"Sampling dimensions: {json.dumps(self.sampling_dimensions, indent=4)}") # ← CRASHES HEREProblem:
self.sampling_dimensionscontains Pythonsetobjects (likely used for deduplication)json.dumps()cannot serializesettype by default- This logging statement only executes when
LOGLEVEL=DEBUG
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels