7c0200c93b88898507dbafcb2d92314d0dbcd451,python/ray/serve/master.py,ServeMaster,set_backend_config,#ServeMaster#Any#Any#,296

Before Change


                          BackendConfig), ("backend_config must be"
                                           " of instance BackendConfig")
        backend_config_dict = dict(backend_config)
        old_backend_config_dict = self.backend_table.get_info(backend_tag)

        if (not old_backend_config_dict["has_accept_batch_annotation"]
                and backend_config.max_batch_size is not None):
            raise batch_annotation_not_found

        self.backend_table.register_info(backend_tag, backend_config_dict)

        // Inform the router about change in configuration
        // (particularly for setting max_batch_size).
        [router] = self.get_router()
        await router.set_backend_config.remote(backend_tag,
                                               backend_config_dict)

        // Restart replicas if there is a change in the backend config related

After Change


            await self.router.set_backend_config.remote(
                backend_tag, backend_config_dict)

    async def set_backend_config(self, backend_tag, backend_config):
        Set the config for the specified backend.
        async with self.write_lock:
            assert (backend_tag in self.backends
                    ), "Backend {} is not registered.".format(backend_tag)
            assert isinstance(backend_config,
                              BackendConfig), ("backend_config must be"
                                               " of instance BackendConfig")
            backend_config_dict = dict(backend_config)
            backend_worker, init_args, old_backend_config_dict = self.backends[
                backend_tag]

            if (not old_backend_config_dict["has_accept_batch_annotation"]
                    and backend_config.max_batch_size is not None):
                raise batch_annotation_not_found

            self.backends[backend_tag] = (backend_worker, init_args,
                                          backend_config_dict)

            // Restart replicas if there is a change in the backend config
            // related to restart_configs.
            need_to_restart_replicas = any(
                old_backend_config_dict[k] != backend_config_dict[k]
                for k in BackendConfig.restart_on_change_fields)
            if need_to_restart_replicas:
                // Kill all the replicas for restarting with new configurations.
                self._scale_replicas(backend_tag, 0)

            // Scale the replicas with the new configuration.
            self._scale_replicas(backend_tag,
                                 backend_config_dict["num_replicas"])

            // NOTE(edoakes): we must write a checkpoint before pushing the
            // update to avoid inconsistent state if we crash after pushing the
            // update.
            self._checkpoint()

            // Inform the router about change in configuration
            // (particularly for setting max_batch_size).
            await self.router.set_backend_config.remote(
                backend_tag, backend_config_dict)

            await self._start_pending_replicas()
            await self._stop_pending_replicas()

    def get_backend_config(self, backend_tag):
        Get the current config for the specified backend.
        assert (backend_tag in self.backends
                ), "Backend {} is not registered.".format(backend_tag)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 9

Instances


Project Name: ray-project/ray
Commit Name: 7c0200c93b88898507dbafcb2d92314d0dbcd451
Time: 2020-04-28
Author: ed.nmi.oakes@gmail.com
File Name: python/ray/serve/master.py
Class Name: ServeMaster
Method Name: set_backend_config


Project Name: ray-project/ray
Commit Name: 7c0200c93b88898507dbafcb2d92314d0dbcd451
Time: 2020-04-28
Author: ed.nmi.oakes@gmail.com
File Name: python/ray/serve/master.py
Class Name: ServeMaster
Method Name: create_backend


Project Name: ray-project/ray
Commit Name: 7c0200c93b88898507dbafcb2d92314d0dbcd451
Time: 2020-04-28
Author: ed.nmi.oakes@gmail.com
File Name: python/ray/serve/master.py
Class Name: ServeMaster
Method Name: set_traffic


Project Name: ray-project/ray
Commit Name: 7c0200c93b88898507dbafcb2d92314d0dbcd451
Time: 2020-04-28
Author: ed.nmi.oakes@gmail.com
File Name: python/ray/serve/master.py
Class Name: ServeMaster
Method Name: set_backend_config