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()
      
      from my_pkg import foo  # Immediately 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.0.tar.gz (59.5 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.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for colab_assist-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6d254bbf691a2ef1443b95cf239d602cc19957c24a25c79d5690e62ac30fadc4
MD5 cd92731dd3fdfafe1e9dfc8ebf8f788e
BLAKE2b-256 4d4b4fb475da79c3718d588a461067bf5b4a3e674f57d0a44e5306fd0769ae1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for colab_assist-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9bcaf5f8870e273670a7552c476a8c5eb33b266c785dc6eb71089f940abae90e
MD5 40b894fd600072ef7ea187678a94bf05
BLAKE2b-256 c36a0e3be5b50d673f51a4ab0226fbc08f8fe12d8172da6818315c0cfd4e65c9

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