def actual_file(): vp = os.path.dirname(__file__) path = os.path.join(vp, 'foo.txt') open(path, 'a').close() volume = BindMountVolume(vp, vp) yield path, VolumePath('foo.txt', volume=volume) os.unlink(path)
def resolve_direct_file_path(self): if not self._direct_file_path: return None path = abspath(self._direct_file_path) if isfile(path) and access(path, R_OK): self._direct_container_path = join(TEMP_VOLUME_DIRECT_MOUNT_PREFIX, self._filename) return BindMountVolume(path, self._direct_container_path, mode='ro') return None
def test_docker_run_mount_idiomatic_volume(self, params): fixture_dir = params.get('fixtureDir') filename = 'read.txt' mount_dir = '/mnt/test' mount_path = os.path.join(mount_dir, filename) volume = BindMountVolume(fixture_dir, mount_path, 'ro') volumepath = VolumePath(filename, volume) result = docker_run.delay( TEST_IMAGE, pull_image=True, container_args=['read', '-p', volumepath], remove_container=True, volumes=[volume]) return result.job
def bogus_volume(): yield BindMountVolume(BOGUS_HOST_PATH, BOGUS_CONTAINER_PATH)
def generatePointCloud(initWorkingSetName, stepName, requestInfo, jobId, outputFolder, imageFiles, longitude, latitude, longitudeWidth, latitudeWidth): """ Run a Girder Worker job to generate a 3D point cloud from 2D images. Requirements: - P3D Girder Worker Docker image is available on host - Host folder /mnt/GTOPO30 contains GTOPO 30 data :param initWorkingSetName: The name of the top-level working set. :type initWorkingSetName: str :param stepName: The name of the step. :type stepName: str (DanesfieldStep) :param requestInfo: HTTP request and authorization info. :type requestInfo: RequestInfo :param jobId: Job ID. :type jobId: str :param outputFolder: Output folder document. :type outputFolder: dict :param imageFiles: List of input image files. :type imageFiles: list[dict] :param longitude: :type longitude: :param latitude: :type latitude: :param longitudeWidth: :type longitudeWidth: :param latitudeWidth: :type latitudeWidth: :returns: Job document. """ gc = createGirderClient(requestInfo) # Docker volumes volumes = [ BindMountVolume(host_path='/mnt/GTOPO30', container_path='/P3D/GTOPO30', mode='ro') ] outputVolumePath = VolumePath('__output__') # Docker container arguments # TODO: Consider a solution where args are written to a file, in # case of very long command lines containerArgs = list(itertools.chain( [ 'python', '/P3D/RTN_distro/scripts/generate_point_cloud.pyc', '--out', outputVolumePath, '--longitude', str(longitude), '--latitude', str(latitude), '--longitudeWidth', str(longitudeWidth), '--latitudeWidth', str(latitudeWidth), '--firstProc', '0', '--threads', '8', '--images' ], [GirderFileIdToVolume(imageFile['_id'], gc=gc) for imageFile in imageFiles], )) # Result hooks # - Upload output files to output folder # - Provide upload metadata upload_kwargs = createUploadMetadata(jobId, stepName) resultHooks = [ GirderUploadVolumePathToFolder( outputVolumePath, outputFolder['_id'], upload_kwargs=upload_kwargs, gc=gc) ] asyncResult = docker_run.delay( volumes=volumes, **createDockerRunArguments( image=DockerImage.P3D, containerArgs=containerArgs, jobTitle='[%s] Generate point cloud' % initWorkingSetName, jobType=stepName, user=requestInfo.user, resultHooks=resultHooks ) ) # Add info for job event listeners job = asyncResult.job job = addJobInfo(job, jobId=jobId, stepName=stepName) return job