# Capturing output of IJulia cell

**URL:** https://discourse.julialang.org/t/capturing-output-of-ijulia-cell/63519
**Category:** New to Julia
**Tags:** jump
**Created:** [June 25, 2021, 12:17am UTC](https://discourse.julialang.org/t/capturing-output-of-ijulia-cell/63519 "2021-06-25T00:17:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![anon94806364](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@anon94806364](https://discourse.julialang.org/u/anon94806364)
#### Post date: [June 25, 2021, 12:17am UTC](https://discourse.julialang.org/t/capturing-output-of-ijulia-cell/63519/1 "2021-06-25T00:17:03Z")

</div>

I recently switched from running an optimization problem in Python to Julia, and am really enjoying the change! However, I’ve noticed that when I run a long optimization problem and close a notebook:

1. I lose the output once it is completed - in Python I could run a cell magic (ie. `%%capture output`) to keep the printed output either in a file or below the cell, but the same magic does not apply to Julia. Is there an equivalent solution?
2. I also don’t see any results during the optimization process (ie. progress bar/iteration step). How do people who use JuMP monitor progress in an IJulia notebook?

Generally I’m curious about people’s workflows and I’d love to pick up some best practices from the Julia community. Thank you for your input!

---

<div class="post-metadata">

### Author: ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)
#### Post date: [June 25, 2021, 10:13pm UTC](https://discourse.julialang.org/t/capturing-output-of-ijulia-cell/63519/2 "2021-06-25T22:13:14Z")

</div>

1. If you save the notebook after the output has run, the printed output should be saved with the notebook.

2. I think there was an issue flushing io from external solvers to the notebook. I haven’t kept up on recent developments. I use vs-code instead: [https://www.julia-vscode.org](https://www.julia-vscode.org)

---

<div class="post-metadata">

### Author: ![polyactis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/polyactis/32/51034_2.png) [@polyactis](https://discourse.julialang.org/u/polyactis)
#### Post date: [June 25, 2023, 2:18am UTC](https://discourse.julialang.org/t/capturing-output-of-ijulia-cell/63519/3 "2023-06-25T02:18:20Z")

</div>

ProgressMeter is what you need.

```julia
using ProgressMeter, Flux

#define your model
....

optim = Flux.setup(Flux.Adam(0.01), model) # will store optimiser momentum, etc.

# Training loop, using the whole data set 1000 times:
loss_v = []
@showprogress for epoch in 1:1_000
    for (x, y) in loader
        loss, grads = Flux.withgradient(model) do m
            # Evaluate model and loss inside gradient context:
            y_hat = m(x)
            Flux.crossentropy(y_hat, y)
        end
        Flux.update!(optim, model, grads[1])
        push!(loss_v, loss) # logging, outside gradient context
    end
end

```
