Skip to content

store: download model before load #16552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
Closed

store: download model before load #16552

wants to merge 15 commits into from

Conversation

Borda
Copy link
Member

@Borda Borda commented Jan 30, 2023

What does this PR do?

the actual store requires a user to call download manually before loading, so we will do it for them...
as an improvement, resolving #15811 (comment)

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

Make sure you had fun coding 🙃

@Borda Borda marked this pull request as ready for review January 30, 2023 11:01
@github-actions
Copy link
Contributor

github-actions bot commented Jan 30, 2023

⚡ Required checks status: All passing 🟢

Groups summary

🟢 lightning: Store
Check ID Status
Store.cloud (test_store Linux) success
Store.cloud (test_store Mac) success
Store.cloud (test_store Windows) success

These checks are required after the changes to src/lightning/store/cloud_api.py, src/lightning/store/save.py, tests/tests_cloud/test_model.py.

🟢 mypy
Check ID Status
mypy success

These checks are required after the changes to src/lightning/store/cloud_api.py, src/lightning/store/save.py.

🟢 install
Check ID Status
install-pkg (ubuntu-22.04, app, 3.8) success
install-pkg (ubuntu-22.04, app, 3.10) success
install-pkg (ubuntu-22.04, fabric, 3.8) success
install-pkg (ubuntu-22.04, fabric, 3.10) success
install-pkg (ubuntu-22.04, pytorch, 3.8) success
install-pkg (ubuntu-22.04, pytorch, 3.10) success
install-pkg (ubuntu-22.04, lightning, 3.8) success
install-pkg (ubuntu-22.04, lightning, 3.10) success
install-pkg (ubuntu-22.04, notset, 3.8) success
install-pkg (ubuntu-22.04, notset, 3.10) success
install-pkg (macOS-12, app, 3.8) success
install-pkg (macOS-12, app, 3.10) success
install-pkg (macOS-12, fabric, 3.8) success
install-pkg (macOS-12, fabric, 3.10) success
install-pkg (macOS-12, pytorch, 3.8) success
install-pkg (macOS-12, pytorch, 3.10) success
install-pkg (macOS-12, lightning, 3.8) success
install-pkg (macOS-12, lightning, 3.10) success
install-pkg (macOS-12, notset, 3.8) success
install-pkg (macOS-12, notset, 3.10) success
install-pkg (windows-2022, app, 3.8) success
install-pkg (windows-2022, app, 3.10) success
install-pkg (windows-2022, fabric, 3.8) success
install-pkg (windows-2022, fabric, 3.10) success
install-pkg (windows-2022, pytorch, 3.8) success
install-pkg (windows-2022, pytorch, 3.10) success
install-pkg (windows-2022, lightning, 3.8) success
install-pkg (windows-2022, lightning, 3.10) success
install-pkg (windows-2022, notset, 3.8) success
install-pkg (windows-2022, notset, 3.10) success

These checks are required after the changes to src/lightning/store/cloud_api.py, src/lightning/store/save.py.


Thank you for your contribution! 💜

Note
This comment is automatically generated and updates for 60 minutes every 180 seconds. If you have any other questions, contact carmocca for help.

@Borda Borda marked this pull request as draft January 30, 2023 11:10
@Borda Borda marked this pull request as ready for review January 30, 2023 17:25
@Borda Borda requested review from ethanwharris, justusschock, pl-ghost and a team January 30, 2023 17:25
@Borda Borda enabled auto-merge (squash) January 30, 2023 17:25
Copy link
Member

@ethanwharris ethanwharris left a comment

Choose a reason for hiding this comment

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

Not sure the logic here makes sense

Comment on lines +331 to +332
if not os.path.exists(_LIGHTNING_STORAGE_FILE):
download_model(name=name, version=version, output_dir=_LIGHTNING_STORAGE_DIR, progress_bar=progress_bar)
Copy link
Member

Choose a reason for hiding this comment

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

This looks weird, we only want to download it if we haven't before right? Does download_model handle that? Or can you only download one at a time?

Also, after you do this one that file will exist, but then if you change the model the file still exists no? So probably this only works the first time you do it...

Copy link
Member Author

Choose a reason for hiding this comment

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

This looks weird, we only want to download it if we haven't before right? Does download_model handle that? Or can you only download one at a time?

good point, but I think this shall be handled on the download side...

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't the condition just before solving the issue?

if not os.path.exists(_LIGHTNING_STORAGE_FILE):

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ethanwharris 's point is that this has only a chance to run once, after which _LIGHTNING_STORAGE_FILE will exist.

Note that _LIGHTNING_STORAGE_FILE is defined as

_LIGHTNING_DIR = os.path.join(Path.home(), ".lightning")
__STORAGE_FILE_NAME = ".model_storage"
_LIGHTNING_STORAGE_FILE = os.path.join(_LIGHTNING_DIR, __STORAGE_FILE_NAME)

so it has nothing to do with the actual location where the specific model file has been saved. It only contains metadata, see:

https://github.com/Lightning-AI/lightning/blob/21a7aa2735d1617fc0ed581b318c6a8b5ca09d89/src/lightning/store/cloud_api.py#L284

The actual solution here is to peek into this file, extract the actual location and see if the specific model file exists. Then, if version is latest, we need to resolve it and see if it increased with respect to what it's contained in the storage file.

@mergify mergify bot added the has conflicts label Feb 2, 2023
@mergify mergify bot removed the has conflicts label Feb 2, 2023
@mergify mergify bot added the has conflicts label Mar 1, 2023
@stale stale bot added the won't fix This will not be worked on label Mar 18, 2023
@Lightning-AI Lightning-AI deleted a comment from stale bot Mar 18, 2023
@stale stale bot removed the won't fix This will not be worked on label Mar 18, 2023
@mergify mergify bot removed the has conflicts label Mar 23, 2023
@Borda Borda requested a review from ethanwharris March 23, 2023 10:20
@stale stale bot added the won't fix This will not be worked on label Apr 13, 2023
@stale stale bot removed the won't fix This will not be worked on label Apr 13, 2023
@Lightning-AI Lightning-AI deleted a comment from stale bot Apr 13, 2023
@mergify mergify bot removed the has conflicts label Apr 25, 2023
@Borda Borda self-assigned this Apr 27, 2023
@mergify mergify bot added the has conflicts label May 5, 2023
@mergify mergify bot removed the has conflicts label May 5, 2023
@Borda
Copy link
Member Author

Borda commented Aug 7, 2023

not needed in light of major refactor in #18234

@Borda Borda closed this Aug 7, 2023
auto-merge was automatically disabled August 7, 2023 12:44

Pull request was closed

@Borda Borda deleted the store/load branch July 26, 2024 11:57
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