Best Python code snippet using localstack_python
deep_rover.py
Source:deep_rover.py
...141 while not self.user_ack:142 time.sleep(1)143 print("Recieved ACK")144 self.user_ack = False145 self._update_done(False)146 return self._observe()147 def _update_done(self, done):148 self.done = done149 if self.state_changed:150 self.state_changed()151 def _observe(self):152 self.obs = self.cam.capture()153 if not self._is_safe():154 reward = 0155 self._update_done(True)156 else:157 reward = 1158 self._update_done(False)159 160 return (self.obs, self.dist, reward, self.done, {})161 def step(self, move):162 if self.done:163 return (self.obs, self.dist, 0, self.done, {})164 if move == Move.FORWARD and not self._is_safe():165 self._update_done(True)166 return (self.obs, self.dist, 0, self.done, {})167 prev_image = self.obs[1]168 prev_dist = self.dist169 self._step_robot(move)170 result = self._observe()171 self.sessionObserver.write(prev_image, self.dist, int(move), result[0][1], result[1], result[2], result[3], result[4])172 return result173 def _step_robot(self, move):174 robot_move_fns[move]()175 time.sleep(0.2)176 robot_move_fns[Move.STOP]()177def random_policy(obs):178 return choice(list(Move)[1:])179policy = random_policy...
lambda_test_util.py
Source:lambda_test_util.py
...3from localstack.utils.common import to_str4from localstack.utils.generic.wait_utils import ShortCircuitWaitException5def update_done(client, function_name):6 """wait fn for checking 'LastUpdateStatus' of lambda"""7 def _update_done():8 last_update_status = client.get_function_configuration(FunctionName=function_name)[9 "LastUpdateStatus"10 ]11 if last_update_status == "Failed":12 raise ShortCircuitWaitException(f"Lambda Config update failed: {last_update_status=}")13 else:14 return last_update_status == "Successful"15 return _update_done16def concurrency_update_done(client, function_name, qualifier):17 """wait fn for ProvisionedConcurrencyConfig 'Status'"""18 def _concurrency_update_done():19 status = client.get_provisioned_concurrency_config(20 FunctionName=function_name, Qualifier=qualifier21 )["Status"]22 if status == "FAILED":23 raise ShortCircuitWaitException(f"Concurrency update failed: {status=}")24 else:25 return status == "READY"26 return _concurrency_update_done27def get_invoke_init_type(28 client, function_name, qualifier29) -> Literal["on-demand", "provisioned-concurrency"]:30 """check the environment in the lambda for AWS_LAMBDA_INITIALIZATION_TYPE indicating ondemand/provisioned"""31 invoke_result = client.invoke(FunctionName=function_name, Qualifier=qualifier)32 return json.loads(to_str(invoke_result["Payload"].read()))["env"][...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!