Skip to content

Update [Notebook] : Add bypass function to directly download outputsfrom execution name + add check on each step to verify needed files are here - #59

Open
Albireo-B wants to merge 6 commits into
virtual-imaging-platform:developfrom
Albireo-B:fix/freesurfer_notebook
Open

Albireo-B wants to merge 6 commits into
virtual-imaging-platform:developfrom
Albireo-B:fix/freesurfer_notebook

Conversation

@Albireo-B

Copy link
Copy Markdown
Contributor

No description provided.

…from execution name + add check on each step to verify needed files are here
Guillaume V. added 2 commits October 2, 2026 10:50
Comment thread src/vip_client/utils/vip.py
Comment thread src/vip_client/utils/vip.py Outdated
" if f.is_dir():\n",
" flatten_folder(Path(f))"
"session_name = restore_session_from_output_dir(FS_CROSS_OUTPUT_DIR) # Replace with a specific session name if needed\n",
"download_by_session_name(session_name, str(FS_CROSS_OUTPUT_DIR))\n",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it to avoid downloading files already present ?
does not session.download_outputs handle that ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it avoid re-downloading by checking existence and file size. It also avoids the creation of the VIP timestamp folder that I had to flatten before.
session.download_outputs does try to check for existing files but include the timestamp folder in the path, which I don't have if it's a rerun (flattened). Other than that it has the download size check I added in the new download functions, but in my download_by_session_name function I also do the VIP expected size check pre-download to filter files.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the download though vip with also benefit from the new download checks added in vip.py.
if i'm not mistaking, the only benefit here is to "flatten" / download without the timestamp folder.
would it not be possible to add this option in session.download_outputs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed custom download_by_session_name and added direct_download_path field to the download functions

"for f in FS_CROSS_OUTPUT_DIR.iterdir():\n",
" if f.is_dir():\n",
" flatten_folder(Path(f))"
"session_name = restore_session_from_output_dir(FS_CROSS_OUTPUT_DIR) # Replace with a specific session name if needed\n",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can there be several session_name in 1 output folder ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No there can be only one, as there is only one session_data.json per output folder

"# Since results may arrive in a VipSession folder (2026-X), when it's the case we flatten this folder to put files directly under FS_CROSS_OUTPUT_DIR\n",
"for f in FS_CROSS_OUTPUT_DIR.iterdir():\n",
" if f.is_dir():\n",
" flatten_folder(Path(f))"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it is better to not do that, but does it not change something when we when to list the tar.gz latter ?
Or does the new download_by_session_name method change that ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was removed by previous commit since we now directly download files inside output folder and not through VIP timestamp folder, so we don't need the flatten anymore.
For the tar.gz we need the files to be directly under the output folder to use FS_CROSS_OUTPUT_DIR.iterdir().

Comment thread src/vip_client/utils/vip.py Outdated

#-----------------------------------------------------------------------------
def remove_local_file(path):
if path is None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe verify that os.path.exists(path) ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/vip_client/utils/vip.py
" if f.is_dir():\n",
" flatten_folder(Path(f))"
"session_name = restore_session_from_output_dir(FS_CROSS_OUTPUT_DIR) # Replace with a specific session name if needed\n",
"download_by_session_name(session_name, str(FS_CROSS_OUTPUT_DIR))\n",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the download though vip with also benefit from the new download checks added in vip.py.
if i'm not mistaking, the only benefit here is to "flatten" / download without the timestamp folder.
would it not be possible to add this option in session.download_outputs

" missing = expected_paths - actual_paths\n",
" print(f\" → {out_tar.name} exists but missing {len(missing)} files, regenerating.\")\n",
" except (tarfile.TarError, OSError):\n",
" print(f\" → {out_tar.name} exists but is corrupted, regenerating.\")\n",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that works, but i wonder if using some timestamps like just above would not be simpler.
if any of the extracted dir of the subject is newer that the tar timestamp, then re-do tar.
would that work ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would, added the check

…ssion download_outputs function to handle direct path download + add/improve checks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants