Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

fix: add automount folder when session creation occurs #588

Merged
merged 6 commits into from
May 17, 2022

Conversation

lizable
Copy link
Collaborator

@lizable lizable commented May 6, 2022

This PR resolves the issue raised on backend.ai-webui#1302.

@lizable lizable added this to the 22.03 milestone May 6, 2022
@lizable lizable requested review from achimnol and adrysn May 6, 2022 16:24
@lizable lizable self-assigned this May 6, 2022
@codecov
Copy link

codecov bot commented May 6, 2022

Codecov Report

Merging #588 (298ad95) into main (edb40bd) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #588      +/-   ##
==========================================
- Coverage   48.42%   48.41%   -0.02%     
==========================================
  Files          53       53              
  Lines        9131     9136       +5     
==========================================
+ Hits         4422     4423       +1     
- Misses       4709     4713       +4     
Impacted Files Coverage Δ
src/ai/backend/manager/models/vfolder.py 33.09% <0.00%> (-0.60%) ⬇️
src/ai/backend/manager/models/utils.py 75.17% <0.00%> (+0.70%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update edb40bd...298ad95. Read the comment docs.

@lizable lizable marked this pull request as ready for review May 6, 2022 16:29
Copy link
Member

@fregataa fregataa left a comment

Choose a reason for hiding this comment

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

thanks! I leave comments

# Fast-path for empty requested mounts
if not accessible_vfolders:
return []
from icecream import ic
Copy link
Member

Choose a reason for hiding this comment

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

is this used for debugging? ic is used on 559 line!

Copy link
Member

Choose a reason for hiding this comment

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

@lizable If you want to suggest icecream as a tool for development setups, please add it the setup.cfg's options.extra_require.dev section but remove in the final PR code for review & production.

FYI: To debug-print something with its own expression, try print(f"{expr=}") in Python. (ref)
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My mistakes. I'll fix it right away.

Comment on lines 542 to 546
for vfolder in accessible_vfolders:
if vfolder['name'] == requested_vfolder_names[key]:
break
else:
raise VFolderNotFound(f"VFolder {vfolder_name} is not found or accessible.")
if vfolder['name'] not in requested_vfolder_names:
raise VFolderNotFound(f"VFolder {vfolder_name} is not found or accessible.")
Copy link
Member

@fregataa fregataa May 7, 2022

Choose a reason for hiding this comment

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

accessible_vfolder_names = set(vfolder['name'] for vfolder in accessible_vfolders)
for key, vfolder_name in requested_vfolder_names.items():
        if vfolder_name not in accessible_vfolder_names:
            raise VFolderNotFound(f"VFolder {vfolder_name} is not found or accessible.")
...

how about this?
rather iterating all accessible_vfolders, using comprehension seems clear

Copy link
Collaborator Author

@lizable lizable May 9, 2022

Choose a reason for hiding this comment

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

Hmm, there seems to be a reason for iterating whole accessible_vfolders. As you can see here, the conditional statement(if clause) breaks and those "items"(which is assigned to vfolder) in accessible_vfolders used from here to the end of the function prepare_vfolder_mounts.
IMHO, replacing accessible_vfolders with accessible_vfolder_names should be reconsidered.

Copy link
Member

Choose a reason for hiding this comment

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

I think Sanghun's suggestion is good. The original inner for-loop is a boilerplate.

Copy link
Member

@adrysn adrysn left a comment

Choose a reason for hiding this comment

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

Tested and it is working.

Comment on lines 530 to 531
if not accessible_vfolders:
return []
Copy link
Member

Choose a reason for hiding this comment

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

I think we should handle this case as well.
Instead of directly applying my suggestion, could we simplify the matching?

Suggested change
if not accessible_vfolders:
return []
if not accessible_vfolders:
if requested_vfolder_names:
raise VFolderNotFound(f"VFolder {requested_vfolder_names[0]} is not found or accessible.")
else:
return []

Comment on lines 535 to 538
for vfolder in accessible_vfolders:
if vfolder['name'].startswith('.'):
requested_vfolder_names.setdefault(vfolder['name'], vfolder['name'])
requested_vfolder_subpaths.setdefault(vfolder['name'], '.')
Copy link
Member

Choose a reason for hiding this comment

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

👍🏼

Comment on lines 535 to 538
for vfolder in accessible_vfolders:
if vfolder['name'].startswith('.'):
requested_vfolder_names.setdefault(vfolder['name'], vfolder['name'])
requested_vfolder_subpaths.setdefault(vfolder['name'], '.')
Copy link
Member

Choose a reason for hiding this comment

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

👍🏼

Comment on lines 542 to 546
for vfolder in accessible_vfolders:
if vfolder['name'] == requested_vfolder_names[key]:
break
else:
raise VFolderNotFound(f"VFolder {vfolder_name} is not found or accessible.")
if vfolder['name'] not in requested_vfolder_names:
raise VFolderNotFound(f"VFolder {vfolder_name} is not found or accessible.")
Copy link
Member

Choose a reason for hiding this comment

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

I think Sanghun's suggestion is good. The original inner for-loop is a boilerplate.

@achimnol achimnol merged commit 3326420 into main May 17, 2022
@achimnol achimnol deleted the fix/automount-folder-on-session-creation branch May 17, 2022 05:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants