Geoffrey Keating
04/28/2022, 3:48 PMValueError: [TypeError("'_thread.RLock' object is not iterable"), TypeError('vars() argument must have __dict__ attribute')]
Code to reproduce in thread
Prefect 1.3 didn't seem to care about loggers being a part of a class used in a flow - any patterns worth adopting to replace this or does this merit a fix?import logging
from prefect import flow, task
class MyModel:
def __init__(self, name: str):
self.logger = logging.getLogger(f"model.{name}")
self.name = name
def model_things(self, a: int):
<http://self.logger.info|self.logger.info>(f"Running on value {a}")
return a > 1
@task
def model_task(model: MyModel):
outputs = []
for i in range(10):
outputs.append(model.model_things(i))
return outputs
@flow
def model_flow(model):
model_task(model)
model_flow(MyModel("testing"))
Anna Geller
PREFECT_LOGGING_EXTRA_LOGGERS
- this blog post explains it in detailKevin Mullins
04/28/2022, 4:49 PM@flow
def model_flow():
model = MyModel("testing")
model_task(model)
model_flow()
Geoffrey Keating
04/28/2022, 4:51 PMprefect
logger to my objects, but this seems like an extra step that requires classes to accept loggers instead of controlling them independently. I still want that class's logger around for non-prefect testing and experimentation.Kevin Mullins
04/28/2022, 4:54 PMGeoffrey Keating
04/28/2022, 4:56 PMtask
or function implemented. Thanks, Kevin