Skip to content

Commit

Permalink
Avoid relpath bug on Windows (#16164)
Browse files Browse the repository at this point in the history
  • Loading branch information
carmocca committed Dec 22, 2022
1 parent b0648a4 commit 7f362fb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pytorch_lightning/utilities/migration/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from lightning_utilities.core.rank_zero import rank_zero_warn

import pytorch_lightning as pl
from lightning_fabric.utilities.imports import _IS_WINDOWS
from lightning_fabric.utilities.types import _PATH
from lightning_fabric.utilities.warnings import PossibleUserWarning
from pytorch_lightning.utilities.migration.migration import _migration_index
Expand Down Expand Up @@ -111,7 +112,10 @@ def _pl_migrate_checkpoint(checkpoint: _CHECKPOINT, checkpoint_path: Optional[_P

# include the full upgrade command, including the path to the loaded file in the error message,
# so user can copy-paste and run if they want
path_hint = os.path.relpath(checkpoint_path, os.getcwd())
if not _IS_WINDOWS: # side-step bug: ValueError: path is on mount 'C:', start on mount 'D:'
path_hint = os.path.relpath(checkpoint_path, os.getcwd())
else:
path_hint = os.path.abspath(checkpoint_path)
_log.info(
f"Lightning automatically upgraded your loaded checkpoint from v{old_version} to v{new_version}."
" To apply the upgrade to your files permanently, run"
Expand Down

0 comments on commit 7f362fb

Please sign in to comment.