ProgressLogging.jl icon indicating copy to clipboard operation
ProgressLogging.jl copied to clipboard

How can I use @logprogress inside a function called within an @withprogress macro?

Open HarrisonWilde opened this issue 4 years ago • 4 comments

Hi, I keep getting the following error when trying to call @logprogress in a function call to update a progress bar inside @withprogress wrapping my main execution loop, it works fine when the @logprogress is in this main loop level, but fails with the following error when I try to update progress within a function call in the loop:

ERROR: `@logprogress` must be used inside `@withprogress` or with `_id` keyword argument

I am not sure how I can pass this _id kwarg, I tried doing:

progress && ProgressLogging.@logprogress _id=progress_id t / Ntotal

But it doesn't change anything, any help would be appreciated

HarrisonWilde avatar Mar 15 '21 22:03 HarrisonWilde

Pretty sure that's just a bug which should be fixed by #41.

pfitzseb avatar Mar 16 '21 08:03 pfitzseb

Great thank you, so once it is merged, will the usage be to specify a parentid on the @withprogress call, then _id on the @logprogress calls? And the ID should presumably be the result of say: UUIDs.uuid1(Random.GLOBAL_RNG) for example?

HarrisonWilde avatar Mar 16 '21 15:03 HarrisonWilde

Just something like

@logprogress 0.2 _id=3 # it's up to you to ensure that "3" is unique :)

should do the trick. We have a global ID which will be used instead of the parentid with #41.

pfitzseb avatar Mar 16 '21 15:03 pfitzseb

Sorry could you clarify on that last part what you mean about using a global ID instead of parentid? Other than that sounds great though thanks for sorting it so quickly

HarrisonWilde avatar Mar 16 '21 15:03 HarrisonWilde