def get_ward(cls): try: identifier = cls.Meta.identifier except Exception as e: raise ArnheimModelConfigurationError(f"Make soure your Model {cls.__name__}overwrites Meta identifier: {e}") from bergen.registries.ward import get_ward_registry return get_ward_registry().get_ward(identifier=identifier)
async def disconnect_async(self, client_type=None): await self.main_ward.disconnect() if self.postman: await self.postman.disconnect() if self._provider: await self._provider.disconnect() if self._entertainer: await self._entertainer.disconnect() ward_registry = get_ward_registry() await asyncio.gather( *[ward.disconnect() for ward in ward_registry.wards]) print("Sucessfulyl disconnected")
async def negotiate_async(self): from bergen.schemas.arkitekt.mutations.negotiate import NEGOTIATION_GQL # Instantiate our Main Ward, this is only for Nodes and Pods self.main_ward = MainWard(self) await self.main_ward.configure() # We resort escalating to the different client Type protocols self._transcript = await NEGOTIATION_GQL.run( ward=self.main_ward, variables={ "clientType": self.client_type, "internal": self.is_iternal, **self.negotiate_additionals }) #Lets create our different Wards assert self._transcript.models is not None, "We apparently didnt't get any points" assert self._transcript.wards is not None, "We apparently didnt't get any wards" ward_registry = get_ward_registry() ward_registry.set_base(self.main_ward) for ward in self._transcript.wards: ward_registry.create_ward(self, ward) for model in self._transcript.models: ward_registry.register_model(model) # Negotating Extensions for the Datapoints self._extensions = await ward_registry.configure_wards() self.postman = self.getPostmanFromSettings(self._transcript) await self.postman.connect() if self.client_type in [ClientType.PROVIDER, ClientType.HOST]: self._entertainer = self.getEntertainerFromSettings( self._transcript) await self._entertainer.connect() if self.client_type == ClientType.PROVIDER: self._provider = self.getProviderFromSettings(self._transcript) await self._provider.connect() self.log_table()