Skip to content

Commit

Permalink
Merge pull request #294 from leetfin/patch-drive-folderpath
Browse files Browse the repository at this point in the history
Remove space from "My Drive" folder path
  • Loading branch information
minimaxir committed May 22, 2022
2 parents d1e97f5 + b79c506 commit f09f5c8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions gpt_2_simple/gpt_2.py
Expand Up @@ -580,15 +580,15 @@ def copy_checkpoint_to_gdrive(run_name='run1', copy_folder=False):
checkpoint_folder = os.path.join('checkpoint', run_name)

if copy_folder:
shutil.copytree(checkpoint_folder, "/content/drive/My Drive/" + checkpoint_folder)
shutil.copytree(checkpoint_folder, "/content/drive/MyDrive/" + checkpoint_folder)
else:
file_path = get_tarfile_name(checkpoint_folder)

# Reference: https://stackoverflow.com/a/17081026
with tarfile.open(file_path, 'w') as tar:
tar.add(checkpoint_folder)

shutil.copyfile(file_path, "/content/drive/My Drive/" + file_path)
shutil.copyfile(file_path, "/content/drive/MyDrive/" + file_path)


def copy_checkpoint_from_gdrive(run_name='run1', copy_folder=False):
Expand All @@ -598,11 +598,11 @@ def copy_checkpoint_from_gdrive(run_name='run1', copy_folder=False):
checkpoint_folder = os.path.join('checkpoint', run_name)

if copy_folder:
shutil.copytree("/content/drive/My Drive/" + checkpoint_folder, checkpoint_folder)
shutil.copytree("/content/drive/MyDrive/" + checkpoint_folder, checkpoint_folder)
else:
file_path = get_tarfile_name(checkpoint_folder)

shutil.copyfile("/content/drive/My Drive/" + file_path, file_path)
shutil.copyfile("/content/drive/MyDrive/" + file_path, file_path)

with tarfile.open(file_path, 'r') as tar:
tar.extractall()
Expand All @@ -612,14 +612,14 @@ def copy_file_to_gdrive(file_path):
"""Copies a file to a mounted Google Drive."""
is_mounted()

shutil.copyfile(file_path, "/content/drive/My Drive/" + file_path)
shutil.copyfile(file_path, "/content/drive/MyDrive/" + file_path)


def copy_file_from_gdrive(file_path):
"""Copies a file from a mounted Google Drive."""
is_mounted()

shutil.copyfile("/content/drive/My Drive/" + file_path, file_path)
shutil.copyfile("/content/drive/MyDrive/" + file_path, file_path)


def is_gpt2_downloaded(model_dir='models', model_name='124M'):
Expand Down

0 comments on commit f09f5c8

Please sign in to comment.