(
import_paths: Tuple[str],
app_dir: str,
output_path: Optional[str],
grpc_servicer_functions: List[str],
)
| 882 | "Defaults to an empty list and no gRPC server is started.", |
| 883 | ) |
| 884 | def build( |
| 885 | import_paths: Tuple[str], |
| 886 | app_dir: str, |
| 887 | output_path: Optional[str], |
| 888 | grpc_servicer_functions: List[str], |
| 889 | ): |
| 890 | sys.path.insert(0, app_dir) |
| 891 | |
| 892 | def build_app_config(import_path: str, name: str = None): |
| 893 | app: Application = import_attr(import_path) |
| 894 | if not isinstance(app, Application): |
| 895 | raise TypeError( |
| 896 | f"Expected '{import_path}' to be an Application but got {type(app)}." |
| 897 | ) |
| 898 | |
| 899 | built_app: BuiltApplication = build_app(app, name=name) |
| 900 | schema = ServeApplicationSchema( |
| 901 | name=name, |
| 902 | route_prefix="/" if len(import_paths) == 1 else f"/{name}", |
| 903 | import_path=import_path, |
| 904 | runtime_env={}, |
| 905 | deployments=[deployment_to_schema(d) for d in built_app.deployments], |
| 906 | ) |
| 907 | |
| 908 | return schema.model_dump(exclude_unset=True) |
| 909 | |
| 910 | config_str = ( |
| 911 | "# This file was generated using the `serve build` command " |
| 912 | f"on Ray v{ray.__version__}.\n\n" |
| 913 | ) |
| 914 | |
| 915 | app_configs = [] |
| 916 | for app_index, import_path in enumerate(import_paths): |
| 917 | app_configs.append(build_app_config(import_path, name=f"app{app_index + 1}")) |
| 918 | |
| 919 | deploy_config = { |
| 920 | "proxy_location": "EveryNode", |
| 921 | "http_options": { |
| 922 | "host": get_all_interfaces_ip(), |
| 923 | "port": 8000, |
| 924 | }, |
| 925 | "grpc_options": { |
| 926 | "port": DEFAULT_GRPC_PORT, |
| 927 | "grpc_servicer_functions": grpc_servicer_functions, |
| 928 | }, |
| 929 | "logging_config": LoggingConfig().model_dump(), |
| 930 | "applications": app_configs, |
| 931 | } |
| 932 | |
| 933 | # Parse + validate the set of application configs |
| 934 | ServeDeploySchema.model_validate(deploy_config) |
| 935 | |
| 936 | config_str += yaml.dump( |
| 937 | deploy_config, |
| 938 | Dumper=ServeDeploySchemaDumper, |
| 939 | default_flow_style=False, |
| 940 | sort_keys=False, |
| 941 | width=80, # Set width to avoid folding long lines |
nothing calls this directly
no test coverage detected
searching dependent graphs…