| 241 | # Execution |
| 242 | # ------------------------------------------------------------------ |
| 243 | def execute(self): |
| 244 | action = getattr(self.args, 'studio_action', None) |
| 245 | if action is None: |
| 246 | raise SystemExit( |
| 247 | 'No studio subcommand specified. ' |
| 248 | "Run 'modelscope studio --help' to see available subcommands.") |
| 249 | |
| 250 | endpoint = resolve_endpoint(self.args.endpoint) |
| 251 | api = HubApi(endpoint=endpoint) |
| 252 | |
| 253 | handlers = { |
| 254 | 'deploy': self._do_deploy, |
| 255 | 'stop': self._do_stop, |
| 256 | 'logs': self._do_logs, |
| 257 | 'settings': self._do_settings, |
| 258 | 'secret': self._do_secret, |
| 259 | } |
| 260 | handler = handlers.get(action) |
| 261 | if handler is None: |
| 262 | raise SystemExit(f'Unknown studio subcommand: {action}') |
| 263 | handler(api, endpoint) |
| 264 | |
| 265 | # -- deploy / stop -------------------------------------------------- |
| 266 | def _do_deploy(self, api, endpoint): |