Skip to main content

git-timewarp

Oftentimes it's neccessary to go back to a previous commit. Perhaps you broke sometime and want to see where, or perhaps you want to benchmark an old version of a function. It's easy to git checkout, but what if you want to use two different versions of a function in the same script? Or use your latest testing/benchmarking code to run your old function? Fear not! git-timewarp allows you to temporarily import modules from a specified commit, performing all the git magic under the hood.

Here's how you use it. First, import the GitTimeWarp object. And the (current) version of a function you want to test.

from git_timewarp import GitTimeWarp
from test import test_func

Let's see the output of the current function

print(test_func())
new function output

Great. But what was the output of that function at an earlier commit? By entering a GitTimeWarp object, we can time travel to discover what it was. All in the same script!

with GitTimeWarp("a704acc5f651331645ee5850ff1cda0539cc23df") as tw:
    from test import test_func
    print(test_func())
old function output

Zounds! A ghost has appeared!

How does this work, you ask? The GitTimeWarp object simply checks out the old code in the timewarps/ folder (remember to add to your .gitignore!). It then modifies sys.path and does some more spicy python magic to ensure all imports in the block will reference the code in this other folder.

Metadata

Release files for git-timewarp 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for git-timewarp 0.0.2
File Size Uploaded
git-timewarp-0.0.2.tar.gz 2.9 kB Details

Release files / git-timewarp-0.0.2.tar.gz

Download URL git-timewarp-0.0.2.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
93769d492dfd42d1f0306a35e7ad13fcaf21b87f0874c59eb4575d75fcde69e6
BLAKE2b-256 checksum
How to use checksums
085abc1c0b2b4f308d7097234479572fac5b9a67f019cc32295e281031ad5d47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page