コード例 #1
0
def confirm_remote_folder(local_folder, remote_folder):
    local_folder = Path(local_folder)
    remote_folder = Path(remote_folder)
    local_folder = folders.subjects_data_folder(local_folder)
    remote_folder = folders.subjects_data_folder(remote_folder)

    src_session_paths = [
        x.parent for x in local_folder.rglob("transfer_me.flag")
    ]

    if not src_session_paths:
        log.info("Nothing to transfer, exiting...")
        return

    for session_path in src_session_paths:
        print(f"\nFound session: {session_path}")
        resp = input(
            f"Transfer to {remote_folder} with the same name ([y]/n/skip/exit)? "
        ) or 'y'
        print(resp)
        if resp not in ['y', 'n', 'skip', 'exit']:
            return confirm_remote_folder(local_folder, remote_folder)
        elif resp == 'y':
            transfer_session(session_path, remote_folder, force=False)
        elif resp == 'n':
            new_session_path = rename_session(session_path)
            transfer_session(new_session_path, remote_folder)
        elif resp == 'skip':
            continue
        elif resp == 'exit':
            return
コード例 #2
0
ファイル: misc.py プロジェクト: EXYNOS-999/ibllib
def confirm_video_remote_folder(local_folder=False,
                                remote_folder=False,
                                force=False):
    pars = load_videopc_params()

    if not local_folder:
        local_folder = pars['DATA_FOLDER_PATH']
    if not remote_folder:
        remote_folder = pars['REMOTE_DATA_FOLDER_PATH']
    local_folder = Path(local_folder)
    remote_folder = Path(remote_folder)
    # Check for Subjects folder
    local_folder = folders.subjects_data_folder(local_folder, rglob=True)
    remote_folder = folders.subjects_data_folder(remote_folder, rglob=True)

    print('LOCAL:', local_folder)
    print('REMOTE:', remote_folder)
    src_session_paths = [
        x.parent for x in local_folder.rglob("transfer_me.flag")
    ]

    if not src_session_paths:
        print("Nothing to transfer, exiting...")
        return

    for session_path in src_session_paths:
        print(f"\nFound session: {session_path}")
        flag_file = session_path / 'transfer_me.flag'
        msg = f"Transfer to {remote_folder} with the same name?"
        resp = input(msg + "\n[y]es/[r]ename/[s]kip/[e]xit\n ^\n> ") or 'y'
        resp = resp.lower()
        print(resp)
        if resp not in ['y', 'r', 's', 'e', 'yes', 'rename', 'skip', 'exit']:
            return confirm_video_remote_folder(local_folder=local_folder,
                                               remote_folder=remote_folder,
                                               force=force)
        elif resp == 'y' or resp == 'yes':
            pass
        elif resp == 'r' or resp == 'rename':
            session_path = rename_session(session_path)
        elif resp == 's' or resp == 'skip':
            continue
        elif resp == 'e' or resp == 'exit':
            return

        remote_session_path = remote_folder / Path(*session_path.parts[-3:])
        if not behavior_exists(remote_session_path):
            print(
                f"No behavior folder found in {remote_session_path}: skipping session..."
            )
            return
        transfer_folder(session_path / 'raw_video_data',
                        remote_session_path / 'raw_video_data',
                        force=force)
        flag_file.unlink()
        create_video_transfer_done_flag(remote_session_path)
        check_create_raw_session_flag(remote_session_path)
コード例 #3
0
def confirm_video_remote_folder(local_folder=False,
                                remote_folder=False,
                                force=False):
    pars = load_videopc_params()

    if not local_folder:
        local_folder = pars["DATA_FOLDER_PATH"]
    if not remote_folder:
        remote_folder = pars["REMOTE_DATA_FOLDER_PATH"]
    local_folder = Path(local_folder)
    remote_folder = Path(remote_folder)
    # Check for Subjects folder
    local_folder = folders.subjects_data_folder(local_folder, rglob=True)
    remote_folder = folders.subjects_data_folder(remote_folder, rglob=True)

    print("LOCAL:", local_folder)
    print("REMOTE:", remote_folder)
    src_session_paths = [
        x.parent for x in local_folder.rglob("transfer_me.flag")
    ]

    if not src_session_paths:
        print("Nothing to transfer, exiting...")
        return

    for session_path in src_session_paths:
        print(f"\nFound session: {session_path}")
        flag_file = session_path / "transfer_me.flag"
        msg = f"Transfer to {remote_folder} with the same name?"
        resp = input(msg + "\n[y]es/[r]ename/[s]kip/[e]xit\n ^\n> ") or "y"
        resp = resp.lower()
        print(resp)
        if resp not in ["y", "r", "s", "e", "yes", "rename", "skip", "exit"]:
            return confirm_video_remote_folder(local_folder=local_folder,
                                               remote_folder=remote_folder,
                                               force=force)
        elif resp == "y" or resp == "yes":
            pass
        elif resp == "r" or resp == "rename":
            session_path = rename_session(session_path)
        elif resp == "s" or resp == "skip":
            continue
        elif resp == "e" or resp == "exit":
            return

        remote_session_path = remote_folder / Path(*session_path.parts[-3:])
        if not behavior_exists(remote_session_path):
            print(
                f"No behavior folder found in {remote_session_path}: skipping session..."
            )
            return
        transfer_folder(session_path / "raw_video_data",
                        remote_session_path / "raw_video_data",
                        force=force)
        flag_file.unlink()
        create_video_transfer_done_flag(remote_session_path)
        check_create_raw_session_flag(remote_session_path)
