def test_stitchedmeshes_with_badobject(setup_stitchedmeshes_config): template_dir, config, _dvid_address, _repo_uuid, object_boxes = setup_stitchedmeshes_config # Body 250 doesn't exist, but it shouldn't fail the whole workflow. config["stitchedmeshes"]["bodies"] = [250,300] dump_config(config, f"{template_dir}/workflow.yaml") execution_dir, _workflow = launch_flow(template_dir, 1) #final_config = workflow.config assert os.path.exists(f"{execution_dir}/meshes/300.obj") mesh300 = Mesh.from_file(f"{execution_dir}/meshes/300.obj") assert (mesh300.vertices_zyx[:] >= object_boxes[2][0]).all() assert (mesh300.vertices_zyx[:] <= object_boxes[2][1]).all() # Here's where our test meshes ended up: #print(f"{execution_dir}/meshes/300.obj") #print(f'{execution_dir}/mesh-stats.csv') df = pd.read_csv(f'{execution_dir}/mesh-stats.csv') assert len(df) == 4 df.set_index('body', inplace=True) assert df.loc[250, 'result'] == 'error' # intentional error assert df.loc[300, 'result'] == 'success'
def check_outputs(execution_dir, object_boxes, subset_labels=None, skipped_labels=[], stats_dir=None, max_vertices=None): """ Basic checks to make sure the meshes for the given labels were generated and not terribly wrong. """ stats_dir = stats_dir or execution_dir # Check all test objects by default. if subset_labels is None: subset_labels = sorted(object_boxes.keys()) df = pd.DataFrame( np.load(f'{stats_dir}/mesh-stats.npy', allow_pickle=True) ) assert len(df) == (len(subset_labels) + len(skipped_labels)) df.set_index('body', inplace=True) for label in subset_labels: assert df.loc[label, 'result'] == 'success' # Here's where our test meshes ended up: #print(f"{execution_dir}/meshes/{label}.obj") assert os.path.exists(f"{execution_dir}/meshes/{label}.ngmesh") # Make sure the mesh vertices appeared in the right place. # (If they weren't rescaled, this won't work.) mesh = Mesh.from_file(f"{execution_dir}/meshes/{label}.ngmesh") assert np.allclose(mesh.vertices_zyx.min(axis=0), object_boxes[label][0], 1) assert np.allclose(mesh.vertices_zyx.max(axis=0), object_boxes[label][1], 1) if max_vertices is not None: assert len(mesh.vertices_zyx) <= 1.1*max_vertices
def test_stitchedmeshes(setup_stitchedmeshes_config, disable_auto_retry): template_dir, _config, _dvid_address, _repo_uuid, object_boxes = setup_stitchedmeshes_config execution_dir, _workflow = launch_flow(template_dir, 1) #final_config = workflow.config assert os.path.exists(f"{execution_dir}/meshes/100.obj") assert os.path.exists(f"{execution_dir}/meshes/200.obj") assert os.path.exists(f"{execution_dir}/meshes/300.obj") # Make sure the mesh vertices appeared in the right place. # (If they weren't rescaled, this won't work.) mesh100 = Mesh.from_file(f"{execution_dir}/meshes/100.obj") assert (mesh100.vertices_zyx[:] >= object_boxes[0][0]).all() assert (mesh100.vertices_zyx[:] <= object_boxes[0][1]).all() mesh200 = Mesh.from_file(f"{execution_dir}/meshes/200.obj") assert (mesh200.vertices_zyx[:] >= object_boxes[1][0]).all() assert (mesh200.vertices_zyx[:] <= object_boxes[1][1]).all() mesh300 = Mesh.from_file(f"{execution_dir}/meshes/300.obj") assert (mesh300.vertices_zyx[:] >= object_boxes[2][0]).all() assert (mesh300.vertices_zyx[:] <= object_boxes[2][1]).all() # Here's where our test meshes ended up: #print(f"{execution_dir}/meshes/100.obj") #print(f"{execution_dir}/meshes/200.obj") #print(f"{execution_dir}/meshes/300.obj") #print(f'{execution_dir}/mesh-stats.csv') df = pd.read_csv(f'{execution_dir}/mesh-stats.csv') assert len(df) == 3 df.set_index('body', inplace=True) assert df.loc[100, 'result'] == 'success' assert df.loc[200, 'result'] == 'success' assert df.loc[300, 'result'] == 'success'