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

Provide context manager for auto-cleanup() #112

Open
LordFckHelmchen opened this issue Apr 21, 2021 · 0 comments
Open

Provide context manager for auto-cleanup() #112

LordFckHelmchen opened this issue Apr 21, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@LordFckHelmchen
Copy link

The problem

After a local solver run, I understand that it might make sense to cleanup() the gekko files and the application (temp) directory. This always requires an explicit call to the according function. If forgotten, the files remain there.

Users

Normal users that just want to have a solution and don't care about the files.

The solution

Provide a context manager for the GEKKO class. For example

@contextmanager
def managed_gekko_solver(*args, **kwargs):
    """
    Context manager for the GEKKO class, to automatically clean-up temp. files & folders after solving.
    """
    solver = GEKKO(*args, **kwargs)
    try:
        yield solver
    finally:
        solver.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants