Refactor ml service impl to support embedded runs