Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use in script with BlockingRunner: get log and/or feedback on progress #436

Closed
bonh opened this issue Jun 21, 2023 · 4 comments · Fixed by #441
Closed

Use in script with BlockingRunner: get log and/or feedback on progress #436

bonh opened this issue Jun 21, 2023 · 4 comments · Fixed by #441

Comments

@bonh
Copy link

bonh commented Jun 21, 2023

In a notebook, I can use live_info() to display the progress. Is something similar available if I run adaptive in a script?

basnijholt added a commit that referenced this issue Aug 20, 2023
basnijholt added a commit that referenced this issue Aug 20, 2023
@basnijholt
Copy link
Member

basnijholt commented Aug 20, 2023

@bonh, that is currently not available, however, I just opened #441 to add this.

Use like:

python live-info-example.py

import adaptive
import asyncio
import random

offset = random.uniform(-0.5, 0.5)


def peak(x, offset=offset, wait=True):
    from random import random
    from time import sleep

    a = 0.01
    if wait:
        # we pretend that this is a slow function
        sleep(random())

    return x + a**2 / (a**2 + (x - offset) ** 2)

learner = adaptive.Learner1D(peak, bounds=(-1, 1))
runner = adaptive.Runner(learner, loss_goal=0.01)


async def run(runner, fname: str):
    runner.live_info_terminal(overwrite_previous=True)
    await runner.task
    runner.learner.save(fname)


runner.ioloop.run_until_complete(run(runner, "learner.pkl"))

@basnijholt
Copy link
Member

Screen Recording 2023-08-20 at 1 19 30 PM

@bonh
Copy link
Author

bonh commented Oct 19, 2023

Sry, I got distracted. Thanks for the suggestion! I hope to try it soon.

basnijholt added a commit that referenced this issue Feb 13, 2024
* Add live_info_terminal, closes #436

* Add time

* rename var

* Add doc-string
@bonh
Copy link
Author

bonh commented May 3, 2024

perfect, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants