def start(self): assert not self.active try: # Apply the RabbitMQ virtual host patch self._vhostPatch = RabbitmqVirtualHostPatch( clientLabel=self._clientLabel, kw=None, logger=self._logger) self._vhostPatch.start() # Apply Model Checkpoint Manager patch self._modelCheckpointPatch = ModelCheckpointStoragePatch( kw=None, logger=self._logger) self._modelCheckpointPatch.start() # Self-validation actualVhost = ( amqp.connection.getRabbitmqConnectionParameters().vhost) assert actualVhost == self._vhostPatch._vhost, ( "Expected vhost=%r, but got vhost=%r") % (self._vhost, actualVhost) except Exception: self._logger.exception("patch failed, removing sub-patches") self._removePatches() raise self.active = True self._logger.info("%s: applied patch", self.__class__.__name__)
def testStorageDirOverrideViaEnvironmentVariable(self): with ModelCheckpointStoragePatch() as storagePatch: checkpointMgr = ModelCheckpointMgr() tempModelCheckpointDir = storagePatch.tempModelCheckpointDir modelEntryDir = checkpointMgr._getModelDir(modelID="abc", mustExist=False) self.assertIn(tempModelCheckpointDir, modelEntryDir)