Skip to content

Commit

Permalink
serving supports dry run
Browse files Browse the repository at this point in the history
  • Loading branch information
hankcs committed Jan 11, 2020
1 parent 523e9d6 commit 09d907b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions hanlp/common/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,13 @@ def export_model_for_serving(self, export_dir=None, version=1, overwrite=False,
f'--model_base_path={export_dir} --rest_api_port=8888')
return export_dir

def serve(self, export_dir=None, grpc_port=8500, rest_api_port=0):
export_dir = self.export_model_for_serving(export_dir)
del self.model # free memory
def serve(self, export_dir=None, grpc_port=8500, rest_api_port=0, dry_run=False):
export_dir = self.export_model_for_serving(export_dir, show_hint=False)
if not dry_run:
del self.model # free memory
cmd = f'nohup tensorflow_model_server --model_name={os.path.splitext(os.path.basename(self.meta["load_path"]))[0]} ' \
f'--model_base_path={export_dir} --port={grpc_port} --rest_api_port={rest_api_port} ' \
f'>serve.log 2>&1 &'
logger.info(f'Running ...\n{cmd}')
os.system(cmd)
if not dry_run:
os.system(cmd)

0 comments on commit 09d907b

Please sign in to comment.