def test_GirderUploadVolumePathToItem_transform_accepts_ObjectId(
        mock_gc, bogus_volume):
    vp = VolumePath('test', bogus_volume)
    hash = '5a5fc09ec2231b9487ce42db'
    GirderUploadVolumePathToItem(vp, ObjectId(hash), gc=mock_gc).transform()
    mock_gc.uploadFileToItem.assert_called_once_with(
        hash, os.path.join(BOGUS_CONTAINER_PATH, 'test'))
Ejemplo n.º 2
0
    def test_docker_run_file_upload_to_item(self, params):
        item_id = params.get('itemId')
        contents = params.get('contents')

        volumepath = VolumePath('test_file')

        result = docker_run.delay(
            TEST_IMAGE, pull_image=True,
            container_args=['write', '-p', volumepath, '-m', contents],
            remove_container=True,
            girder_result_hooks=[GirderUploadVolumePathToItem(volumepath, item_id)])

        return result.job
Ejemplo n.º 3
0
def _createThumbnail(item):
    # Remove previously attached thumbnails
    _removeThumbnails(item, saveItem=True)

    outdir = VolumePath('__thumbnails_output__')
    return docker_run.delay(
        'girder/dicom_thumbnailer:latest',
        container_args=[
            '--slices',
            str(THUMB_SLICES), '--width',
            str(THUMB_WIDTH), '--height',
            str(THUMB_HEIGHT),
            GirderItemIdToVolume(item['_id'], item_name=item['name']), outdir
        ],
        girder_job_title='DICOM thumbnail generation: %s' % item['name'],
        girder_result_hooks=[
            GirderUploadVolumePathToItem(
                outdir,
                item['_id'],
                upload_kwargs={
                    'reference': json.dumps({'interactive_thumbnail': True})
                })
        ]).job
Ejemplo n.º 4
0
def _createThumbnail(item, preset):
    # Remove previously attached thumbnails
    _removeThumbnails(item, saveItem=True)

    outdir = VolumePath('__thumbnails_output__')
    return docker_run.delay(
        'zachmullen/3d_thumbnails:latest',
        container_args=[
            '--angle-step',
            str(_ANGLE_STEP), '--width',
            str(_SIZE), '--height',
            str(_SIZE), '--preset', preset,
            GirderItemIdToVolume(item['_id'], item_name=item['name']), outdir
        ],
        girder_job_title='Interactive thumbnail generation: %s' % item['name'],
        girder_result_hooks=[
            GirderUploadVolumePathToItem(
                outdir,
                item['_id'],
                upload_kwargs={
                    'reference': json.dumps({'interactive_thumbnail': True})
                })
        ]).job
def test_GirderUploadVolumePathToItem_transform_calls_gc_uploadFile(
        mock_gc, bogus_volume):
    vp = VolumePath('test', bogus_volume)
    GirderUploadVolumePathToItem(vp, 'BOGUS_ITEM_ID', gc=mock_gc).transform()
    mock_gc.uploadFileToItem.assert_called_once_with(
        'BOGUS_ITEM_ID', os.path.join(BOGUS_CONTAINER_PATH, 'test'))
def test_girderUploadVolumePathToItem_transform_returns_item_id(
        mock_gc, bogus_volume):
    vp = VolumePath('test', bogus_volume)

    guvpti = GirderUploadVolumePathToItem(vp, 'BOGUS_ITEM_ID', gc=mock_gc)
    assert guvpti.transform() == 'BOGUS_ITEM_ID'