def publish_realtime_local(self, parameter_s='', cell=None): import tempfile import azure.cli.command_modules.ml.service.realtime as r import azure.cli.command_modules.ml._util as u # reload util to get new environment vars self.easy_reload(u) p = argparse.ArgumentParser() p.add_argument('-s', '--schema', help='local path to schema file', required=True) p.add_argument('-m', '--model', help='local path to model', required=True) p.add_argument('-n', '--name', help='name of the webservice', required=True) p.add_argument('-d', '--dependency', dest='dependencies', help='arbitrary dependencies', action='append', default=[]) p.add_argument('-o', '--overwrite', help='flag to overwrite existing service', action='store_true') args = p.parse_args(parameter_s.split()) context = u.JupyterContext() context.local_mode = True context.set_input_response( 'Delete existing service and create new service (y/N)? ', 'y' if args.overwrite else 'n') _, fp = tempfile.mkstemp() with open(fp, 'w') as score_file: score_file.write(cell) try: resp_code = r.realtime_service_create( score_file.name, dependencies=args.dependencies, requirements='', schema_file=args.schema, service_name=args.name, verb=False, custom_ice_url='', target_runtime='spark-py', logging_level='debug', model=args.model, context=context) if resp_code == 1: print( 'Use -o flag to magic to overwrite the existing service.') finally: # cleanup os.remove(fp)
def view_realtime_local(self, line): import azure.cli.command_modules.ml.service.realtime as r import azure.cli.command_modules.ml._util as u p = argparse.ArgumentParser() p.add_argument('-n', '--name', help='name of the webservice', required=True) name = p.parse_args(line.split()).name context = u.JupyterContext() context.local_mode = True r.realtime_service_view(service_name=name, context=context)
def publish_realtime_local(self, parameter_s='', cell=None): import tempfile import azure.cli.command_modules.ml.service.realtime as r import azure.cli.command_modules.ml._util as u import azure.cli.command_modules.ml.service._realtimeutilities as rtu # reload util to get new environment vars self.easy_reload(u) p = argparse.ArgumentParser() p.add_argument('-s', '--schema', help='local path to schema file', required=False, default='') p.add_argument('-m', '--model', help='local path to model', required=False, default='') p.add_argument('-n', '--name', help='name of the webservice', required=True) p.add_argument('-d', '--dependency', dest='dependencies', help='arbitrary dependencies', action='append', default=[]) p.add_argument( '-p', '--requirements', dest='requirements', help= 'A pip requirements.txt file of packages needed by the code file.', required=False, default='') p.add_argument('-o', '--overwrite', help='flag to overwrite existing service', action='store_true') p.add_argument( '-r', '--target-runtime', help='Runtime of the web service. Valid runtimes are {}'.format( '|'.join(rtu.RealtimeConstants.supported_runtimes)), default='spark-py') p.add_argument('-l', '--app-insights-logging-enabled', dest='app_insights_logging_enabled', action='store_true', help='Flag to enable App insights logging.', required=False) p.add_argument('-z', '--num-replicas', dest='num_replicas', type=int, default=1, required=False, help='Number of replicas for a Kubernetes service.') args = p.parse_args(parameter_s.split()) context = u.JupyterContext() context.local_mode = True context.set_input_response( 'Delete existing service and create new service (y/N)? ', 'y' if args.overwrite else 'n') _, fp = tempfile.mkstemp() with open(fp, 'w') as score_file: score_file.write(cell) try: resp_code = r.realtime_service_create( fp, dependencies=args.dependencies, requirements=args.requirements, schema_file=args.schema, service_name=args.name, verb=False, custom_ice_url='', target_runtime=args.target_runtime, app_insights_logging_enabled=args.app_insights_logging_enabled, num_replicas=args.num_replicas, model=args.model, context=context) if resp_code == 1: print( 'Use -o flag to magic to overwrite the existing service.') finally: # cleanup os.remove(fp)