:mega: two new Metaflow features which I'd like to...
# ask-metaflow
s
📣 two new Metaflow features which I'd like to attribute to @lively-lunch-9285 - thanks for ideas and feedback! happydance 1. Today's Metaflow, 2.13.3, includes a default
@card
that shows the source code of the corresponding step 🐍 a. In other words, you can see the code executed in the Metaflow UI (and the card viewer) 2. A small new handy utility:
pip install metaflow-diff
(repo here). It runs
git diff
between a Metaflow run and the current working directory, so you can a. See what has changed between a past run and the status quo b. Reset the current working directory back to the state of a past run to reproduce past results c. Unpack a past code package to a local directory so you can inspect and rerun code written by your or your colleagues easily See the features in action below! 📺
slack on fire 7
fireworks 2 4
h
Very cool! Is it possible to diff 2 runs too?
v
not yet but PRs are very welcome 😄
h
i
Nice!
v
@hundreds-rainbow-67050 merged! Note that
git apply
is very particular how it wants the paths to appear in the diff output, so I had to fix
source_file
and
target_file
logic in your PR (also disable color output for patches and non-terminal output)
even before my changes, the test complained
Copy code
AssertionError: Expected 'run' to be called once. Called 2 times.
I am not sure how it's supposed to work so if you have a chance, take a look if the tests still pass for you when it comes to the
patch
command, the best test would be 1. Run a flow, run id X 2. Make a change 3.
patch X
4. Run
git apply
to apply the patch (as instructed in the
patch
command output) 5. Assert that (2) was reverted properly
diff-runs
seems to work nicely - that's a great addition - thanks! bowq
h
Hmm not sure how that happened. Fixed the tests: https://github.com/outerbounds/metaflow-diff/pull/5
v
cool, works now except a small glitch
Copy code
python test_metaflow_diff.py > a
works since it does
--no-color
. Without
> a
it doesn't work as it does
--color
instead of
--no-color
breaking
assert_any_call
🙂
maybe you can do
Copy code
if sys.stdout.isatty():
                color = ["--color"]
            else:
                color = ["--no-color"]
in the test too 🤷
h
Weird. I usually run it with
pytest test_metaflow_diff.py
and
pytest test_metaflow_diff.py > a
also works.
python test_metaflow_diff.py > a
doesn't produce any output in
a
for me, so not sure what that's even supposed to do
v
piping it to a file makes
sys.stdout.isatty()
eval to False, so we use
--no-color
The current test asserts that diff output has
--no-color
which is not true when you are outputting a diff in the terminal (since we want a colored output)
h
ok fixed
v
works, merged! yay
fox yay 1