コード例 #4
0
ファイル: misc.py プロジェクト: ekellbuch/ibllib
def confirm_ephys_remote_folder(local_folder=False,
                                remote_folder=False,
                                force=False,
                                iblscripts_folder=False):
    pars = load_ephyspc_params()

    if not local_folder:
        local_folder = pars['DATA_FOLDER_PATH']
    if not remote_folder:
        remote_folder = pars['REMOTE_DATA_FOLDER_PATH']
    local_folder = Path(local_folder)
    remote_folder = Path(remote_folder)
    # Check for Subjects folder
    local_folder = folders.subjects_data_folder(local_folder, rglob=True)
    remote_folder = folders.subjects_data_folder(remote_folder, rglob=True)

    print('LOCAL:', local_folder)
    print('REMOTE:', remote_folder)
    src_session_paths = [
        x.parent for x in local_folder.rglob("transfer_me.flag")
    ]

    if not src_session_paths:
        print("Nothing to transfer, exiting...")
        return

    for session_path in src_session_paths:
        print(f"\nFound session: {session_path}")
        # Rename ephys files
        rename_ephys_files(str(session_path))
        # Move ephys files
        move_ephys_files(str(session_path))
        # Copy wiring files
        copy_wiring_files(str(session_path), iblscripts_folder)
        flag_file = session_path / 'transfer_me.flag'
        msg = f"Transfer to {remote_folder} with the same name?"
        resp = input(msg + "\n[y]es/[r]ename/[s]kip/[e]xit\n ^\n> ") or 'y'
        resp = resp.lower()
        print(resp)
        if resp not in ['y', 'r', 's', 'e', 'yes', 'rename', 'skip', 'exit']:
            return confirm_ephys_remote_folder(local_folder=local_folder,
                                               remote_folder=remote_folder)
        elif resp == 'y' or resp == 'yes':
            remote_session_path = remote_folder / Path(
                *session_path.parts[-3:])
            if not behavior_exists(remote_session_path):
                print(
                    f"No behavior folder found in {remote_session_path}: skipping session..."
                )
                continue
            transfer_folder(session_path / 'raw_ephys_data',
                            remote_session_path / 'raw_ephys_data',
                            force=force)
            flag_file.unlink()
            if (remote_session_path / 'extract_me.flag').exists():
                (remote_session_path / 'extract_me.flag').unlink()
        elif resp == 'r' or resp == 'rename':
            new_session_path = rename_session(session_path)
            remote_session_path = remote_folder / Path(
                *new_session_path.parts[-3:])
            if not behavior_exists(remote_session_path):
                print(
                    f"No behavior folder found in {remote_session_path}: skipping session..."
                )
                continue
            transfer_folder(new_session_path / 'raw_ephys_data',
                            remote_session_path / 'raw_ephys_data')
            flag_file.unlink()
            # if behavior extract_me.flag exists remove it, no need because of ephys flag
            if (remote_session_path / 'extract_me.flag').exists():
                (remote_session_path / 'extract_me.flag').unlink()
        elif resp == 's' or resp == 'skip':
            continue
        elif resp == 'e' or resp == 'exit':
            return
