Colab Transfer: transfer data between Colab & Drive
This repository contains Python code to transfer data between Google Colab and Google Drive.
Disclaimer: If files or folders already exist at the destination, then they will not be overwritten. If you want to force an update, ensure that you delete them first.
Installation
The code is packaged for PyPI, so that the installation consists in running:
pip install colab_transfer
Usage
Get the path to the home folder of the local machine for your session on Colaboratory
import colab_transfer
colab_path = colab_transfer.get_path_to_home_of_local_machine()
Get the path to the home folder on Google Drive
import colab_transfer
drive_path = colab_transfer.get_path_to_home_of_google_drive()
Mount Google Drive
NB: you will have to manually input the authorization code.
import colab_transfer
colab_transfer.mount_google_drive()
Check whether Google Drive is mounted
import colab_transfer
google_drive_is_mounted = colab_transfer.is_google_drive_mounted()
Copy a file from Drive to Colaboratory
import colab_transfer
colab_path = colab_transfer.get_path_to_home_of_local_machine()
drive_path = colab_transfer.get_path_to_home_of_google_drive()
input_file_name = 'dummy_file.txt'
colab_transfer.copy_file(
file_name=input_file_name,
source=drive_path,
destination=colab_path,
)
Copy a file from Colaboratory to Drive
import colab_transfer
colab_path = colab_transfer.get_path_to_home_of_local_machine()
drive_path = colab_transfer.get_path_to_home_of_google_drive()
input_file_name = 'dummy_file.txt'
colab_transfer.copy_file(
file_name=input_file_name,
source=colab_path,
destination=drive_path,
)
Copy a folder structure from Drive to Colaboratory
import colab_transfer
colab_path = colab_transfer.get_path_to_home_of_local_machine()
drive_path = colab_transfer.get_path_to_home_of_google_drive()
input_folder_name = 'dummy_folder/'
colab_transfer.copy_folder_structure(
source=drive_path + input_folder_name,
destination=colab_path + input_folder_name,
)
Alternatively:
import colab_transfer
colab_path = colab_transfer.get_path_to_home_of_local_machine()
drive_path = colab_transfer.get_path_to_home_of_google_drive()
input_folder_name = 'dummy_folder/'
colab_transfer.copy_folder(
folder_name=input_folder_name,
source=drive_path,
destination=colab_path,
)
Copy a folder structure from Colaboratory to Drive
import colab_transfer
colab_path = colab_transfer.get_path_to_home_of_local_machine()
drive_path = colab_transfer.get_path_to_home_of_google_drive()
input_folder_name = 'dummy_folder/'
colab_transfer.copy_folder_structure(
source=colab_path + input_folder_name,
destination=drive_path + input_folder_name,
)
Alternatively:
import colab_transfer
colab_path = colab_transfer.get_path_to_home_of_local_machine()
drive_path = colab_transfer.get_path_to_home_of_google_drive()
input_folder_name = 'dummy_folder/'
colab_transfer.copy_folder(
folder_name=input_folder_name,
source=colab_path,
destination=drive_path,
)
Metadata
Release files for Google-Colab-Transfer 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Google Colab Transfer-0.1.6.tar.gz | 4.7 kB | Without provenance | Details for Google Colab Transfer-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Google_Colab_Transfer-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for Google_Colab_Transfer-0.1.6-py3-none-any.whl |
Total release size: 11.8 kB
Release files / Google Colab Transfer-0.1.6.tar.gz
| Download URL | Google Colab Transfer-0.1.6.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
faf058e84cf3448de01954ad5250bbabec5da5a9da3c89dd159def816ca056ac
|
|
BLAKE2b-256 checksum How to use checksums |
99ee3e37cff597122043536230bf1690a6e82de1e327f4c639bae6e4d369aa18
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0
|
Release files / Google_Colab_Transfer-0.1.6-py3-none-any.whl
| Download URL | Google_Colab_Transfer-0.1.6-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b98e50dda6b21b31eb4c178f9c6d63ff9bf2c3eaa1ca24371e5b55e0ddb918c1
|
|
BLAKE2b-256 checksum How to use checksums |
a09076fc38bcad442018977ed0e4e663473ef56a4d15395b2aa09055e8c49185
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0
|
Security for Google-Colab-Transfer 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.