Hello ! I'm encountering an issue with logging con...
# ask-for-help
l
Hello ! I'm encountering an issue with logging configuration in BentoML. In my
service.py
file, I set up loggers right before defining multiple @`bentoml.service` . When I build a Bento, the code outside of the service definitions, including my logger setup, gets executed. This requires me to provide a logging configuration file at build time, which seems unusual. Is this the expected behavior during the
bentoml build
process? Thanks!
j
Yes, the service.py file gets executed during build because we are relying it to build the dependency graph of services
l
Okay, thank you ! Is there a way to execute code only during serving ? • Maybe using lifecycle hooks ? But from what i understand they only work from within a Service definition, which doesn't work well for logging setup . • Or maybe by checking if the service is the
__main__
or any other variable that indicates that we are at build/serving time ?