Best Python code snippet using lisa_python
process.py
Source:process.py
...47 "passed as parameter expected_exit_code. Must be int or "48 "List[int]"49 )50 return assert_that(expected_exit_codes, message).contains(self.exit_code)51 def save_stdout_to_file(self, saved_path: Path) -> "ExecutableResult":52 with open(saved_path, "w") as f:53 f.write(self.stdout)54 return self55# TODO: So much cleanup here. It was using duck typing.56class Process:57 def __init__(58 self,59 id_: str,60 shell: Shell,61 parent_logger: Optional[Logger] = None,62 ) -> None:63 # the shell can be LocalShell or SshShell64 self._shell = shell65 self._id_ = id_...
experiment_template.py
Source:experiment_template.py
...72 'address': 'auto',73}74script_name = os.path.basename(__file__).strip('.py')75fname = f'log_{script_name}_{datetime.now().strftime("%y%m%d_%H%M")}.txt'76BruteLogger.save_stdout_to_file(path=exp_config['log_dir'], fname=fname, encoding='utf8', also_stderr=True)77assert not (exp_config['use_cma_ipop'] and exp_config['use_dibb_ipop']), 'It is not recommended to use both CMA-IPOP and DIBB-IPOP at the same time'78if exp_config['use_notify']:79 from notify_run import Notify80 notify = Notify()81 82ray.init(**ray_config)83def format_time(seconds):84 hh = int(seconds // 3600)85 mm = int(seconds % 3600 // 60)86 ss = int(seconds % 3600 % 60)87 return f'{hh:02}h {mm:02}m {ss:02}s'88def RemCocoWrapper(rem_coco):89 """Filters the relevant problems and uses tqdm to track progress.."""90 return tqdm(rem_coco.problems,...
experiment.py
Source:experiment.py
...21 assert (not self.cfg['resume']) or (not self.cfg['timestamp']), "Cannot resume experiment with timestamp activated"22 assert (not self.cfg['transfer'] == 'sequential') or (not self.cfg['resume']), "Cannot resume training on sequential"23 self.make_paths()24 # Setup logger25 BruteLogger.save_stdout_to_file(path=self.paths['logs'])26 # Resolve CPU threads and cuda device27 torch.set_num_threads(self.cfg['trg_n_cpu'])28 if torch.cuda.is_available():29 # Need to have a GPU and to precise it at the end of the experiment file name30 # Or in the terminal after the file name31 # Assertion blocks if we cannot cast to int, i.e. last part of experiment file name is not an int32 assert isinstance(int(self.cfg['trg_gpu']), int), "Please precise your GPU at the end of the experiment file name"33 # Will anyway stop if the index is not available or wrong34 self.cuda_device = f"cuda:{int(self.cfg['trg_gpu'])}"35 # Otherwise just go with CPU36 else:37 self.cuda_device = 'cpu'38 torch.set_num_threads(self.cfg['trg_n_cpu'])39 # Give a dropout, learning rate, optimizer and loss function specific to each DMs...
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!!