Best Python code snippet using localstack_python
init_mode.py
Source:init_mode.py
...7def init(data, state):8 if g.mode == "Create new Project":9 state["classifierStatus"] = "No trained classifier detected"10 selected_classes = json.loads(os.environ["modal.state.classes"].replace("'", '"'))11 init_directories.init_directories()12 if len(selected_classes) < 2:13 raise Exception("At least 2 classes must be selected")14 else:15 state["classifierStatus"] = None16 init_directories.init_directories()17def init_ex_project():18 for file in os.listdir(init_directories.proj_dir):19 if file.endswith(".ilp"):20 g.api.app.set_field(g.task_id, "state.classifierStatus", file)21 os.rename(os.path.join(init_directories.proj_dir, file),22 os.path.join(init_directories.proj_dir, f"{g.project.name}.ilp"))23 break24 ex_meta_json = sly.json.load_json_file(os.path.join(init_directories.proj_dir, "meta.json"))25 ex_meta = sly.ProjectMeta.from_json(ex_meta_json)26 selected_classes = [obj_class.name for obj_class in ex_meta.obj_classes]27 if len(selected_classes) < 2:28 raise Exception("At least 2 classes must be selected")29 g.project_meta = g.project_meta.merge(ex_meta)30 g.api.project.update_meta(g.project_id, g.project_meta.to_json())...
directories.py
Source:directories.py
1import os2class Directories:3 def __init__(self):4 self.init_directories()5 def init_directories(self):6 self.__project_dir = os.getcwd()7 self.__chkpt_dir = '/chkpts/'8 self.__log_dir = '/log/'9 self.__rgb_image_dir = '/FlyingChairs/data/'10 self.__flow_image_dir = '/FlyingChairs/data/'11 self.__rgb_format = '.ppm'12 self.__flow_format = '.flo'13 self.__training_dir = 'training/'14 self.__validation_dir = 'validation/'15 self.__networks_dir = '/networks/'16 def update_for_task(self, current_dir, network_dir):17 self.init_directories()18 self.__networks_dir = current_dir + self.__networks_dir19 self.__chkpt_dir = network_dir + self.__chkpt_dir20 self.__log_dir = network_dir + self.__log_dir21 self.__rgb_image_dir = current_dir + self.__rgb_image_dir22 self.__flow_image_dir = current_dir + self.__flow_image_dir23 # Getters #24 #---------#25 @property26 def project_dir(self):27 return self.__project_dir28 @property29 def networks_dir(self):30 return self.__networks_dir31 @property...
run_dataset_generation.py
Source:run_dataset_generation.py
1from data import generate_dataset2from init_directories import init_directories3from data import generate_pickle_dataset_xml4init_directories()5generate_dataset()...
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!!