def test_add_sample_stage(ws): models.add_project(name='Manhattan', sample_mask='man-###') models.add_sample(project_id='PqrX9', name='sample 1') models.add_method(name='X-ray tomography', description='Placeholder description.') t = models._sample_stage_token_hashid().encode(0) m = models.add_sample_stage( sample_id='OQn6Q', method_id='XZOQ0', token=t, annotation='Annotation') assert 1 == m.id assert 'Drn1Q' == m.obfuscated_id assert None == m.alt_id assert 'Annotation' == m.annotation assert 1 == m._sample_id assert 'OQn6Q' == m.sample_id assert 1 == m._method_id assert 'XZOQ0' == m.method_id
def test_add_sample(ws): models.add_project(name='Manhattan', sample_mask='man-###') m = models.add_sample(project_id='PqrX9', name='sample 1') assert 1 == m.id assert 'OQn6Q' == m.obfuscated_id assert 'sample 1' == m.name assert 1 == m._project_id assert 'PqrX9' == m.project_id
def sample(ws): project = models.add_project(name='Manhattan', sample_mask='man-###') sample = models.add_sample(project_id='PqrX9', name='sample 1') method = models.add_method(name='X-ray tomography', description='Placeholder description.') return {'app' : ws, 'project' : project, 'sample' : sample, 'method' : method}
def test_add_sample_stage(ws): models.add_project(name='Manhattan', sample_mask='man-###') models.add_sample(project_id='PqrX9', name='sample 1') models.add_method(name='X-ray tomography', description='Placeholder description.') t = models._sample_stage_token_hashid().encode(0) m = models.add_sample_stage(sample_id='OQn6Q', method_id='XZOQ0', token=t, annotation='Annotation') assert 1 == m.id assert 'Drn1Q' == m.obfuscated_id assert None == m.alt_id assert 'Annotation' == m.annotation assert 1 == m._sample_id assert 'OQn6Q' == m.sample_id assert 1 == m._method_id assert 'XZOQ0' == m.method_id
root = '/mnt/adapt/analysis/inconel/versa-data/P001-B001/Uncompressed' project = 'PqrX9' method = 'XZOQ0' labelled = collect( lambda m: m['label'], map( parse_fpath, find(root, '^((?!.*Multiple_Images).)*\.(xrm|txm|txrm|tar|tif|avi)$'))) errors = [] for s in map(lambda x: x.split('-')[0], labelled.keys()): try: m.add_sample(project, s) except Exception as e: errors.append(e) upload_root = config.UPLOAD_PATH builders = [ stage_builder(method, label, map(lambda m: m['path'], labelled[label])) for label in labelled.keys() ] errors = [] for builderfn in builders: try: builderfn() except Exception as e: errors.append(e)
def sample(ws): project = models.add_project(name='Manhattan', sample_mask='man-###') sample = models.add_sample(project_id='PqrX9', name='sample 1') method = models.add_method(name='X-ray tomography', description='Placeholder description.') return {'app': ws, 'project': project, 'sample': sample, 'method': method}
st.with_files(files) return st.to_sample(sample(parts[0]).obfuscated_id) if __name__ == "__example__": import app import app.models as m import config import os root = '/mnt/adapt/analysis/inconel/versa-data/P001-B001/Uncompressed' project = 'PqrX9' method = 'XZOQ0' labelled = collect(lambda m: m['label'], map(parse_fpath, find(root, '^((?!.*Multiple_Images).)*\.(xrm|txm|txrm|tar|tif|avi)$'))) errors = [] for s in map(lambda x: x.split('-')[0], labelled.keys()): try: m.add_sample(project, s) except Exception as e: errors.append(e) upload_root = config.UPLOAD_PATH builders = [stage_builder(method, label, map(lambda m: m['path'], labelled[label])) for label in labelled.keys()] errors = [] for builderfn in builders: try: builderfn() except Exception as e: errors.append(e)