コード例 #5
0
ファイル: misc.py プロジェクト: EXYNOS-999/ibllib
def confirm_ephys_remote_folder(local_folder=False,
                                remote_folder=False,
                                force=False,
                                iblscripts_folder=False):
    pars = load_ephyspc_params()

    if not local_folder:
        local_folder = pars['DATA_FOLDER_PATH']
    if not remote_folder:
        remote_folder = pars['REMOTE_DATA_FOLDER_PATH']
    local_folder = Path(local_folder)
    remote_folder = Path(remote_folder)
    # Check for Subjects folder
    local_folder = folders.subjects_data_folder(local_folder, rglob=True)
    remote_folder = folders.subjects_data_folder(remote_folder, rglob=True)

    print('LOCAL:', local_folder)
    print('REMOTE:', remote_folder)
    src_session_paths = [
        x.parent for x in local_folder.rglob("transfer_me.flag")
    ]

    if not src_session_paths:
        print("Nothing to transfer, exiting...")
        return

    for session_path in src_session_paths:
        print(f"\nFound session: {session_path}")
        # Rename ephys files
        # FIXME: if transfer has failed and wiring file is there renaming will fail!
        rename_ephys_files(str(session_path))
        # Move ephys files
        move_ephys_files(str(session_path))
        # Copy wiring files
        copy_wiring_files(str(session_path), iblscripts_folder)
        try:
            create_alyx_probe_insertions(str(session_path))
        except BaseException as e:
            print(
                e,
                "\nCreation failed, please create the probe insertions manually.",
                "Continuing transfer...")
        msg = f"Transfer to {remote_folder} with the same name?"
        resp = input(msg + "\n[y]es/[r]ename/[s]kip/[e]xit\n ^\n> ") or 'y'
        resp = resp.lower()
        print(resp)
        if resp not in ['y', 'r', 's', 'e', 'yes', 'rename', 'skip', 'exit']:
            return confirm_ephys_remote_folder(
                local_folder=local_folder,
                remote_folder=remote_folder,
                force=force,
                iblscripts_folder=iblscripts_folder)
        elif resp == 'y' or resp == 'yes':
            pass
        elif resp == 'r' or resp == 'rename':
            session_path = rename_session(session_path)
        elif resp == 's' or resp == 'skip':
            continue
        elif resp == 'e' or resp == 'exit':
            return

        remote_session_path = remote_folder / Path(*session_path.parts[-3:])
        if not behavior_exists(remote_session_path):
            print(
                f"No behavior folder found in {remote_session_path}: skipping session..."
            )
            return
        transfer_folder(session_path / 'raw_ephys_data',
                        remote_session_path / 'raw_ephys_data',
                        force=force)
        # if behavior extract_me.flag exists remove it, because of ephys flag
        flag_file = session_path / 'transfer_me.flag'
        flag_file.unlink()
        if (remote_session_path / 'extract_me.flag').exists():
            (remote_session_path / 'extract_me.flag').unlink()
        # Create remote flags
        create_ephys_transfer_done_flag(remote_session_path)
        check_create_raw_session_flag(remote_session_path)
コード例 #6
0
def confirm_ephys_remote_folder(local_folder=False,
                                remote_folder=False,
                                force=False,
                                iblscripts_folder=False):
    pars = load_ephyspc_params()

    if not local_folder:
        local_folder = pars["DATA_FOLDER_PATH"]
    if not remote_folder:
        remote_folder = pars["REMOTE_DATA_FOLDER_PATH"]
    local_folder = Path(local_folder)
    remote_folder = Path(remote_folder)
    # Check for Subjects folder
    local_folder = folders.subjects_data_folder(local_folder, rglob=True)
    remote_folder = folders.subjects_data_folder(remote_folder, rglob=True)

    print("LOCAL:", local_folder)
    print("REMOTE:", remote_folder)
    src_session_paths = [
        x.parent for x in local_folder.rglob("transfer_me.flag")
    ]

    if not src_session_paths:
        print("Nothing to transfer, exiting...")
        return

    for session_path in src_session_paths:
        print(f"\nFound session: {session_path}")
        # Rename ephys files
        # FIXME: if transfer has failed and wiring file is there renaming will fail!
        rename_ephys_files(str(session_path))
        # Move ephys files
        move_ephys_files(str(session_path))
        # Copy wiring files
        copy_wiring_files(str(session_path), iblscripts_folder)
        try:
            create_alyx_probe_insertions(str(session_path))
        except BaseException as e:
            print(
                e,
                "\nCreation failed, please create the probe insertions manually.",
                "Continuing transfer...",
            )
        msg = f"Transfer to {remote_folder} with the same name?"
        resp = input(msg + "\n[y]es/[r]ename/[s]kip/[e]xit\n ^\n> ") or "y"
        resp = resp.lower()
        print(resp)
        if resp not in ["y", "r", "s", "e", "yes", "rename", "skip", "exit"]:
            return confirm_ephys_remote_folder(
                local_folder=local_folder,
                remote_folder=remote_folder,
                force=force,
                iblscripts_folder=iblscripts_folder,
            )
        elif resp == "y" or resp == "yes":
            pass
        elif resp == "r" or resp == "rename":
            session_path = rename_session(session_path)
        elif resp == "s" or resp == "skip":
            continue
        elif resp == "e" or resp == "exit":
            return

        remote_session_path = remote_folder / Path(*session_path.parts[-3:])
        if not behavior_exists(remote_session_path):
            print(
                f"No behavior folder found in {remote_session_path}: skipping session..."
            )
            return
        # TODO: Check flagfiles on src.and dst + alf dir in session folder then remove
        # Try catch? wher catch condition is force transfer maybe
        transfer_folder(session_path / "raw_ephys_data",
                        remote_session_path / "raw_ephys_data",
                        force=force)
        # if behavior extract_me.flag exists remove it, because of ephys flag
        flag_file = session_path / "transfer_me.flag"
        flag_file.unlink()
        if (remote_session_path / "extract_me.flag").exists():
            (remote_session_path / "extract_me.flag").unlink()
        # Create remote flags
        create_ephys_transfer_done_flag(remote_session_path)
        check_create_raw_session_flag(remote_session_path)