class_docstr: Implementation for subcmd `towhee server`. Start pipelines as services.
class_docstr_tok: ["Implementation","for","subcmd","`","towhee","server","`",".","Start","pipelines","as","services","."]
code: def _pservice(self, file, interface):
      # Add module path to sys path so that module can be found
      rel_path = (Path.cwd() / file).resolve().parent
      abs_path = Path(file).resolve().parent
      sys.path.insert(0, str(abs_path))
      sys.path.insert(0, str(rel_path))
  
      # Load api service from target python file
      module_str = Path(file).stem
      attr_str = interface
      module = importlib.import_module(module_str)
      service = getattr(module, attr_str)
  
      return service
  
file_path: towhee/towhee/command/service.py
imports: import sys
  import importlib
  import argparse
  from pathlib import Path
  from towhee.utils.lazy_import import LazyImport
label_desc: Use image node_id 4 for calling the ServerCommand obj's underlying member method code with example usage: obj._pservice(file, interface) and returns: service