MCPcopy
hub / github.com/ray-project/ray / run

Function run

python/ray/serve/scripts.py:460–601  ·  view source on GitHub ↗
(
    config_or_import_path: str,
    arguments: Tuple[str],
    runtime_env: str,
    runtime_env_json: str,
    working_dir: str,
    app_dir: str,
    address: str,
    blocking: bool,
    reload: bool,
    route_prefix: str,
    name: str,
)

Source from the content-addressed store, hash-verified

458 ),
459)
460def run(
461 config_or_import_path: str,
462 arguments: Tuple[str],
463 runtime_env: str,
464 runtime_env_json: str,
465 working_dir: str,
466 app_dir: str,
467 address: str,
468 blocking: bool,
469 reload: bool,
470 route_prefix: str,
471 name: str,
472):
473 sys.path.insert(0, app_dir)
474 args_dict = convert_args_to_dict(arguments)
475 final_runtime_env = parse_runtime_env_args(
476 runtime_env=runtime_env,
477 runtime_env_json=runtime_env_json,
478 working_dir=working_dir,
479 )
480
481 if pathlib.Path(config_or_import_path).is_file():
482 if len(args_dict) > 0:
483 cli_logger.warning(
484 "Application arguments are ignored when running a config file."
485 )
486
487 is_config = True
488 config_path = config_or_import_path
489 cli_logger.print(f"Running config file: '{config_path}'.")
490
491 with open(config_path, "r") as config_file:
492 config_dict = yaml.safe_load(config_file)
493
494 config = ServeDeploySchema.model_validate(config_dict)
495
496 else:
497 is_config = False
498 import_path = config_or_import_path
499 cli_logger.print(f"Running import path: '{import_path}'.")
500 app = _private_api.call_user_app_builder_with_args_if_necessary(
501 import_attr(import_path), args_dict
502 )
503
504 # Only initialize ray if it has not happened yet.
505 if not ray.is_initialized():
506 # Setting the runtime_env here will set defaults for the deployments.
507 ray.init(
508 address=address, namespace=SERVE_NAMESPACE, runtime_env=final_runtime_env
509 )
510 elif (
511 address is not None
512 and address != "auto"
513 and address != ray.get_runtime_context().gcs_address
514 ):
515 # Warning users the address they passed is different from the existing ray
516 # instance.
517 ray_address = ray.get_runtime_context().gcs_address

Callers

nothing calls this directly

Calls 15

parse_runtime_env_argsFunction · 0.90
import_attrFunction · 0.90
gRPCOptionsClass · 0.90
convert_args_to_dictFunction · 0.85
openFunction · 0.85
is_fileMethod · 0.80
get_runtime_contextMethod · 0.80
successMethod · 0.80
shutdownMethod · 0.65
insertMethod · 0.45
warningMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected