(
model,
config=None,
backend=None,
num_gpus=None,
target=None,
min_instances=None,
max_instances=None,
enable_lora=None,
lora_adapters=None,
precision=None,
)
| 108 | |
| 109 | |
| 110 | def deploy_model( |
| 111 | model, |
| 112 | config=None, |
| 113 | backend=None, |
| 114 | num_gpus=None, |
| 115 | target=None, |
| 116 | min_instances=None, |
| 117 | max_instances=None, |
| 118 | enable_lora=None, |
| 119 | lora_adapters=None, |
| 120 | precision=None, |
| 121 | ): |
| 122 | default_config_path = os.path.abspath( |
| 123 | os.path.join(os.path.dirname(__file__), "default_config.json") |
| 124 | ) |
| 125 | |
| 126 | if not os.path.exists(default_config_path): |
| 127 | print(f"[ERROR] Default config not found at {default_config_path}") |
| 128 | return |
| 129 | |
| 130 | config_data = read_config(default_config_path) |
| 131 | |
| 132 | if config: |
| 133 | # Try to find the config file in multiple locations |
| 134 | config_path = None |
| 135 | search_paths = [ |
| 136 | os.path.abspath( |
| 137 | config |
| 138 | ), # Absolute or relative to current directory |
| 139 | os.path.join( |
| 140 | os.path.dirname(__file__), config |
| 141 | ), # Relative to sllm package |
| 142 | os.path.expanduser(f"~/.sllm/{config}"), # User config directory |
| 143 | os.path.join("/etc/sllm", config), # System config directory |
| 144 | ] |
| 145 | |
| 146 | for path in search_paths: |
| 147 | if os.path.exists(path): |
| 148 | config_path = path |
| 149 | break |
| 150 | |
| 151 | if not config_path: |
| 152 | print( |
| 153 | f"[ERROR] Config file '{config}' not found in any of these locations:" |
| 154 | ) |
| 155 | for path in search_paths: |
| 156 | print(f" - {path}") |
| 157 | print("") |
| 158 | print("Available config files:") |
| 159 | # Show available config files in current directory |
| 160 | current_dir_configs = [ |
| 161 | f for f in os.listdir(".") if f.endswith(".json") |
| 162 | ] |
| 163 | if current_dir_configs: |
| 164 | for cf in current_dir_configs: |
| 165 | print(f" - {cf}") |
| 166 | else: |
| 167 | print(" - No JSON config files found in current directory") |
no test coverage detected