Lőrinc Pap commited on
Commit
32f7167
1 Parent(s): 03b5741

Simplify version check and make gdrive loading optional

Browse files
Files changed (1) hide show
  1. LLaMA_LoRA.ipynb +16 -19
LLaMA_LoRA.ipynb CHANGED
@@ -60,20 +60,15 @@
60
  "# @title A small workaround { display-mode: \"form\" }\n",
61
  "# @markdown Don't panic if you see an error here. Just click the `RESTART RUNTIME` button in the output below, then Run All again.\n",
62
  "# @markdown The error will disappear on the next run.\n",
63
- "!pip install Pillow==9.3.0 numpy==1.23.5\n",
64
  "\n",
 
65
  "import PIL\n",
66
- "major, minor = map(float, PIL.__version__.split(\".\")[:2])\n",
67
- "version_float = major + minor / 10**len(str(minor))\n",
68
- "print('PIL', version_float)\n",
69
- "if version_float < 9.003:\n",
70
- " raise Exception(\"Restart the runtime by clicking the 'RESTART RUNTIME' button above (or Runtime > Restart Runtime).\")\n",
71
- "\n",
72
  "import numpy\n",
73
- "major, minor = map(float, numpy.__version__.split(\".\")[:2])\n",
74
- "version_float = major + minor / 10**len(str(minor))\n",
75
- "print('numpy', version_float)\n",
76
- "if version_float < 1.0023:\n",
77
  " raise Exception(\"Restart the runtime by clicking the 'RESTART RUNTIME' button above (or Runtime > Restart Runtime).\")"
78
  ],
79
  "metadata": {
@@ -144,15 +139,17 @@
144
  "# colab_notebook_name = remove_ipynb_extension(colab_notebook_filename)\n",
145
  "\n",
146
  "from google.colab import drive\n",
147
- "drive.mount(google_drive_mount_path)\n",
 
148
  "\n",
149
- "# google_drive_data_directory_relative_path = f\"{google_drive_colab_data_folder}/{colab_notebook_name}\"\n",
150
- "google_drive_data_directory_relative_path = google_drive_folder\n",
151
- "google_drive_data_directory_path = f\"{google_drive_mount_path}/My Drive/{google_drive_data_directory_relative_path}\"\n",
152
- "!mkdir -p \"{google_drive_data_directory_path}\"\n",
153
- "!ln -nsf \"{google_drive_data_directory_path}\" ./data\n",
154
- "!touch \"data/This folder is used by the Colab notebook \\\"{colab_notebook_filename}\\\".txt\"\n",
155
- "!echo \"Data will be stored in Google Drive folder: \\\"{google_drive_data_directory_relative_path}\\\", which is mounted under \\\"{google_drive_data_directory_path}\\\"\"\n"
 
156
  ],
157
  "metadata": {
158
  "id": "iZmRtUY68U5f"
 
60
  "# @title A small workaround { display-mode: \"form\" }\n",
61
  "# @markdown Don't panic if you see an error here. Just click the `RESTART RUNTIME` button in the output below, then Run All again.\n",
62
  "# @markdown The error will disappear on the next run.\n",
63
+ "%pip install Pillow==9.3.0 numpy==1.23.5\n",
64
  "\n",
65
+ "import pkg_resources as r\n",
66
  "import PIL\n",
 
 
 
 
 
 
67
  "import numpy\n",
68
+ "for module, min_version in [(PIL, \"9.3\"), (numpy, \"1.23\")]:\n",
69
+ " lib_version = r.parse_version(module.__version__)\n",
70
+ " print(module.__name__, lib_version)\n",
71
+ " if lib_version < r.parse_version(min_version):\n",
72
  " raise Exception(\"Restart the runtime by clicking the 'RESTART RUNTIME' button above (or Runtime > Restart Runtime).\")"
73
  ],
74
  "metadata": {
 
139
  "# colab_notebook_name = remove_ipynb_extension(colab_notebook_filename)\n",
140
  "\n",
141
  "from google.colab import drive\n",
142
+ "try:\n",
143
+ " drive.mount(google_drive_mount_path)\n",
144
  "\n",
145
+ " google_drive_data_directory_relative_path = google_drive_folder\n",
146
+ " google_drive_data_directory_path = f\"{google_drive_mount_path}/My Drive/{google_drive_data_directory_relative_path}\"\n",
147
+ " !mkdir -p \"{google_drive_data_directory_path}\"\n",
148
+ " !ln -nsf \"{google_drive_data_directory_path}\" ./data\n",
149
+ " !touch \"data/This folder is used by the Colab notebook \\\"{colab_notebook_filename}\\\".txt\"\n",
150
+ " !echo \"Data will be stored in Google Drive folder: \\\"{google_drive_data_directory_relative_path}\\\", which is mounted under \\\"{google_drive_data_directory_path}\\\"\"\n",
151
+ "except Exception as e:\n",
152
+ " print(\"Drive won't be mounted!\")"
153
  ],
154
  "metadata": {
155
  "id": "iZmRtUY68U5f"