Skip to content

vfs

VFSProcessManager

Bases: object

build_launch_command(mount_point)

Build command to pass to Popen to launch VFS :param mount_point: directory to mount which must be the first parameter seen by our executable :return: command

create_mount_point(mount_point) classmethod

By default fuse won't create our mount folder, create it if it doesn't exist

find_vfs() classmethod

Determine where the VFS executable we'll be launching lives so we can find the correct relative paths around it for LD_LIBRARY_PATH and config files :return: Path to VFS executable

find_vfs_launch_script() classmethod

Determine where the VFS launch script lives so we can build the launch command :return: Path to VFS launch script

Get the path where links to any necessary executables which should be added to the path should live :returns: Path to the link folder

get_cwd() classmethod

Determine the cwd we should hand to Popen. We expect a config/logging.ini file to exist relative to this folder.

get_launch_environ()

Get the environment variables we'll pass to the launch command. :returns: dictionary of default environment variables with VFS changes applied

get_library_path() classmethod

Find our library dependencies which should be at ../lib relative to our executable

get_logs_folder()

Find the folder we expect VFS logs to be written to

get_manifest_path_for_mount(session_dir, mount_point) classmethod

Given a mount_point this searches the pid file for the associated manifest path.

:param session_dir: tmp directory for session :param mount_point: local directory associated with the desired manifest

:returns: Path to the manifest file for mount if there is one

get_shutdown_args(mount_path, os_user) classmethod

Return the argument list to provide the subprocess run command to shut down the mount :param mount_path: path to mounted folder :param os_user: the user running the job.

is_mount(path) classmethod

os.path.ismount returns false for libfuse mounts owned by "other users", use findmnt instead

kill_all_processes(session_dir, os_user) classmethod

Kill all existing VFS processes when outputs have been uploaded. :param session_dir: tmp directory for session :param os_user: the user running the job.

kill_process_at_mount(session_dir, mount_point, os_user) classmethod

Kill the VFS instance running at the given mount_point and modify the VFS pid tracking file to remove the entry.

:param session_dir: tmp directory for session :param mount_point: local directory to search for :param os_user: user to attempt shut down as

logs_folder_path(session_dir) classmethod

Find the folder we expect VFS logs to be written to

print_log_end(session_dir, log_file_name='vfs_log.txt', lines=100, log_level=logging.WARNING) classmethod

Print out the end of our VFS Log. Reads the full log file into memory. Our VFS logs are size capped so this is not an issue for the intended use case. :param session_dir: Session folder for mount :param log_file_name: Name of file within the logs folder to read from. Defaults to vfs_log.txt which is our "most recent" log file. :param lines: Maximum number of lines from the end of the log to print :param log_level: Level to print logging as

set_manifest_owner()

Set the manifest path to be owned by _os_user

shutdown_libfuse_mount(mount_path, os_user, session_dir) classmethod

Shut down the mount at the provided path using the fusermount3 unmount option as the provided user :param mount_path: path to mounted folder

start(session_dir)

Start our VFS process :return: VFS process id

wait_for_mount(mount_path, session_dir, mount_wait_seconds=60, expected=True) classmethod

After we've launched the VFS subprocess we need to wait for the OS to validate that the mount is in place before use :param mount_path: Path to mount to watch for :param session_dir: Session folder associated with mount :param mount_wait_seconds: Duration to wait for mount state :param expected: Wait for the mount to exist or no longer exist