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.4.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.4-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for colab_assist-0.2.4.tar.gz
Algorithm Hash digest
SHA256 226c16af244c6748f56b9987ce1bc1233580b734c0cf795a9ca23e7603a90fb8
MD5 20e26a6a39e01c709b8fd2626a135a8e
BLAKE2b-256 b715ede8379cecdfe22e01dc61b83bf4cd9eaa897316352fb7cbbad9ac2ed6bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for colab_assist-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b846cc6bfe173e4e854eb02b53590854a0b5cc7a2ed24b69c0ccf8782da200e7
MD5 74b75bf1e00a672474c4c17cecf05d4c
BLAKE2b-256 76c2f77a92811e840fc77003e63357cb6414095e7a968717b2ee560c8365b7a9

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