Skip to main content

Google Colab workflow utilities

Project description

colab-assist

Google Colab workflow utilities


Test PyPI Documentation Issues

CI workflow status Release workflow status Test coverage

About

  • colab-assist is a small package that shares the utility functions that I find useful for my development workflows on Google Colab.

  • Actually, this is also a semi-mock project that I use to learn Python open-source development. Feedbacks, pointers, and feature suggestions are much appreciated!

Usage

Experimenting your private Python package on Colab

  1. Develop your package any way you like and push it to your private GitHub repo.

  2. Make a repo-specific personal access token (PAT).

  3. Store the PAT as a Colab Secret:

    Colab Secrets demo

  4. On Colab:

    import colab_assist as A
    
    • Install → experiment → push → resintall:

      # Install your private package
      A.install("$my_token@me/my_pkg@feat/foo")
      
      # Experiment
      from my_pkg import foo
      foo()
      
      # Update the repo
      
      # Reinstall updated package
      A.install("$my_token@me/my_pkg@feat/foo")
      
      # Reimport updated functions/classes without needing to restart Colab session
      foo = A.reload(foo)
      foo()
      
    • Or clone → experiment → push → pull:

      # Clone your private package and automatically add it to `sys.path`
      A.clone("$my_token@me/my_pkg@feat/foo", x="p")
      
      # Experiment
      from my_pkg import foo
      foo()
      
      # Update the repo
      
      # Pull the update
      A.pull("my_pkg")
      
      # Reimport updated functions/classes without needing to restart Colab session
      foo = A.reload(foo)
      foo()
      
      # Or restart the Colab session with `sys.path` automatically recovered
      A.restart()
      
      import colab_assist as A  # Import `colab_assist` recovers previously extended `sys.path`
      from my_pkg import foo  # The clone is now again importable
      foo()
      
      # Terminate the Colab runtime with your clones automatically cleaned up
      A.end()
      

Text file creation and editing

# Create `foo.txt` at working directory and call `google.colab.files.view()` to edit it
A.edit("foo.txt", x="c")

Dependencies & Installation

  • Although currently colab-assist lists no dependencies, it is intended to only be installed and used in a Google Colab environment. The reason not to explicitly list dependencies for now is that at least one depedency (google-colab) is bespoke for Colab and not hosted on PyPI. However, colab-assist is designed to install and run just fine on a fresh Colab instance.

  • You can install colab-assist very quickly with pre-installed uv on Colab:

    !uv pip install --system -q colab-assist
    

    Or with pip:

    %pip install -q colab-assist
    

License

Acknowledgements

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

colab_assist-0.2.1.tar.gz (59.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

colab_assist-0.2.1-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file colab_assist-0.2.1.tar.gz.

File metadata

  • Download URL: colab_assist-0.2.1.tar.gz
  • Upload date:
  • Size: 59.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.0

File hashes

Hashes for colab_assist-0.2.1.tar.gz
Algorithm Hash digest
SHA256 cc535fceb1ca15dd296fc7d9a9aed42e53f199a1e9ea9e1c6537df1d64e2496a
MD5 49d4ab4bdf5158799238ed48de36a807
BLAKE2b-256 26b01dc754bc18d72ff4157c22dccbc1baf01a6e5799fbb1ee80f0734f4c19cf

See more details on using hashes here.

File details

Details for the file colab_assist-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for colab_assist-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 010a9a603966e2d0a60a73f5ec8d0c527e6c48940d997c0dab7357241a06c2b3
MD5 1a46f818f08ab6aba1cfb273b0ce0ab2
BLAKE2b-256 4ce8226a024e3777a92713b11c5b35f58387e3395ab4de5ec3a8c6261c8f7532

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page